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();
        }
示例#2
0
        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);
        }
示例#5
0
        private void Start()
        {
            description = "Активная спосбность\r\n\r\n" +
                          $"Защищает союзную цель от любых физических атак. Дополнительно, отряд использующий способность получает {selfBuffCoefficient * 100}% сопротивления физическому урону.";

            casterUnit = GetComponentInParent <UnitStackBase>();
        }
示例#6
0
        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();
        }
示例#8
0
        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);
            }
        }
示例#9
0
        private void Start()
        {
            description = "Активная спосбность\r\n\r\n" +
                          $"Лечит отряд и воскрешает убитых юнитов. Размер лечения равен {healPercentage * 100}% от здоровья отряда на момент начала сражения.";

            casterUnit = GetComponentInParent <UnitStackBase>();
        }
示例#10
0
 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);
        }
示例#12
0
 public bool UnitIsViableTarget(UnitStackBase targetUnit)
 {
     if (casterUnit.PlayerUnit != targetUnit.PlayerUnit)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#13
0
        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}.");
        }
示例#14
0
 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();
        }
示例#18
0
        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);
        }
示例#19
0
        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);
        }
示例#20
0
 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);
     }
 }
示例#21
0
 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();
     }
 }
示例#22
0
        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();
            }
        }
示例#25
0
        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();
        }
示例#26
0
        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();
            }
        }
示例#27
0
        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;
 }