public void Test() { if (sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)) { if (RscManager.HasSufficientRsc(dndTower.GetCost())) { RscManager.SpendRsc(dndTower.GetCost()); Debug.Log("buy"); SelectControl.ClearUnit(); if (!UseFreeFormMode()) { AddTower(dndTower, sInfo.platform, sInfo.nodeID); } else { AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0); } dndTower.Build(); dndTower = null; dndCooldown = Time.time; } else { GameControl.InvalidAction("Insufficient Resources"); _ExitDragNDropPhase(); } } else { GameControl.InvalidAction("Invalid Build Point"); _ExitDragNDropPhase(); } }
private void OnCursorDown() { SelectInfo sInfo = TowerManager.GetSelectInfo(Input.mousePosition); bool select = false; bool build = false; if (sInfo.HasValidPoint()) { if (sInfo.GetTower() != null) { select = true; SelectControl.SelectUnit(sInfo.GetTower()); UITowerSelect.Show(sInfo.GetTower()); } else if (buildMode == _BuildMode.PointNBuild && sInfo.AvailableForBuild()) { build = true; UIBuildButton.Show(sInfo); SelectControl.SelectNode(sInfo.platform, sInfo.nodeID); } } if (buildMode == _BuildMode.PointNBuild && !build) { SelectControl.ClearNode(); UIBuildButton.Hide(); } if (!select) { SelectControl.ClearUnit(); UITowerSelect.Hide(); } }
public void OnSellButton(GameObject butObj, int pointerID = -1) { UITooltip.Hide(); sTower.Sell(); SelectControl.ClearUnit(); Hide(); }
public static void HideSampleTower() { SelectControl.ClearUnit(); if (instance.activeSampleTowerIdx >= 0) { instance.sampleList[instance.activeSampleTowerIdx].GetObj().SetActive(false); } }
public void _ExitDragNDropPhase() { if (dndTower == null) { return; } Destroy(dndTower.gameObject); SelectControl.ClearUnit(); dndTower = null; }
public void OnBuildButton(GameObject butObj, int pointerID = -1) { if (!ValidForInteraction()) { return; } int idx = UI.GetItemIndex(butObj, buildButtons); if (UIControl.UsePointNBuildMode() && UIControl.InTouchMode()) { if (touchModeButtonIdx != idx) { if (touchModeButtonIdx >= 0) { ClearTouchModeSelect(); } touchModeButtonIdx = idx; buildButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true); OnHoverBuildButton(butObj); return; } ClearTouchModeSelect(); } if (UIControl.UsePointNBuildMode()) { if (!CheckCost(sInfo.buildableList[idx].GetCost())) { return; } TowerManager.BuildTower(sInfo.buildableList[idx], sInfo.platform, sInfo.nodeID); SelectControl.ClearNode(); OnExitBuildButton(null); Hide(); TowerManager.HideSampleTower(); } if (UIControl.UseDragNDropMode()) { if (!CheckCost(buildableList[idx].GetCost())) { return; } SelectControl.ClearUnit(); UITowerSelect.Hide(); TowerManager.CreateDragNDropTower(buildableList[idx]); } }
public void OnUpgradeButton(GameObject butObj, int pointerID = -1) { int idx = UI.GetItemIndex(butObj, upgradeButtons); List <float> upgradeCost = sTower.GetUpgradeCost(idx); if (CheckCost(upgradeCost)) { //RscManager.SpendRsc(upgradeCost); sTower.Upgrade(idx); SelectControl.ClearUnit(); Hide(); } UITooltip.Hide(); }
public void Test() { if (m_TowerManager.dndTower != null) { if (RscManager.HasSufficientRsc(m_TowerManager.dndTower.GetCost())) { RscManager.SpendRsc(m_TowerManager.dndTower.GetCost()); Debug.Log("buy"); m_TSC = m_TowerManager.dndTower.gameObject.GetComponent <TowerSoliderController>(); SelectControl.ClearUnit(); TowerManager.AddTower(m_TowerManager.dndTower, TowerManager.CreatePlatformForTower(m_TowerManager.dndTower, TowerManager.GetGridSize()), 0); m_TowerManager.dndTower.Build(); m_TowerManager.dndTower = null; //TowerManager.dndCooldown=Time.time; if (m_TSC != null) { m_TSC.ShowSolider(); } } else { GameControl.InvalidAction("Insufficient Resources"); m_TowerManager._ExitDragNDropPhase(); } } }
// Update is called once per frame void Update() { //~ if(Input.GetMouseButtonDown(0)){ //~ ToggleNode(Input.mousePosition, true); //~ } //~ if(Input.GetMouseButtonDown(1)){ //~ ToggleNode(Input.mousePosition, false); //~ } /* * //PointNBuild * if(Input.GetMouseButtonUp(0)){ * sInfo=OnCursorDown(Input.mousePosition); * * bool select=false; * bool build=false; * * if(sInfo.HasValidPoint()){ * if(sInfo.GetTower()!=null){ * select=true; * //selectTower * * } * else if(sInfo.AvailableForBuild()){ * build=true; * //show build menu * } * } * * if(!select){} //clear selected tower * if(!build){} //hide build menu * } */ /*Daniel Add * if(dndTower!=null && Time.unscaledTime-dndCooldown>0.15f){ * if(lastDnDCursorPos!=Input.mousePosition){ * lastDnDCursorPos=Input.mousePosition; * * sInfo=GetSelectInfo(Input.mousePosition, dndInstanceID, dndTower.radius); * if (CheckMouseClick) { * if (sInfo.HasWorldPoint ()) * dndTower.transform.position = sInfo.GetPos (); * else * dndTower.transform.position = Camera.main.ScreenToWorldPoint (Input.mousePosition + new Vector3 (0, 0, 15)); * } * CheckMouseClick = false; * } * * * bool cursorUp=Input.GetMouseButtonUp(0); * if(cursorUp){ * if(sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)){ * if(RscManager.HasSufficientRsc(dndTower.GetCost())){ * RscManager.SpendRsc(dndTower.GetCost()); * Debug.Log ("buy"); * SelectControl.ClearUnit(); * if(!UseFreeFormMode()) AddTower(dndTower, sInfo.platform, sInfo.nodeID); * else AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0); * dndTower.Build(); dndTower=null; dndCooldown=Time.time; * CheckMouseClick = true; * } * else{ * GameControl.InvalidAction("Insufficient Resources"); * _ExitDragNDropPhase(); * } * } * else{ * GameControl.InvalidAction("Invalid Build Point"); * _ExitDragNDropPhase(); * } * } * //End*/ //這是原本的 //* if (dndTower != null && Time.unscaledTime - dndCooldown > 0.15f) { if (lastDnDCursorPos != Input.mousePosition) { lastDnDCursorPos = Input.mousePosition; sInfo = GetSelectInfo(Input.mousePosition, dndInstanceID, dndTower.radius); if (sInfo.HasWorldPoint()) { dndTower.transform.position = sInfo.GetPos(); } else { dndTower.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 15)); } } bool cursorUp = Input.GetMouseButtonUp(2); if (cursorUp) { if (sInfo.HasValidPoint() && sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)) { if (RscManager.HasSufficientRsc(dndTower.GetCost())) { RscManager.SpendRsc(dndTower.GetCost()); Debug.Log("buy"); SelectControl.ClearUnit(); if (!UseFreeFormMode()) { AddTower(dndTower, sInfo.platform, sInfo.nodeID); } else { AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0); } testShow(); dndTower.Build(); dndTower = null; dndCooldown = Time.time; } else { GameControl.InvalidAction("Insufficient Resources"); _ExitDragNDropPhase(); } } else { GameControl.InvalidAction("Invalid Build Point"); _ExitDragNDropPhase(); } } //*/ /* * if(sInfo.HasValidPoint()){ * dndTower.transform.position=sInfo.GetPos(); * * if(sInfo.AvailableForBuild() && sInfo.CanBuildTower(dndTower.prefabID)){ * //~ if(cursorDown){ * //~ if(RscManager.HasSufficientRsc(dndTower.GetCost())){ * //~ RscManager.SpendRsc(dndTower.GetCost()); * //~ SelectControl.ClearUnit(); * //~ if(!UseFreeFormMode()) AddTower(dndTower, sInfo.platform, sInfo.nodeID); * //~ else AddTower(dndTower, CreatePlatformForTower(dndTower, GetGridSize()), 0); * //~ dndTower.Build(); dndTower=null; dndCooldown=Time.time; * //~ } * //~ else{ * //~ GameControl.InvalidAction("Insufficient Resources"); * //~ _ExitDragNDropPhase(); * //~ } * //~ } * } * } * else{ * //Debug.Log("this will need some work "); * dndTower.transform.position=Camera.main.ScreenToWorldPoint(Input.mousePosition+new Vector3(0, 0, 15)); * //~ if(cursorDown){ * //~ GameControl.InvalidAction("Invalid Build Point"); * //~ _ExitDragNDropPhase(); * //~ } * } */ if (Input.GetMouseButtonDown(1)) { SelectControl.ClearUnit(); _ExitDragNDropPhase(); } } }