Only use placement system if is build mode
This commit is contained in:
parent
05555ed075
commit
8dd3dcefab
|
@ -27,7 +27,7 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
RaycastHit hit;
|
||||
|
||||
RaycastHit selectHit;
|
||||
if (Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer) && !GameManager.Instance.IsBuildMode)
|
||||
if (!GameManager.Instance.IsBuildMode && Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer))
|
||||
{
|
||||
var tower = selectHit.collider.gameObject.GetComponentInChildren<Tower>();
|
||||
if (tower != null)
|
||||
|
@ -40,7 +40,7 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
Debug.LogWarning("TowerCam scpritet is not assigned, assign in the inspector");
|
||||
}
|
||||
}
|
||||
else if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||||
else if (GameManager.Instance.IsBuildMode && Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||||
{
|
||||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||
slotInfo.OnClick();
|
||||
|
@ -58,23 +58,24 @@ 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>();
|
||||
|
||||
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||
if (GameManager.Instance.IsBuildMode)
|
||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||||
{
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
}
|
||||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||
|
||||
slotInfo.OnHovered();
|
||||
PrevHoveredSlot = slotInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PrevHoveredSlot != null)
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
PrevHoveredSlot = null;
|
||||
}
|
||||
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||
{
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
}
|
||||
|
||||
slotInfo.OnHovered();
|
||||
PrevHoveredSlot = slotInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PrevHoveredSlot != null)
|
||||
PrevHoveredSlot.OnUnHovered();
|
||||
PrevHoveredSlot = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue