using System.Collections; using System.Collections.Generic; using UnityEngine; 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 { get; private set; } //Модификатор к доходу в еденицу времени от этого гекса public int ownerID; public stateTypes state = stateTypes.idle; //TODO переменная для памати содержимого // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } 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().color = color; } }