grid spawner now debug respawnable
This commit is contained in:
parent
1315f5c035
commit
28af0a8085
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,7 @@ public class GridManager : MonoBehaviour
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
TowerPlacementManager.OnSpawnGridRequested += SpawnSlots;
|
TowerPlacementManager.OnSpawnGridRequested += SpawnSlots;
|
||||||
|
TowerPlacementManager.OnGridDeleteRequested += DeleteGrid;
|
||||||
|
|
||||||
GridStates = new string[GridSize.x, GridSize.y];
|
GridStates = new string[GridSize.x, GridSize.y];
|
||||||
}
|
}
|
||||||
|
@ -28,6 +29,7 @@ public class GridManager : MonoBehaviour
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
TowerPlacementManager.OnSpawnGridRequested -= SpawnSlots;
|
TowerPlacementManager.OnSpawnGridRequested -= SpawnSlots;
|
||||||
|
TowerPlacementManager.OnGridDeleteRequested -= DeleteGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SpawnSlots(TowerPlacementManager sender)
|
public void SpawnSlots(TowerPlacementManager sender)
|
||||||
|
@ -55,6 +57,15 @@ public class GridManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeleteGrid(TowerPlacementManager sender)
|
||||||
|
{
|
||||||
|
SlotManager[] slots = GetComponentsInChildren<SlotManager>();
|
||||||
|
for (int i = 0; i < slots.Length; i++)
|
||||||
|
{
|
||||||
|
Destroy(slots[i].gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GridType
|
public enum GridType
|
||||||
|
|
|
@ -12,8 +12,12 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
/// Sender
|
/// Sender
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
||||||
|
public static event Action<TowerPlacementManager> OnGridDeleteRequested;
|
||||||
public static TowerPlacementManager Instance;
|
public static TowerPlacementManager Instance;
|
||||||
|
|
||||||
|
[Header("Debug")]
|
||||||
|
[SerializeField] private bool RebuildGrid = false;
|
||||||
|
|
||||||
// Section: Mouse
|
// Section: Mouse
|
||||||
private SlotManager CurrentSelectedSlot;
|
private SlotManager CurrentSelectedSlot;
|
||||||
private SlotManager CurrentHovered; // Not implemented
|
private SlotManager CurrentHovered; // Not implemented
|
||||||
|
@ -48,6 +52,13 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
CurrentRotation++;
|
CurrentRotation++;
|
||||||
CurrentRotation = CurrentRotation % 4;
|
CurrentRotation = CurrentRotation % 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (RebuildGrid)
|
||||||
|
{
|
||||||
|
RebuildGrid = false;
|
||||||
|
OnGridDeleteRequested?.Invoke(this);
|
||||||
|
OnSpawnGridRequested?.Invoke(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||||
|
|
Loading…
Reference in New Issue