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

[CreateAssetMenu(menuName = "Actions/Pump")]
public class ActionPump: ActionAsset {

    public int range = 4;

    public override void Action(Tile targetTile)
    {
        base.Action(targetTile);


        targetTile.waterLevel = 0;

        int minX = (int)Mathf.Clamp(targetTile.tileX - range, 0, TileManager.Instance.width);
        int maxX = (int)Mathf.Clamp(targetTile.tileX + range, 0, TileManager.Instance.width);
        int minY = (int)Mathf.Clamp(targetTile.tileY - range, 0, TileManager.Instance.height);
        int maxY = (int)Mathf.Clamp(targetTile.tileY + range, 0, TileManager.Instance.height);

        for (int i = minX; i < maxX; i++)
        {
            for (int j = minY; j < maxY; j++)
            {
                //Debug.Log("Pumping " + i.ToString() + ", " + j.ToString() + " " + TileManager.Instance.tiles [i, j], TileManager.Instance.tiles [i, j]);
                TileManager.Instance.tiles [i, j].waterLevel = 0;
                TileManager.Instance.tiles [i, j].UpdateColor();
                TileManager.Instance.tiles [i, j].UpdateSprite();
            }
        }
    }
}
