Compare commits
No commits in common. "6806df3fedf690049311f69292e437a924ca3901" and "f5fade285f39c61d3635597fb158c1b6822008a3" have entirely different histories.
6806df3fed
...
f5fade285f
|
@ -1,6 +1,5 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraSlotClickDetect : MonoBehaviour
|
||||
|
@ -8,19 +7,15 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
public Camera mainCamera;
|
||||
public LayerMask layerMask;
|
||||
|
||||
private SlotManager PrevHoveredSlot;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
ShootClickRay();
|
||||
ShootRay();
|
||||
}
|
||||
}
|
||||
|
||||
ShootHoverRay();
|
||||
}
|
||||
|
||||
void ShootClickRay()
|
||||
void ShootRay()
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
|
@ -29,29 +24,8 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
{
|
||||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||
slotInfo.OnClick();
|
||||
}
|
||||
}
|
||||
|
||||
void ShootHoverRay()
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||||
{
|
||||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||
|
||||
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||
{
|
||||
slotInfo.OnHovered();
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
}
|
||||
|
||||
PrevHoveredSlot = slotInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevHoveredSlot = null;
|
||||
Debug.Log($"Hit PlacementSlot! At ({slotInfo.x}, {slotInfo.y})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
|
||||
}
|
||||
|
||||
|
||||
[Space(10)]
|
||||
public Material SilhouetteMaterial;
|
||||
public GameObject ToSilhouette(GameObject obj)
|
||||
|
|
|
@ -16,21 +16,8 @@ public class SlotManager : MonoBehaviour
|
|||
/// </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()
|
||||
{
|
||||
OnSlotClicked?.Invoke(this, spawnerRef, x, y);
|
||||
}
|
||||
|
||||
public void OnHovered()
|
||||
{
|
||||
OnSlotHovered?.Invoke(this, spawnerRef, x, y);
|
||||
}
|
||||
|
||||
public void OnUnHovered()
|
||||
{
|
||||
OnSlotUnHovered?.Invoke(this, spawnerRef, x, y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue