using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class WindProcessor : MonoBehaviour {

    public float WindAngle = 0.0f;
    public float NextWindChange = 0.0f;
    public float WindSpeed = 1.5f;

    public GameObject CompassArt = null;
    public TextMeshProUGUI WindSpeedText = null;

    // Use this for initialization
	void Start () {
        WindAngle = Random.Range(0.0f, 360.0f);
        ChangeWind();
	}

    void ChangeWind()
    {
        WindAngle += Random.Range(-120.0f, 120.0f);
        NextWindChange = Time.time + Random.Range(15.0f, 30.0f);
        CompassArt.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, -WindAngle);
        WindSpeed = Random.Range(0.0f, 0.8f); 
        WindSpeedText.text = ((int)(WindSpeed * 50)).ToString() + "km/h";

        GetComponent<CombustibleProcessor>().RebuildAllNeighbourTables();
    }

    // Update is called once per frame
    void Update () {
        if (Time.time > NextWindChange)
        {
            ChangeWind();
        }
		
	}
}
