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

[CreateAssetMenu(menuName = "Actions/Alarm")]
public class ActionAlarm : ActionAsset {

    public AlarmTile alarmTilePrefab;
    public LayerMask raycastMask;

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

        AlarmTile alarm = TileManager.Instance.Build(targetTile, alarmTilePrefab) as AlarmTile;

        RaycastHit2D[] hits = Physics2D.CircleCastAll(targetTile.transform.position, 0.3f, Vector2.zero, 0f, raycastMask);
        for (int i = 0; i < hits.Length; i++)
        {
            HouseTile house = hits [i].collider.GetComponent<HouseTile>();
            if (house != null)
            {
                house.hasAlarm = true;
            }
        }
    }
}
