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

public class Warm : MonoBehaviour {
    public float radius = 20f;
    public float tmpPerSecTimesDistance = 2.5f;

	void Update ()
    {
        var cols = Physics.OverlapSphere(transform.position, radius);
        foreach (var col in cols)
        {
            var tile = col.GetComponentInParent<Tile>();
            if (tile == null)
                continue;
            var sqrDistance = Vector3.SqrMagnitude(transform.position - tile.transform.position);
            if (tile.temperature < 0.4f)
                tile.temperature += tmpPerSecTimesDistance/sqrDistance * Time.deltaTime;
            tile.temperature = Mathf.Clamp(tile.temperature, -1, 1);
        }
	}
}
