3DTD/Assets/Scripts/PlacementSystem/SlotManager.cs

47 lines
1.1 KiB
C#
Raw Normal View History

2024-04-20 01:51:12 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SlotManager : MonoBehaviour
{
public GridManager spawnerRef;
public int x;
public int y;
2024-04-21 11:43:45 +02:00
public HealthComponent TowerHealth;
2024-04-21 11:46:44 +02:00
public bool IsOccupied => TowerHealth != null && TowerHealth.TryGetComponent(out HealthComponent _);
2024-04-21 11:43:45 +02:00
2024-04-20 16:27:58 +02:00
public Transform TowerSpawnPoint;
2024-04-20 01:51:12 +02:00
/// <summary>
/// (Sender, spawnerRef, X, Y)
/// </summary>
2024-04-20 15:38:21 +02:00
public event Action<SlotManager, GridManager, int, int> OnSlotClicked;
2024-04-20 18:04:55 +02:00
public event Action<SlotManager, GridManager, int, int> OnSlotHovered;
public event Action<SlotManager, GridManager, int, int> OnSlotUnHovered;
2024-04-20 15:38:21 +02:00
public void OnClick()
{
2024-04-21 11:43:45 +02:00
if (IsOccupied) return;
2024-04-20 15:38:21 +02:00
OnSlotClicked?.Invoke(this, spawnerRef, x, y);
}
2024-04-20 18:04:55 +02:00
public void OnHovered()
{
2024-04-21 11:43:45 +02:00
if (IsOccupied) return;
2024-04-20 18:04:55 +02:00
OnSlotHovered?.Invoke(this, spawnerRef, x, y);
}
public void OnUnHovered()
{
2024-04-21 11:43:45 +02:00
if (IsOccupied) return;
2024-04-20 18:04:55 +02:00
OnSlotUnHovered?.Invoke(this, spawnerRef, x, y);
}
2024-04-20 01:51:12 +02:00
}