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)
|
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||||
{
|
{
|
||||||
slotInfo.OnHovered();
|
|
||||||
PrevHoveredSlot.OnUnHovered();
|
PrevHoveredSlot.OnUnHovered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slotInfo.OnHovered();
|
||||||
PrevHoveredSlot = slotInfo;
|
PrevHoveredSlot = slotInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class GridManager : MonoBehaviour
|
||||||
infoHolder.y = y;
|
infoHolder.y = y;
|
||||||
|
|
||||||
infoHolder.OnSlotClicked += sender.OnSlotClicked;
|
infoHolder.OnSlotClicked += sender.OnSlotClicked;
|
||||||
|
infoHolder.OnSlotHovered += sender.OnSlotHovered;
|
||||||
|
infoHolder.OnSlotUnHovered += sender.OnSlotUnHovered;
|
||||||
|
|
||||||
SpawnedSlots.Add(spawned);
|
SpawnedSlots.Add(spawned);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Unity.Mathematics;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -13,8 +14,11 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
public static event Action<TowerPlacementManager> OnSpawnGridRequested;
|
||||||
public static TowerPlacementManager Singleton;
|
public static TowerPlacementManager Singleton;
|
||||||
|
|
||||||
// Section: Selection
|
// Section: Mouse
|
||||||
private SlotManager CurrentSelected;
|
private SlotManager CurrentSelectedSlot;
|
||||||
|
private SlotManager CurrentHovered;
|
||||||
|
|
||||||
|
private GameObject SilhouettedObject;
|
||||||
|
|
||||||
// Section: Debug
|
// Section: Debug
|
||||||
public GameObject DebugTowerPrefab;
|
public GameObject DebugTowerPrefab;
|
||||||
|
@ -28,8 +32,6 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
Singleton = this;
|
Singleton = this;
|
||||||
|
|
||||||
OnSpawnGridRequested?.Invoke(this);
|
OnSpawnGridRequested?.Invoke(this);
|
||||||
|
|
||||||
ToSilhouette(DebugTowerPrefab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||||
|
@ -44,9 +46,9 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
public void OnSelectSlot(SlotManager slot)
|
public void OnSelectSlot(SlotManager slot)
|
||||||
{
|
{
|
||||||
// Detects if the selected slot is new
|
// Detects if the selected slot is new
|
||||||
if (CurrentSelected != null && CurrentSelected != slot)
|
if (CurrentSelectedSlot != null && CurrentSelectedSlot != slot)
|
||||||
OnDeselectSlot(CurrentSelected, slot);
|
OnDeselectSlot(CurrentSelectedSlot, slot);
|
||||||
CurrentSelected = slot;
|
CurrentSelectedSlot = slot;
|
||||||
|
|
||||||
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
slot.gameObject.GetComponentInChildren<Renderer>().material.color = Color.blue;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +61,29 @@ public class TowerPlacementManager : MonoBehaviour
|
||||||
|
|
||||||
public void SpawnTowerAtSelected(GameObject towerPrefab)
|
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