private void KilledMonster(IGameTank gameTank, Monster monster)
        {
            var gameState = _game.GameState;

            if (monster.OnDeathAbility != null)
            {
                monster.OnDeathAbility.Invoke(gameState);
            }

            gameState.Foes.Remove(monster);
            if (!gameState.Lost)
            {
                gameTank.Killed++;
                if (monster is BossMonster)
                {
                    gameTank.BossesKilled++;
                }
            }
        }
        private void SpawnFoes(GameState gameState)
        {
            CheckForNewWave();

            int foesToSpawnLog = _game.FoesToSpawn;

            while (foesToSpawnLog > 0)
            {
                if (_game.GameState.Wave % 5 == 0)
                {
                    _game.FoesToSpawn = 0;

                    AbilityType type = _game.GameState.WaveType;

                    BossMonster m =
                        new BossMonster(foesToSpawnLog *
                                        (int)(_game.MonsterStartHealth * Math.Pow(1.1, gameState.Wave) + 1), type);
                    m.Location = new Location(gameState.Size.Width / 2 - m.Size.Width / 2.0,
                                gameState.Size.Height / 2 - m.Size.Height / 2.0);

                    foesToSpawnLog = 0;
                    gameState.Foes.Add(m);
                }
                else
                {
                    _game.FoesToSpawn--;
                    foesToSpawnLog /= 10;

                    AbilityType type;
                    int rand = new Random().Next(1, 20);

                    if (rand == 1)
                    {
                        type = AbilityType.Healing;
                    }
                    else if (rand == 2)
                    {
                        type = AbilityType.Splitter;
                    }
                    else if (rand == 3)
                    {
                        type = AbilityType.RangedHeat;
                    }
                    else if (rand == 4)
                    {
                        type = AbilityType.Fast;
                    }
                    else if (rand == 5)
                    {
                        type = AbilityType.Kamakaze;
                    }
                    else
                    {
                        type = _game.GameState.WaveType;
                    }

                    Monster m = new Monster((int)(_game.MonsterStartHealth * Math.Pow(1.1, gameState.Wave) + 1), type)
                    {
                        Location = new Location(gameState.Size.Width / 2 - Monster.Width / 2.0,
                            gameState.Size.Height / 2 - Monster.Height / 2.0)
                    };

                    gameState.Foes.Add(m);
                }
            }
        }
Esempio n. 3
0
 protected void SetOnHitAbilities()
 {
     if (AbilityType == AbilityType.Fast)
     {
         Speed = (Speed + MaxSpeed) / 2;
         Velocity.Total *= 1.1;
     }
     else if (AbilityType == AbilityType.Splitter)
     {
         OnHitAbility = (gameState, damageTaken) =>
         {
             if (_heat <= 0 && gameState.Foes.Count < 100 && Health > 1 && Generation < 5)
             {
                 var heatGain = 20;
                 _heat += heatGain;
                 Health /= 2;
                 Generation++;
                 var splitling = new Monster(Health, AbilityType.Splitter)
                 {
                     Location = new Location(X, Y),
                     Velocity = new Vector(Velocity.X + _random.NextDouble() - .5, Velocity.Y + _random.NextDouble() - .5),
                     Speed = Speed,
                     Generation = Generation
                 };
                 splitling._heat = heatGain;
                 gameState.Foes.Add(splitling);
             }
         };
     }
 }