This commit is contained in:
BOT Alex 2024-04-21 00:39:39 +02:00
commit 8b015c4d33
1 changed files with 8 additions and 6 deletions

View File

@ -25,18 +25,20 @@ public class CameraSlotClickDetect : MonoBehaviour
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
slotInfo.OnClick();
GameManager.Instance.SelectedTower = null;
}
RaycastHit selectHit;
if (Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer) && !GameManager.Instance.IsBuildMode)
{
var tower = selectHit.collider.gameObject.GetComponentInChildren<Tower>();
if (tower != null)
{
GameManager.Instance.SelectedTower = tower;
}
}
else if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
slotInfo.OnClick();
GameManager.Instance.SelectedTower = null;
}
}