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;

    }
}

