Skip to content

Commit a0236f3

Browse files
committed
添加渲染参数
1 parent 15b9aa1 commit a0236f3

File tree

3 files changed

+2028
-280
lines changed

3 files changed

+2028
-280
lines changed

demo/Assets/Scripts/Tools.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.

demo/Assets/Scripts/UI/UI_GenNameMap.cs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,62 @@ void Start ()
2424
_btnGen.onClick.AddListener(GenMap);
2525

2626
_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);
2735
}
2836

2937
private static Texture2D _txtTexture;
3038
const int TextureScale = 20;
3139
private const int Width = 100;
3240
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)
3469
{
35-
//Random.seed = 1;
70+
if (check)
71+
_isLake = true;
72+
}
3673

74+
private void GenMap()
75+
{
76+
Random.seed = 1;
3777
_txtTexture = GetTextTexture();
3878

3979
Map.Width = Width;
4080
Map.Height = Height;
4181
Map map = new Map();
42-
map.SetPointNum(2500);
82+
map.SetPointNum(_pointNum);
4383
map.Init(CheckIsland());
4484
//扰乱边缘
4585
NoisyEdges noisyEdge = new NoisyEdges();
@@ -54,7 +94,12 @@ public static System.Func<Vector2, bool> CheckIsland()
5494
int x = Convert.ToInt32(q.x / Width * _txtWidth);
5595
int y = Convert.ToInt32(q.y / Height * _txtHeight);
5696
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;
58103
};
59104
return inside;
60105
}
@@ -77,7 +122,7 @@ private Texture2D GetTextTexture()
77122
gText.anchor = TextAnchor.MiddleCenter;
78123
gText.alignment = TextAlignment.Center;
79124
gText.font = _dFont;
80-
gText.fontSize = 125;
125+
gText.fontSize = gText.text.Length <=3?125: 100;
81126

82127
_showMap.SetActive(false);
83128
myCamera.Render();

0 commit comments

Comments
 (0)