public void UpdateTowerHeading(TowerHolder towerHolder) { if (_towerHeadingViews.TryGetValue(towerHolder, out var view)) { view.UpdateValues(); } }
public void HideTowerHeading(TowerHolder towerHolder) { if (_towerHeadingViews.TryGetValue(towerHolder, out var view)) { view.gameObject.SetActive(false); } }
public IEnumerator CreateTargetTower(TowerPreset preset, TileHolder tile, YieldInstruction wait = null) { var tower = new Tower(preset, tile.Tile); var obj = Instantiate(TowerPrefab); obj.SetVisual(preset.VisualPrefab); obj.Init(tower, tile); _currentTowers.Add(obj); _currentTargetTower = obj; yield return(wait); }
public void AddTower(TowerHolder baseHolder) { var towers = towerControllers.Count; if (towers < towerLimit) { CreateNewTower(baseHolder); } else { MoveExistingTower(baseHolder); } }
public void DestroyTower(TowerHolder towerHolder) { var isTarget = towerHolder == _currentTargetTower; _currentTowers.Remove(towerHolder); Destroy(towerHolder.gameObject); if (isTarget) { _currentTargetTower = null; GameManager.Instance.StateMachine.OnTargetTowerDestroyed(); } }
public void ShowTowerHeading(TowerHolder towerHolder) { if (_towerHeadingViews.TryGetValue(towerHolder, out var view)) { view.gameObject.SetActive(true); } else { view = Instantiate(towerHeadingPrefab, transform); view.Init(towerHolder); _towerHeadingViews[towerHolder] = view; } }
private void MoveExistingTower(TowerHolder newBaseHolder) { //take bottom tower off que var oldTower = towerControllers.Dequeue(); //set the placable flags oldTower.baseHolder.isOccupiedByTower = false; // baseHolder.isOccupiedByTower = false; //set the base towerholder oldTower.baseHolder = newBaseHolder; newBaseHolder.isOccupiedByTower = true; //move oldTower.transform.position = newBaseHolder.transform.position; //set old tower to the top of the queue towerControllers.Enqueue(oldTower); }
private void CreateNewTower(TowerHolder baseHolder) { TowerController newTower; if (IsRandomTower) { int i = Random.Range(0, towers.Length); newTower = Instantiate(towers[i], baseHolder.transform.position, Quaternion.identity); } else { newTower = Instantiate(towers[0], baseHolder.transform.position, Quaternion.identity); } newTower.transform.parent = this.transform; baseHolder.isOccupiedByTower = true; newTower.baseHolder = baseHolder; towerControllers.Enqueue(newTower); }
private void DemoData() { var holder = new MobHolder { MobData = Mobs }; var holder1 = new TowerHolder() { TowerData = Towers }; var holder2 = new TowerRaceHolder() { TowerRace = TowerRaces }; var holder3 = new MobRaceHolder() { MobRace = MobRaces }; File.WriteAllText("db\\1.race_mob.json", JsonConvert.SerializeObject(holder3)); File.WriteAllText("db\\1.mob.json", JsonConvert.SerializeObject(holder)); File.WriteAllText("db\\1.race_tower.json", JsonConvert.SerializeObject(holder2)); File.WriteAllText("db\\1.tower.json", JsonConvert.SerializeObject(holder1)); }
public void Init(TowerHolder towerHolder) { name.text = towerHolder.GridObject.Preset.Name; health.text = $"{towerHolder.GridObject.Health} / {towerHolder.GridObject.MaxHealth}"; _towerHolder = towerHolder; }
public void ReplaceTower(TowerHolder tower, TowerPreset preset) { tower.Replace(preset); }