47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SlotManager : MonoBehaviour
|
|
{
|
|
public GridManager spawnerRef;
|
|
public int x;
|
|
public int y;
|
|
|
|
public HealthComponent TowerHealth;
|
|
|
|
public bool IsOccupied => TowerHealth != null && TowerHealth.TryGetComponent(out HealthComponent _);
|
|
|
|
public Transform TowerSpawnPoint;
|
|
|
|
/// <summary>
|
|
/// (Sender, spawnerRef, X, Y)
|
|
/// </summary>
|
|
public event Action<SlotManager, GridManager, int, int> OnSlotClicked;
|
|
|
|
public event Action<SlotManager, GridManager, int, int> OnSlotHovered;
|
|
public event Action<SlotManager, GridManager, int, int> OnSlotUnHovered;
|
|
|
|
public void OnClick()
|
|
{
|
|
if (IsOccupied) return;
|
|
|
|
OnSlotClicked?.Invoke(this, spawnerRef, x, y);
|
|
}
|
|
|
|
public void OnHovered()
|
|
{
|
|
if (IsOccupied) return;
|
|
|
|
OnSlotHovered?.Invoke(this, spawnerRef, x, y);
|
|
}
|
|
|
|
public void OnUnHovered()
|
|
{
|
|
if (IsOccupied) return;
|
|
|
|
OnSlotUnHovered?.Invoke(this, spawnerRef, x, y);
|
|
}
|
|
}
|