Files
hexwar/Assets/scripts/cell.cs
2026-01-13 19:09:23 +03:00

64 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cell : MonoBehaviour
{
public Vector2Int pos = new Vector2Int(0, 0);
public float noiseValue;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
/*
GetComponent<SpriteRenderer>().color = new Color(noiseValue, noiseValue, noiseValue, 1);
noiseValue = Random.Range(0f, 1f);
*/
}
public void Init()
{
//Debug.Log(noiseValue);
noiseValue = Mathf.Pow(noiseValue, 1.7f);
float pow = 1.2f;
Color color;
if (noiseValue <= 0.35)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.2f, noiseValue * 0.2f, noiseValue + 0.1f);//âîäà
}
else if (noiseValue <= 0.5)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.4f, noiseValue+0.3f, noiseValue*0.4f);//íèçèíà
}
else if (noiseValue <= 0.8)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue * 0.2f, noiseValue + 0.3f, noiseValue * 0.2f);//ïîëå
}
else if (noiseValue <= 0.95)
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.8f + 0.1f, noiseValue * 0.4f, noiseValue * 0.2f);//ãîðû
}
else
{
noiseValue = Mathf.Pow(noiseValue, pow);
color = new Color(noiseValue*0.6f + 0.0f, noiseValue * 0.1f, noiseValue * 0.0f);//íåïðîõîäèìûé ïèê
}
GetComponent<SpriteRenderer>().color = color;
}
}