public void _Show(UnitTower tower, bool showControl = false) { isOn = true; thisObj.SetActive(showControl); rscObj.SetActive(!showControl); currentTower = tower; if (showControl) { if (currentTower.IsInConstruction()) { StartCoroutine(WaitForConstruction()); floatingButtons.SetActive(false); butSell.SetActive(false); butUpgradeAlt1.SetActive(false); butUpgrade.SetActive(false); } else { floatingButtons.SetActive(true); butSell.SetActive(true); txtSell.text = "" + currentTower.GetValueSell(); upgradeOption = currentTower.ReadyToBeUpgrade(); if (upgradeOption > 0) { butUpgrade.SetActive(true); txtUpgrade.text = "" + currentTower.GetCost(); if (upgradeOption > 1) { butUpgradeAlt1.SetActive(true); txtUpgradeAlt1.text = "" + currentTower.GetCost(1); } else { butUpgradeAlt1.SetActive(false); } } else { butUpgrade.SetActive(false); butUpgradeAlt1.SetActive(false); } } } else { int cost = currentTower.GetCost(); txtRsc.text = cost.ToString(); } Update(); txtName.text = tower.unitName; txtDesp1.text = tower.GetDespStats(); txtDesp2.text = tower.GetDespGeneral(); thisObj.SetActive(isOn); }
IEnumerator WaitForConstruction() { while (currentTower != null && currentTower.IsInConstruction()) { yield return(null); } if (currentTower != null) { Update(); floatingButtons.SetActive(true); } }
public void _Show(UnitTower tower, bool showControl = false) { isOn = true; thisObj.SetActive(showControl); floatingButtons.SetActive(showControl); controlObj.SetActive(showControl); rscObj.SetActive(!showControl); currentTower = tower; if (showControl) { if (currentTower.IsInConstruction()) { StartCoroutine(WaitForConstruction()); floatingButtons.SetActive(false); } upgradeOption = currentTower.ReadyToBeUpgrade(); if (upgradeOption > 0) { butUpgrade.SetActive(true); } else { butUpgrade.SetActive(false); } // deactivate the priority settings for support and electricity towers if (tower.type != _TowerType.Turret) { priorityObj.SetActive(false); } } else { List <int> cost = currentTower.GetCost(); for (int i = 0; i < rscObjList.Count; i++) { rscObjList[i].label.text = cost[i].ToString(); } } Update(); txtName.text = tower.unitName; txtLvl.text = "lvl " + tower.GetLevel(); txtDesp1.text = tower.GetDespStats(); txtDesp2.text = tower.GetDespGeneral(); thisObj.SetActive(isOn); }
public IEnumerator BuildingBarRoutine(UnitTower tower) { Slider bar = buildingBarList[GetUnusedBuildingBarIndex()]; Transform barT = bar.transform; bar.gameObject.SetActive(true); while (tower != null && tower.IsInConstruction()) { bar.value = tower.GetBuildProgress(); Vector3 screenPos = Camera.main.WorldToScreenPoint(tower.thisT.position + new Vector3(0, 0, 0)); barT.localPosition = (screenPos + new Vector3(0, -20, 0)) * UIMainControl.GetScaleFactor(); yield return(null); } bar.gameObject.SetActive(false); }
IEnumerator _Building(UnitTower tower) { Slider bar = GetUnusedBuildingBar(); Transform barT = bar.transform; while (tower != null && tower.IsInConstruction()) { bar.value = tower.GetBuildProgress(); if (mainCam == null) { mainCam = Camera.main; continue; } Vector3 screenPos = mainCam.WorldToScreenPoint(tower.thisT.position + new Vector3(0, 0, 0)); barT.localPosition = screenPos + new Vector3(0, -20, 0); bar.gameObject.SetActive(true); yield return(null); } bar.gameObject.SetActive(false); }
IEnumerator _Building(UnitTower tower){ Slider bar=GetUnusedBuildingBar(); Transform barT=bar.transform; while(tower!=null && tower.IsInConstruction()){ bar.value=tower.GetBuildProgress(); if(mainCam==null){ mainCam=Camera.main; continue; } Vector3 screenPos = mainCam.WorldToScreenPoint(tower.thisT.position+new Vector3(0, 0, 0)); barT.localPosition=(screenPos+new Vector3(0, -20, 0))/UI.GetScaleFactor(); bar.gameObject.SetActive(true); yield return null; } bar.gameObject.SetActive(false); }
public void _Show(UnitTower tower, bool showControl = false) { isOn = true; thisObj.SetActive(showControl); floatingButtons.SetActive(showControl); controlObj.SetActive(showControl); rscObj.SetActive(!showControl); currentTower = tower; if (showControl) { if (currentTower.IsInConstruction()) { StartCoroutine(WaitForConstruction()); floatingButtons.SetActive(false); } upgradeOption = currentTower.ReadyToBeUpgrade(); if (upgradeOption > 0) { butUpgrade.SetActive(true); if (upgradeOption > 1) { butUpgradeAlt1.SetActive(true); } else { butUpgradeAlt1.SetActive(false); } } else { butUpgrade.SetActive(false); butUpgradeAlt1.SetActive(false); } txtTargetPriority.text = tower.targetPriority.ToString(); if (tower.directionalTargeting) { directionObj.SetActive(true); sliderDirection.value = tower.dirScanAngle; } else { directionObj.SetActive(false); } if (FPSControl.ActiveInScene()) { if (FPSControl.UseTowerWeapon() && currentTower.FPSWeaponID == -1) { fpsButtonObj.SetActive(false); } else { fpsButtonObj.SetActive(true); } } else { fpsButtonObj.SetActive(false); } } else { List <int> cost = currentTower.GetCost(); for (int i = 0; i < rscObjList.Count; i++) { rscObjList[i].label.text = cost[i].ToString(); } } Update(); txtName.text = tower.unitName; txtLvl.text = "lvl" + tower.GetLevel(); txtDesp1.text = tower.GetDespStats(); txtDesp2.text = tower.GetDespGeneral(); thisObj.SetActive(isOn); }
public void _Show(UnitTower tower, bool showControl=false) { isOn=true; thisObj.SetActive(showControl); floatingButtons.SetActive(showControl); controlObj.SetActive(showControl); rscObj.SetActive(!showControl); currentTower=tower; if(showControl){ if(currentTower.IsInConstruction()){ StartCoroutine(WaitForConstruction()); floatingButtons.SetActive(false); } upgradeOption=currentTower.ReadyToBeUpgrade(); if(upgradeOption>0){ butUpgrade.SetActive(true); } else{ butUpgrade.SetActive(false); } // deactivate the priority settings for support and electricity towers if (tower.type != _TowerType.Turret) { priorityObj.SetActive(false); } } else{ List<int> cost=currentTower.GetCost(); for(int i=0; i<rscObjList.Count; i++){ rscObjList[i].label.text=cost[i].ToString(); } } Update(); txtName.text=tower.unitName; txtLvl.text="lvl "+tower.GetLevel(); txtDesp1.text=tower.GetDespStats(); txtDesp2.text=tower.GetDespGeneral(); thisObj.SetActive(isOn); }
public void _Show(UnitTower tower, bool showControl=false){ isOn=true; thisObj.SetActive(showControl); floatingButtons.SetActive(showControl); controlObj.SetActive(showControl); rscObj.SetActive(!showControl); currentTower=tower; if(showControl){ if(currentTower.IsInConstruction()){ StartCoroutine(WaitForConstruction()); floatingButtons.SetActive(false); } upgradeOption=currentTower.ReadyToBeUpgrade(); if(upgradeOption>0){ butUpgrade.SetActive(true); if(upgradeOption>1) butUpgradeAlt1.SetActive(true); else butUpgradeAlt1.SetActive(false); } else{ butUpgrade.SetActive(false); butUpgradeAlt1.SetActive(false); } txtTargetPriority.text=tower.targetPriority.ToString(); if(tower.directionalTargeting){ directionObj.SetActive(true); sliderDirection.value=tower.dirScanAngle; } else directionObj.SetActive(false); if(FPSControl.ActiveInScene()){ if(FPSControl.UseTowerWeapon() && currentTower.FPSWeaponID==-1) fpsButtonObj.SetActive(false); else fpsButtonObj.SetActive(true); } else fpsButtonObj.SetActive(false); } else{ List<int> cost=currentTower.GetCost(); for(int i=0; i<rscObjList.Count; i++){ rscObjList[i].label.text=cost[i].ToString(); } } Update(); txtName.text=tower.unitName; txtLvl.text="lvl"+tower.GetLevel(); txtDesp1.text=tower.GetDespStats(); txtDesp2.text=tower.GetDespGeneral(); thisObj.SetActive(isOn); }