Silhouette semi working
This commit is contained in:
parent
6806df3fed
commit
7c78c430bb
|
@ -43,10 +43,10 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
|
||||
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||
{
|
||||
slotInfo.OnHovered();
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
}
|
||||
|
||||
slotInfo.OnHovered();
|
||||
PrevHoveredSlot = slotInfo;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -48,6 +48,8 @@ public class GridManager : MonoBehaviour
|
|||
infoHolder.y = y;
|
||||
|
||||
infoHolder.OnSlotClicked += sender.OnSlotClicked;
|
||||
infoHolder.OnSlotHovered += sender.OnSlotHovered;
|
||||
infoHolder.OnSlotUnHovered += sender.OnSlotUnHovered;
|
||||
|
||||
SpawnedSlots.Add(spawned);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -13,8 +14,11 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
||||
public static TowerPlacementManager Singleton;
|
||||
|
||||
// Section: Selection
|
||||
private SlotManager CurrentSelected;
|
||||
// Section: Mouse
|
||||
private SlotManager CurrentSelectedSlot;
|
||||
private SlotManager CurrentHovered;
|
||||
|
||||
private GameObject SilhouettedObject;
|
||||
|
||||
// Section: Debug
|
||||
public GameObject DebugTowerPrefab;
|
||||
|
@ -28,8 +32,6 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
Singleton = this;
|
||||
|
||||
OnSpawnGridRequested?.Invoke(this);
|
||||
|
||||
ToSilhouette(DebugTowerPrefab);
|
||||
}
|
||||
|
||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||
|
@ -44,9 +46,9 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
public void OnSelectSlot(SlotManager slot)
|
||||
{
|
||||
// Detects if the selected slot is new
|
||||
if (CurrentSelected != null && CurrentSelected != slot)
|
||||
OnDeselectSlot(CurrentSelected, slot);
|
||||
CurrentSelected = slot;
|
||||
if (CurrentSelectedSlot != null && CurrentSelectedSlot != slot)
|
||||
OnDeselectSlot(CurrentSelectedSlot, slot);
|
||||
CurrentSelectedSlot = slot;
|
||||
|
||||
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
||||
}
|
||||
|
@ -59,12 +61,29 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
|
||||
public void SpawnTowerAtSelected(GameObject towerPrefab)
|
||||
{
|
||||
Instantiate(towerPrefab, CurrentSelected.transform);
|
||||
Instantiate(towerPrefab, CurrentSelectedSlot.transform);
|
||||
}
|
||||
|
||||
public void OnSlotHovered()
|
||||
public void OnSlotHovered(SlotManager slot, GridManager grid, int x, int y)
|
||||
{
|
||||
print("Hovered");
|
||||
|
||||
if (SilhouettedObject == null)
|
||||
SilhouettedObject = ToSilhouette(DebugTowerPrefab);
|
||||
|
||||
//SilhouettedObject.SetActive(true);
|
||||
SilhouettedObject.transform.parent = slot.TowerSpawnPoint.transform;
|
||||
SilhouettedObject.transform.localPosition = Vector3.zero;
|
||||
SilhouettedObject.transform.localRotation = quaternion.identity;
|
||||
}
|
||||
|
||||
public void OnSlotUnHovered(SlotManager slot, GridManager grid, int x, int y)
|
||||
{
|
||||
print("UnHovered");
|
||||
|
||||
//SilhouettedObject.SetActive(false);
|
||||
SilhouettedObject.transform.parent = null;
|
||||
SilhouettedObject.transform.position = Vector3.zero;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue