public void TakeTurn(UnitStackBase actingUnit, BattleManager battleManager) { this.actingUnit = actingUnit; this.battleManager = battleManager; List <UnitStackBase> targetableUnits = new List <UnitStackBase>(); foreach (UnitStackBase unit in battleManager.playerUnitsInBattle) { if (unit.IsTargetableByAttack()) { targetableUnits.Add(unit); } } if (targetableUnits.Count == 0) { battleManager.SkipTurn(); return; } UnitStackBase mostDangerousUnit = targetableUnits[0]; foreach (UnitStackBase unit in targetableUnits) { if (unit.GetAttackDamage() > mostDangerousUnit.GetAttackDamage()) { mostDangerousUnit = unit; } } AttackUnit(mostDangerousUnit); }
private void TryToUseDefend() { List <UnitStackBase> abilityTargets = new List <UnitStackBase>(); foreach (UnitStackBase unit in battleManager.enemyUnitsInBattle) { if (defendAbility.UnitIsViableTarget(unit)) { abilityTargets.Add(unit); } } if (abilityTargets.Count == 0) { AttackRandom(); return; } UnitStackBase mostDangerous = abilityTargets[0]; foreach (UnitStackBase unit in abilityTargets) { if (unit.GetAttackDamage() > mostDangerous.GetAttackDamage()) { mostDangerous = unit; } } defendAbility.GetActiatedByAi(mostDangerous, battleManager); battleManager.EndTurn(); }
private void AttackUnit(UnitStackBase unit) { if (!unit.IsTargetableByAttack()) { return; } int damage = activeUnit.GetAttackDamage(); unit.GetDamaged(damage, activeUnit, DamageType.Physical); playerTurn = false; battleManager.EndTurn(); }
private void AttackRandom() { List <UnitStackBase> targetableUnits = new List <UnitStackBase>(); foreach (var unit in battleManager.playerUnitsInBattle) { if (unit.IsTargetableByAttack()) { targetableUnits.Add(unit); } } if (targetableUnits.Count == 0) { battleManager.SkipTurn(); } else { int chance = UnityEngine.Random.Range(0, targetableUnits.Count); targetableUnits[chance].GetDamaged(actingUnit.GetAttackDamage(), actingUnit, DamageType.Physical); battleManager.EndTurn(); } }
private void AttackUnit(UnitStackBase targetUnit) { targetUnit.GetDamaged(actingUnit.GetAttackDamage(), actingUnit, DamageType.Physical); battleManager.EndTurn(); }