Beispiel #1
0
            private int CalculateDamage()
            {
                int attack, defense;

                //checking if calc should use physical or magical stats
                if (attackingHit.CheckAttribute(HitAttributes.Physical))
                {
                    attack  = attackingUnit.physicalAttack;
                    defense = defendingUnit.physicalDefense;
                }
                else
                {
                    attack  = attackingUnit.magicalAttack;
                    defense = defendingUnit.magicalDefense;
                }

                //setting modifier to make enemies take more damage
                int allyModifier = (defendingUnit.GetTargetType() == TargetTypes.Enemy) ? 1 : 1000;

                //damage calculation
                int damage = Mathf.RoundToInt((attackingHit.GetHitModifier() * ((1F + attack) / (1f + defense))) / allyModifier);



                //applying all modifiers
                foreach (float modifier in modifiers.Values)
                {
                    damage = Mathf.RoundToInt(damage * modifier);
                }

                return(damage);
            }