refactor: Hex, cell
cell - delete Hex - refactor, feature State: stable В Hex перенесен функционал из cell.
This commit is contained in:
@@ -7,12 +7,14 @@ public class Hex : MonoBehaviour
|
||||
public enum landscapeTypes { water, land, hill, highHill, mountain, uncrosableMountain };
|
||||
public enum stateTypes { idle, owned, battle };
|
||||
|
||||
|
||||
|
||||
public Vector2Int position;
|
||||
public float noiseValue;
|
||||
public landscapeTypes landType;
|
||||
public int miniMapSeed;
|
||||
|
||||
public int income; //Ìîäèôèêàòîð ê äîõîäó â åäåíèöó âðåìåíè îò ýòîãî ãåêñà
|
||||
public int income { get; private set; } //Ìîäèôèêàòîð ê äîõîäó â åäåíèöó âðåìåíè îò ýòîãî ãåêñà
|
||||
public int ownerID;
|
||||
public stateTypes state = stateTypes.idle;
|
||||
|
||||
@@ -29,4 +31,98 @@ public class Hex : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void InitializeHex(Vector2Int pos, float noiseVal, int seed)
|
||||
{
|
||||
noiseValue = noiseVal;
|
||||
position = pos;
|
||||
//Debug.Log(noiseValue);
|
||||
noiseValue = Mathf.Pow(noiseValue, 1.7f); //Óðåç÷åíèå ïåðåõîäîâ ëàíäøàôòà
|
||||
|
||||
miniMapSeed = seed + position.x * 100000 + position.y;
|
||||
|
||||
|
||||
|
||||
//Âûíåñòè ýòè âåëå÷èíû â íàñòðîéêè
|
||||
float waterLevel = 0.34f;
|
||||
float landLevel = 0.4f;
|
||||
float hillLevel = 0.6f;
|
||||
float highHillLevel = 0.75f;
|
||||
float mountainLevel = 0.95f;
|
||||
|
||||
|
||||
//Îïðåäåëåíèå òèïà ëàíäøàôòà
|
||||
if (noiseValue <= waterLevel)
|
||||
{
|
||||
landType = landscapeTypes.water;
|
||||
}
|
||||
else if (noiseValue <= landLevel)
|
||||
{
|
||||
landType = landscapeTypes.land;
|
||||
}
|
||||
else if (noiseValue <= hillLevel)
|
||||
{
|
||||
landType = landscapeTypes.hill;
|
||||
}
|
||||
else if (noiseValue <= highHillLevel)
|
||||
{
|
||||
landType = landscapeTypes.highHill;
|
||||
}
|
||||
else if (noiseValue <= mountainLevel)
|
||||
{
|
||||
landType = landscapeTypes.mountain;
|
||||
}
|
||||
else
|
||||
{
|
||||
landType = landscapeTypes.uncrosableMountain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
InitializeTexture();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void InitializeTexture()
|
||||
{
|
||||
Color color = new Color(0,0,0,0);
|
||||
|
||||
float pow = 1.2f; //ñòåïåíü â êîòîðóþ âîçâîäòèòñÿ øóì äëÿ äîïîëíèòåëüíîãî óðåç÷åíèÿ öâåòîâ'
|
||||
|
||||
float val = Mathf.Pow(noiseValue, pow);
|
||||
|
||||
switch (landType)
|
||||
{
|
||||
case landscapeTypes.water:
|
||||
color = new Color(noiseValue * 0.2f, noiseValue * 0.2f, noiseValue + 0.1f);
|
||||
break;
|
||||
|
||||
case landscapeTypes.land:
|
||||
color = new Color(noiseValue * 0.3f, noiseValue + 0.3f, noiseValue * 0.3f);
|
||||
break;
|
||||
|
||||
case landscapeTypes.hill:
|
||||
color = new Color(noiseValue * 0.5f, noiseValue + 0.3f, noiseValue * 0.2f);
|
||||
break;
|
||||
|
||||
case landscapeTypes.highHill:
|
||||
color = new Color(noiseValue * 0.7f, noiseValue + 0.3f, noiseValue * 0.2f);
|
||||
break;
|
||||
|
||||
case landscapeTypes.mountain:
|
||||
color = new Color(noiseValue * 0.8f + 0.1f, noiseValue * 0.4f, noiseValue * 0.2f);
|
||||
break;
|
||||
|
||||
case landscapeTypes.uncrosableMountain:
|
||||
color = new Color(noiseValue * 0.6f + 0.0f, noiseValue * 0.1f, noiseValue * 0.0f);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
GetComponent<SpriteRenderer>().color = color;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user