void OnNewWave(int waveID) { int totalWaveCount = SpawnManager.GetTotalWaveCount(); string text = totalWaveCount > 0 ? "/" + totalWaveCount : ""; txtWave.text = waveID + text; if (GameControl.IsGameStarted()) { buttonSpawn.rootObj.SetActive(false); } }
void FixedUpdate() { if ((onlyChargeOnSpawn && GameControl.IsGameStarted()) || !onlyChargeOnSpawn) { if (energy < fullEnergy) { float valueGained = Time.fixedDeltaTime * GetEnergyRate(); energy += valueGained; energy = Mathf.Min(energy, GetEnergyFull()); } } }
//called by any external component to build tower, uses buildInfo public static string BuildTower(UnitTower tower) { if (buildInfo == null) { return("Select a Build Point First"); } //dont allow building of resource tower before game started if (tower.type == _TowerType.Resource && !GameControl.IsGameStarted()) { return("Cant Build Tower before spawn start"); } UnitTower sampleTower = GetSampleTower(tower); //check if there are sufficient resource List <int> cost = sampleTower.GetCost(); int suffCost = ResourceManager.HasSufficientResource(cost); if (suffCost == -1) { ResourceManager.SpendResource(cost); GameObject towerObj = (GameObject)ObjectPoolManager.Spawn(tower.gameObject, buildInfo.position, buildInfo.platform.thisT.rotation); UnitTower towerInstance = towerObj.GetComponent <UnitTower>(); towerInstance.InitTower(instance.towerCount += 1); towerInstance.Build(); //register the tower to the platform if (buildInfo.platform != null) { buildInfo.platform.BuildTower(buildInfo.position, towerInstance); } //clear the build info and indicator for build manager ClearBuildPoint(); return(""); } return("Insufficient Resource"); }
public string _BuildTowerDragNDrop(UnitTower tower) { if (tower.type == _TowerType.Resource && !GameControl.IsGameStarted()) { return("Cant Build Tower before spawn start"); } UnitTower sampleTower = GetSampleTower(tower); List <int> cost = sampleTower.GetCost(); int suffCost = ResourceManager.HasSufficientResource(cost); if (suffCost == -1) { sampleTower.thisObj.SetActive(true); GameControl.SelectTower(sampleTower); UnitTower towerInstance = sampleTower; towerInstance.StartCoroutine(towerInstance.DragNDropRoutine()); return(""); } return("Insufficient Resource " + suffCost); }