private void TryToBuffPyro() { List <UnitStackBase> abilitytargets = new List <UnitStackBase>(); foreach (UnitStackBase unit in battleManager.enemyUnitsInBattle) { if (ability.UnitIsViableTarget(unit)) { abilitytargets.Add(unit); } } if (abilitytargets.Count == 0) { AttackRandom(); return; } UnitStackBase finalAbilityTarget = abilitytargets[0]; foreach (UnitStackBase unit in abilitytargets) { if (unit.UnitType == UnitType.Pyromaniac) { finalAbilityTarget = unit; } } ability.GetActiatedByAi(finalAbilityTarget, battleManager); battleManager.EndTurn(); }
public void GetActiatedByAi(UnitStackBase unit, BattleManager manager) { uint amount = (uint)Mathf.RoundToInt(healPercentage * unit.StartingUnitCount * unit.MaxHealth); unit.GetHealedAndResurrected(amount); amountOfCharges--; }
private void Start() { description = "Активная спосбность\r\n\r\n" + $"Как армагеддон, только меньше. Наносит {damageAmount} магического урона всем отрядам на поле боя."; casterUnit = GetComponentInParent <UnitStackBase>(); }
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 Start() { description = "Активная спосбность\r\n\r\n" + $"Защищает союзную цель от любых физических атак. Дополнительно, отряд использующий способность получает {selfBuffCoefficient * 100}% сопротивления физическому урону."; casterUnit = GetComponentInParent <UnitStackBase>(); }
public void EnemyTurn(UnitStackBase activeUnit, BattleManager battleManager) { this.activeUnit = activeUnit; this.battleManager = battleManager; ActivateAppropriateStrategy(activeUnit.UnitType); }
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 PrintSelectedUnitStats(UnitStackBase unit) { DeselectCurrentTarget(); nameSelectedText.gameObject.SetActive(true); numberSelectedText.gameObject.SetActive(true); HPSelectedText.gameObject.SetActive(true); currentHPSelectedText.gameObject.SetActive(true); damageSelectedText.gameObject.SetActive(true); initiativeSelectedText.gameObject.SetActive(true); nameSelectedText.text = unit.UnitName; numberSelectedText.text = "Количество " + unit.NumberOfUnits; HPSelectedText.text = "Max HP " + unit.MaxHealth; currentHPSelectedText.text = "Current HP " + unit.TopUnitHealth; damageSelectedText.text = "Урон " + unit.Damage; initiativeSelectedText.text = "Инициатива " + unit.Initiative; List <IDisplayableIcon> icons = new List <IDisplayableIcon>(); icons.AddRange(unit.GetComponentsInChildren <IDisplayableIcon>()); for (int i = 0; i < icons.Count; i++) { IDisplayableIcon icon = icons[i]; DisplaySelectedUnitIcon(icon, i); } }
private void Start() { description = "Активная спосбность\r\n\r\n" + $"Лечит отряд и воскрешает убитых юнитов. Размер лечения равен {healPercentage * 100}% от здоровья отряда на момент начала сражения."; casterUnit = GetComponentInParent <UnitStackBase>(); }
public void Clear() { activeUnit = null; if (currentStrategy != null) { battleManager.StopCoroutine(DelayTurn(currentStrategy)); } }
private void RedirectAttack(int damage, UnitStackBase source, DamageType damageType) { if (!protectorUnit.gameObject.activeInHierarchy) { return; } protectorUnit.GetDamaged(damage, source, damageType); }
public bool UnitIsViableTarget(UnitStackBase targetUnit) { if (casterUnit.PlayerUnit != targetUnit.PlayerUnit) { return(true); } else { return(false); } }
private void DefendTarget(UnitStackBase targetUnit) { PercentageDamageReduction modifier = casterUnit.gameObject.AddComponent <PercentageDamageReduction>(); modifier.SetEffect(casterUnit, selfBuffCoefficient, iconImage); defenderEffect = targetUnit.gameObject.AddComponent <RecievedAttackRedirection>(); defenderEffect.SetEffect(targetUnit, casterUnit, iconImage); Debug.Log($"{targetUnit} is now defended by {casterUnit}."); }
public int ModifyDamageTaken(int initialDamge, UnitStackBase source, DamageType damageType) { if (damageType == DamageType.Magical) { return(0); } else { return(initialDamge); } }
public int ModifyDamageTaken(int initialDamge, UnitStackBase source, DamageType damageType) { if (damageType == DamageType.Physical) { return(Mathf.RoundToInt(initialDamge - (initialDamge * buffCoefficient))); } else { return(initialDamge); } }
public int ModifyDamageTaken(int initialDamge, UnitStackBase source, DamageType damageType) { if (damageType == DamageType.Physical) { RedirectAttack(initialDamge, source, damageType); return(0); } else { return(initialDamge); } }
private void AttackUnit(UnitStackBase unit) { if (!unit.IsTargetableByAttack()) { return; } int damage = activeUnit.GetAttackDamage(); unit.GetDamaged(damage, activeUnit, DamageType.Physical); playerTurn = false; battleManager.EndTurn(); }
public List <UnitStackBase> SpawnPlayerUnits(Army playerArmy) { this.playerArmy = playerArmy; List <UnitStackBase> returnList = new List <UnitStackBase>(); for (int i = 0; i < playerArmy.unitStacks.Count; i++) { UnitStackBase newUnit = unitFactory.Create(playerArmy.unitStacks[i], true); PlacePlayerUnit(newUnit.gameObject, i); battleUI.SetNumberOfUnitsPlaque(newUnit); returnList.Add(newUnit); } return(returnList); }
public List <UnitStackBase> SpawnEnemyUnits(Army enemyArmy) { this.enemyArmy = enemyArmy; List <UnitStackBase> returnList = new List <UnitStackBase>(); for (int i = 0; i < enemyArmy.unitStacks.Count; i++) { UnitStackBase newUnit = unitFactory.Create(enemyArmy.unitStacks[i], false); PlaceEnemyUnit(newUnit.gameObject, i); battleUI.SetNumberOfUnitsPlaque(newUnit); returnList.Add(newUnit); } return(returnList); }
private void SetUnitAsActive(UnitStackBase unit) { activeUnit = unit; activeUnit.unitSelection.SetSelectionImage(UnitSelection.SelectionType.Active); battleUI.PrintActiveUnitStats(activeUnit); if (activeUnit.PlayerUnit) { playerTurnManager.StartTurn(activeUnit, this); } else { enemyAI.EnemyTurn(activeUnit, this); } }
public void TakeTurn(UnitStackBase unit, BattleManager battleManager) { this.battleManager = battleManager; actingUnit = unit; healAbility = unit.GetComponentInChildren <HealAbility>(); if (healAbility == null) { Debug.LogError($"Unit doesn't have healing ability. Enemy strategy: HealThenAttackRandom. Enemy: {unit}."); AttackRandom(); } else { TryToHeal(); } }
public void PrintActiveUnitStats(UnitStackBase unit) { ClearActiveUnitStats(); nameActiveText.gameObject.SetActive(true); numberActiveText.gameObject.SetActive(true); HPActiveText.gameObject.SetActive(true); currentHPActiveText.gameObject.SetActive(true); damageActiveText.gameObject.SetActive(true); initiativeActiveText.gameObject.SetActive(true); nameActiveText.text = unit.UnitName; numberActiveText.text = "Количество " + unit.NumberOfUnits; HPActiveText.text = "Max HP " + unit.MaxHealth; currentHPActiveText.text = "Current HP " + unit.TopUnitHealth; damageActiveText.text = "Урон " + unit.Damage; initiativeActiveText.text = "Инициатива " + unit.Initiative; List <IActiveAbility> abilities = new List <IActiveAbility>(); abilities.AddRange(unit.GetComponentsInChildren <IActiveAbility>()); foreach (IActiveAbility ability in abilities) { SetActiveUnitAbility(ability); } List <IDisplayableIcon> blackList = new List <IDisplayableIcon>(); blackList.AddRange(abilities); List <IDisplayableIcon> icons = new List <IDisplayableIcon>(); icons.AddRange(unit.GetComponentsInChildren <IDisplayableIcon>()); foreach (IDisplayableIcon icon in icons) { if (blackList.Contains(icon)) { continue; } DisplayActiveUnitIcon(icon); } }
public void TakeTurn(UnitStackBase unit, BattleManager battleManager) { this.actingUnit = unit; this.battleManager = battleManager; defendAbility = actingUnit.GetComponentInChildren <DefendAbility>(); if (defendAbility == null) { Debug.LogError($"Unit doesn't have defending ability. Enemy strategy: DefenderStrategy. Enemy: {unit}."); AttackRandom(); return; } if (defendAbility.CanBeUsed()) { TryToUseDefend(); } else { AttackRandom(); } }
public void TakeTurn(UnitStackBase actingUnit, BattleManager battleManager) { this.actingUnit = actingUnit; this.battleManager = battleManager; this.ability = actingUnit.GetComponentInChildren <BuffDamageAbility>(); if (ability == null) { Debug.LogError($"Unit doesn't have buffing ability. Enemy strategy: SpecialCasterStrat. Enemy: {actingUnit}."); AttackRandom(); return; } if (ability.CanBeUsed()) { TryToBuffPyro(); } else { AttackRandom(); } }
private void OnUnitDied(UnitDiedEvent customEvent) { UnitStackBase unit = customEvent.Unit; if (playerUnitsInBattle.Contains(unit)) { playerUnitsInBattle.Remove(unit); } else if (enemyUnitsInBattle.Contains(unit)) { enemyUnitsInBattle.Remove(unit); } else { return; } unit.gameObject.SetActive(false); deadUnits.Add(unit); battleUI.DeselectCurrentTarget(); }
public void TakeTurn(UnitStackBase actingUnit, BattleManager battleManager) { this.actingUnit = actingUnit; this.battleManager = battleManager; this.ability = actingUnit.GetComponentInChildren <SmallmageddonAbility>(); if (ability == null) { Debug.LogError($"Unit doesn't have smallmageddon ability. Enemy strategy: PyroStrategy. Enemy: {actingUnit}."); AttackRandom(); return; } if (ability.CanBeUsed()) { ability.GetActiatedByAi(actingUnit, battleManager); battleManager.EndTurn(); } else { AttackRandom(); } }
public void SetNumberOfUnitsPlaque(UnitStackBase newUnit) { Vector3 plaquePosition; if (newUnit.PlayerUnit) { plaquePosition = new Vector3( mainCamera.WorldToScreenPoint(newUnit.transform.position).x + PlayerUnitPlaqueOffset.x, mainCamera.WorldToScreenPoint(newUnit.transform.position).y + PlayerUnitPlaqueOffset.y, 0 ); } else { plaquePosition = new Vector3( mainCamera.WorldToScreenPoint(newUnit.transform.position).x + EnemyUnitPlaqueOffset.x, mainCamera.WorldToScreenPoint(newUnit.transform.position).y + EnemyUnitPlaqueOffset.y, 0 ); } GameObject newPlaque = Instantiate(numberOfUnitsPrefab, plaquePosition, Quaternion.identity, mainCanvas.transform); newUnit.SetNumberOfUnitsPlaque(newPlaque.GetComponentInChildren <Text>()); }
public void StartTurn(UnitStackBase activeUnit, BattleManager battleManager) { this.battleManager = battleManager; this.activeUnit = activeUnit; }
private void AttackUnit(UnitStackBase targetUnit) { targetUnit.GetDamaged(actingUnit.GetAttackDamage(), actingUnit, DamageType.Physical); battleManager.EndTurn(); }
public void Clear() { activeUnit = null; playerTurn = false; currentlySelectedAbility = null; }