Пример #1
0
        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);
        }
Пример #2
0
 IEnumerator WaitForConstruction()
 {
     while (currentTower != null && currentTower.IsInConstruction())
     {
         yield return(null);
     }
     if (currentTower != null)
     {
         Update();
         floatingButtons.SetActive(true);
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
		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);
		}
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
		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);
		}