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 hit;
|
||||||
|
|
||||||
RaycastHit selectHit;
|
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>();
|
var tower = selectHit.collider.gameObject.GetComponentInChildren<Tower>();
|
||||||
if (tower != null)
|
if (tower != null)
|
||||||
|
@ -40,7 +40,7 @@ public class CameraSlotClickDetect : MonoBehaviour
|
||||||
Debug.LogWarning("TowerCam scpritet is not assigned, assign in the inspector");
|
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>();
|
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||||
slotInfo.OnClick();
|
slotInfo.OnClick();
|
||||||
|
@ -58,23 +58,24 @@ public class CameraSlotClickDetect : MonoBehaviour
|
||||||
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||||
RaycastHit hit;
|
RaycastHit hit;
|
||||||
|
|
||||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
if (GameManager.Instance.IsBuildMode)
|
||||||
{
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
|
||||||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
|
||||||
|
|
||||||
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
|
||||||
{
|
{
|
||||||
PrevHoveredSlot.OnUnHovered();
|
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||||
}
|
|
||||||
|
|
||||||
slotInfo.OnHovered();
|
if (PrevHoveredSlot != null && PrevHoveredSlot != slotInfo)
|
||||||
PrevHoveredSlot = slotInfo;
|
{
|
||||||
}
|
PrevHoveredSlot.OnUnHovered();
|
||||||
else
|
}
|
||||||
{
|
|
||||||
if (PrevHoveredSlot != null)
|
slotInfo.OnHovered();
|
||||||
PrevHoveredSlot.OnUnHovered();
|
PrevHoveredSlot = slotInfo;
|
||||||
PrevHoveredSlot = null;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
if (PrevHoveredSlot != null)
|
||||||
|
PrevHoveredSlot.OnUnHovered();
|
||||||
|
PrevHoveredSlot = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue