private ConstructionView.DisplayUIComp[] GetTowerUpgradePath(TowerUnit towerUnit) { if (towerUnit.unitStats == null) { return(null); } TowerStats towerStats = (TowerStats)towerUnit.unitStats; List <ConstructionView.DisplayUIComp> uiComps = new List <ConstructionView.DisplayUIComp>(); if (towerStats.upgrade_path != null && towerStats.upgrade_path.Length > 0) { int upgradePathLength = towerStats.upgrade_path.Length; for (int i = 0; i < upgradePathLength; i++) { uiComps.Add(GetTowerUIComp(towerUnit, towerStats.upgrade_path[i])); } } uiComps.Add(GetTowerInfoComp(towerStats)); uiComps.Add(GetTowerSaleComp(towerStats)); return(uiComps.ToArray()); }
protected void AttackOnTower(TowerUnit towerUnit) { float lastAttackTime = 0; if (AttackTimeDict.ContainsKey(_uniqueID)) { lastAttackTime = AttackTimeDict[_uniqueID]; } else { AttackTimeDict.Add(_uniqueID, lastAttackTime); } //Go for it if (LevelDesignManager.Time > lastAttackTime) { float meleeAttackTime = 5f; float reachTime = GeneralUtility.GetReachTimeGivenInfo(towerUnit.transform.position, unit.transform.position, meleeAttackTime, LevelDesignManager.DeltaTime); GameDamageManager.DMGRegistry registry = GeneralUtility.GetDMGRegisterCard(towerUnit, this.unit, monsterStat, LevelDesignManager.Time, reachTime); _gameDamageManager.AddRequest(registry); AttackTimeDict[_uniqueID] = LevelDesignManager.Time + monsterStat.spd; } }
private ConstructionView.DisplayUIComp GetTowerUIComp(TowerUnit towerUnit, TowerStats towerStats) { return(FormTowerUIComp("$" + towerStats.cost, towerStats.id, towerStats.sprite, () => { SelectTowerToUpgrade(towerUnit, towerStats); })); }
IEnumerator ApocalypseAttack(Attack attack) { _isApocalypseActive = true; Base target = ((ProjectileFireball)attack).Target; TowerUnit tower = (TowerUnit)attack.Attacker.Unit; // find all enemies within range of the target enemy List <Collider> targetsFound = Physics.OverlapSphere(target.transform.position, tower.TowerAttributes.Range, tower.SearchLayer).ToList(); // remove the primary target from the list of enemies found so it isn't targeted again targetsFound.Remove(target.Unit.Components.SearchCollider); // generate a fireball for each target found, up to the rank's maximum amount var fireballsGenerated = 0; foreach (var bonusTarget in targetsFound) { // stagger the creation of fireballs so the projectiles don't overlap yield return(new WaitForSeconds(0.2f)); // ensure the target still exists (wasn't removed by hitting the nexus or being killed) if (bonusTarget == null) { continue; } // create the fireball attack var fireball = Instantiate(tower.Components.AttackPrefab, tower.Components.AttackSpawnLocation.position, Quaternion.identity, tower.transform).GetComponent <ProjectileFireball>(); fireball.InitializeAttack(attack.Attacker, tower.TowerAttributes.Damage, UI.CombatTextType.SpecialDamage); fireball.InitializeProjectile(bonusTarget.GetComponent <UnitCollider>().Base, tower.TowerAttributes.ProjectileSpeed); fireball.InitializeFireball(tower.TowerAttributes["explosionSize"].AttributeValue / 10); // stop generating fireballs when it reaches its rank's maximum fireballsGenerated++; if (fireballsGenerated == (UpgradeData.GetValue(1) - 1)) { break; } } _isApocalypseActive = false; }
private async void SelectTowerToBuild(string tower_id) { if (IsTileNodeValid(currentSelectedNode)) { TowerStats towerStats = _statHolder.FindObject <TowerStats>(tower_id); //No money if (_levelDesignManager.selfPlayer.capital < towerStats.cost) { return; } var tower = PoolManager.instance.ReuseObject(VariableFlag.Pooling.TowerID); if (tower != null) { tower.transform.position = currentSelectedNode.WorldSpace; BlockComponent mapBlock = _mapBlockManager.GetMapComponentByPos(currentSelectedNode.WorldSpace); STPTower stpTower = _stpTheme.FindObject <STPTower>(VariableFlag.Pooling.TowerID); TowerUnit towerUnit = tower.GetComponent <TowerUnit>(); if (stpTower != null && towerUnit != null && mapBlock != null && towerStats != null) { tower.transform.SetParent(mapBlock.unitHolder); towerUnit.SetUp(towerStats, stpTower, _mapGrid, _levelDesignManager.selfPlayer, (UnitInterface projectile, GameDamageManager.DMGRegistry dmgRistry) => { _gameUnitManager.AddUnit(projectile); _gameUnitManager.gameDamageManager.AddRequest(dmgRistry); }); _gameUnitManager.AddUnit(towerUnit); isTaskDone = true; } } } }
public void OnAttack(GameDamageManager.DMGRegistry dmgCard) { try { _hp -= dmgCard.unitStats.atk; if (_hp <= 0) { if (dmgCard.fromUnit != null) { TowerUnit towerUnit = (TowerUnit)dmgCard.fromUnit; if (towerUnit != null && towerUnit.buildPlayer != null) { towerUnit.buildPlayer.EarnPrize(_monsterStats.prize); } } Destroy(); } } catch { Debug.Log("OnAttack error occur"); } }
public void MinionDestroyed(TowerUnit minion) { if(livingMinions.Contains(minion)) livingMinions.Remove (minion); }
private void SelectTowerToUpgrade(TowerUnit towerUnit, TowerStats upgradeStats) { towerUnit.SetTowerStats(upgradeStats); }