コード例 #1
0
        void Spawn(Grid grid, Random rng)
        {
            if (spawnY < 0)
            {
                s_elasped = 0;
                spawnY    = 0;
                formations.RemoveAt(0);
                ys.RemoveAt(0);
                spawning = false;
                return;
            }

            for (int x = formations.First().GetLength(0) - 1; x >= 0; x--)
            {
                int   posy              = ys.First();
                int   posx              = 5;
                Stats nstats            = new Stats(ai_stats[formations.First()[x, spawnY]]);
                Type_Data <Ai_Type> nut = new Type_Data <Ai_Type>(unit_types[formations.First()[x, spawnY]]);
                var unit = new Grounded(new Vector2(posx, posy + (64 * x)), new Point(32, 32), nut, nstats, grid);
                ais.Add(unit.AID, unit);
            }

            spawnY--;
            spawnX = 0;
        }
コード例 #2
0
        void AiSwap(Guid ai, Grid grid, Architech arch)  //swaps a unit to an equalivalent zombie unit
        {
            var old  = zombies[ai];
            var unit = new Grounded(old.Position, new Point(32, 32), unit_types[ConvertToGrounded(old.GetStats().Type)], ai_stats[ConvertToGrounded(old.GetStats().Type)], grid);

            unit.GetStats().Health = 0;
            ais.Add(unit.ID, unit);
            zombies.Remove(ai);
        }
コード例 #3
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);
            }
        }