Пример #1
0
 public void SetAttacker(ref AiUnit attacker)
 {
     this.attacker = attacker;
 }
Пример #2
0
        public void Combat <T>(AiUnit attacker, T defender, Random rng)
        {
            float final_dmg = 0;

            switch (attacker.Stats.WeaponType)
            {
            case WeaponType.Spear:
                final_dmg += 5;
                break;

            case WeaponType.Sword:
                final_dmg += 8;
                break;

            case WeaponType.Bow:
                final_dmg += 3;
                break;

            case WeaponType.Voice:
                final_dmg += 1;
                break;
            }

            switch (attacker.Stats.Focus)
            {
            case Focus.Aggressive:
                final_dmg += 5;
                break;

            case Focus.Violent:
                final_dmg += 10;
                break;

            case Focus.Focused:
                final_dmg += 7;
                break;

            case Focus.Hyper:
                final_dmg += 3;
                break;
            }

            switch (attacker.Stats.Luck)
            {
            case Luck.Cowardly:
                if (rng.Next(0, 100) <= 2)
                {
                    final_dmg *= 2;
                }
                break;

            case Luck.Holy:
                if (rng.Next(0, 100) <= 25)
                {
                    final_dmg *= 2;
                }
                break;

            case Luck.Trained:
                if (rng.Next(0, 100) <= 10)
                {
                    final_dmg *= 2;
                }
                break;

            case Luck.Zombie:
                if (rng.Next(0, 100) <= 5)
                {
                    final_dmg *= 2;
                }
                break;
            }

            if (typeof(T) == typeof(Building))
            {
                Building d = defender as Building;
                //calculate dmg


                switch (d.GetBuildingData().ArmourType)
                {
                case ArmourType.Reinforced:
                    final_dmg /= 2;
                    break;
                }

                if (d.State == BuildingStates.Building)
                {
                    final_dmg *= 2;
                }

                final_dmg += attacker.Stats.BaseDamage;

                d.GetBuildingData().Health -= final_dmg;
            }

            if (typeof(T) == typeof(Grounded))
            {
                Grounded d = defender as Grounded;
                switch (d.Stats.ArmourType)
                {
                case ArmourType.Heavy:
                    final_dmg /= 1.8f;
                    break;

                case ArmourType.Medium:
                    final_dmg /= 1.5f;
                    break;

                case ArmourType.Light:
                    final_dmg /= 1.2f;
                    break;

                case ArmourType.None:
                    final_dmg *= 1.1f;
                    break;
                }

                switch (d.Stats.Luck)
                {
                case Luck.Cowardly:
                    if (rng.Next(0, 100) <= 2)
                    {
                        final_dmg /= 2;
                    }
                    break;

                case Luck.Holy:
                    if (rng.Next(0, 100) <= 50)
                    {
                        final_dmg /= 2;
                    }
                    break;

                case Luck.Trained:
                    if (rng.Next(0, 100) <= 25)
                    {
                        final_dmg /= 2;
                    }
                    break;

                case Luck.Zombie:
                    if (rng.Next(0, 100) <= 10)
                    {
                        final_dmg /= 2;
                    }
                    break;
                }

                final_dmg += attacker.Stats.BaseDamage;
                d.GetStats().Health -= final_dmg;

                d.Retaliate(attacker.ID);
            }
        }