@@ -24,22 +24,62 @@ void Start ()
24
24
_btnGen . onClick . AddListener ( GenMap ) ;
25
25
26
26
_showMap = GameObject . Find ( "Map" ) ;
27
+
28
+ transform . FindChild ( "Toggles1/Toggle1" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( Toggle1 ) ;
29
+ transform . FindChild ( "Toggles1/Toggle2" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( Toggle2 ) ;
30
+ transform . FindChild ( "Toggles1/Toggle3" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( Toggle3 ) ;
31
+ transform . FindChild ( "Toggles1/Toggle4" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( Toggle4 ) ;
32
+
33
+ transform . FindChild ( "Toggles2/Toggle1" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( ToggleLand ) ;
34
+ transform . FindChild ( "Toggles2/Toggle2" ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( ToggleLake ) ;
27
35
}
28
36
29
37
private static Texture2D _txtTexture ;
30
38
const int TextureScale = 20 ;
31
39
private const int Width = 100 ;
32
40
private const int Height = 50 ;
33
- private void GenMap ( )
41
+ private int _pointNum = 1000 ;
42
+ private static bool _isLake ;
43
+ void Toggle1 ( bool check )
44
+ {
45
+ if ( check )
46
+ _pointNum = 1000 ;
47
+ }
48
+ void Toggle2 ( bool check )
49
+ {
50
+ if ( check )
51
+ _pointNum = 2500 ;
52
+ }
53
+ void Toggle3 ( bool check )
54
+ {
55
+ if ( check )
56
+ _pointNum = 4000 ;
57
+ }
58
+ void Toggle4 ( bool check )
59
+ {
60
+ if ( check )
61
+ _pointNum = 10000 ;
62
+ }
63
+ void ToggleLand ( bool check )
64
+ {
65
+ if ( check )
66
+ _isLake = false ;
67
+ }
68
+ void ToggleLake ( bool check )
34
69
{
35
- //Random.seed = 1;
70
+ if ( check )
71
+ _isLake = true ;
72
+ }
36
73
74
+ private void GenMap ( )
75
+ {
76
+ Random . seed = 1 ;
37
77
_txtTexture = GetTextTexture ( ) ;
38
78
39
79
Map . Width = Width ;
40
80
Map . Height = Height ;
41
81
Map map = new Map ( ) ;
42
- map . SetPointNum ( 2500 ) ;
82
+ map . SetPointNum ( _pointNum ) ;
43
83
map . Init ( CheckIsland ( ) ) ;
44
84
//扰乱边缘
45
85
NoisyEdges noisyEdge = new NoisyEdges ( ) ;
@@ -54,7 +94,12 @@ public static System.Func<Vector2, bool> CheckIsland()
54
94
int x = Convert . ToInt32 ( q . x / Width * _txtWidth ) ;
55
95
int y = Convert . ToInt32 ( q . y / Height * _txtHeight ) ;
56
96
Color tColor = _txtTexture . GetPixel ( x , y ) ;
57
- return tColor == Color . white ;
97
+ bool isLand = false ;
98
+ if ( _isLake )
99
+ isLand = tColor != Color . white ;
100
+ else
101
+ isLand = tColor == Color . white ;
102
+ return isLand ;
58
103
} ;
59
104
return inside ;
60
105
}
@@ -77,7 +122,7 @@ private Texture2D GetTextTexture()
77
122
gText . anchor = TextAnchor . MiddleCenter ;
78
123
gText . alignment = TextAlignment . Center ;
79
124
gText . font = _dFont ;
80
- gText . fontSize = 125 ;
125
+ gText . fontSize = gText . text . Length <= 3 ? 125 : 100 ;
81
126
82
127
_showMap . SetActive ( false ) ;
83
128
myCamera . Render ( ) ;
0 commit comments