void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) { return; } if (!buildManager.CanBuild) { return; } if (turret != null) { buildManager.SelectNode(this); return; } buildManager.nodeUI.Hide(); BuildTurret(buildManager.GetTurretToBuild()); }
//On mouse click, checks to see if mouse is over valid gameObject. Then checks to see if a turret already exists on that node. If it does, selects the node and then returns. //If no turret exists on the node, build a new one on that node. private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) { return; } if (currentTurret != null) { buildManager.SelectNode(this); return; } if (!buildManager.canBuild) { return; } BuildTurret(buildManager.GetTurretToBuild()); }