コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            for (int i = _components.Count - 1; i > 0; i--)
            {
                var item = _components[i];
                if (item == null)
                {
                    throw new ArgumentNullException(nameof(item));
                }
                if (item.Enabled == false)
                {
                    continue;
                }
                item.Update(gameTime);

                var collider = item as ICollider;
                if (collider != null)
                {
                    foreach (var itemInner in _components)
                    {
                        if (itemInner.Enabled == false)
                        {
                            continue;
                        }
                        var collidable = itemInner as ICollidable;
                        if (collidable != null)
                        {
                            if (collidable.Intersects(collider))
                            {
                                collidable.OnCollision(collider);
                                collider.OnCollision(collidable);
                            }
                        }
                    }
                }
            }
            if (life < 1)
            {
                _game.ScreenManager.ActivateScreen(GameScreens.GameOver);
            }

/*
 *          Vector3 waveVector = new Vector3(0,0,0);
 *          waveVector = Waves[WaveNumber].TheWave;
 *          if(count % 90 == 0)
 *          {
 *              SpawnEnemy(this, (int) waveVector.X, 0);
 *              Console.Write("Spawn1");
 *          }
 *          if(count % 90 == 30)
 *          {
 *              SpawnEnemy(this, (int) waveVector.Y, 1);
 *              Console.Write("Spawn2");
 *          }
 *          if(count % 90 == 60)
 *          {
 *              SpawnEnemy(this, (int)waveVector.Z, 2);
 *              Console.Write("Spawn3");
 *          }
 */


            if (spawnCount == 4)
            {
                spawnCount = 1;
                Vector3 waveVector = new Vector3(0, 0, 0);
                waveVector      = Waves[WaveNumber++].TheWave;
                FrostyCountdown = (int)waveVector.X;
                //Console.WriteLine("Frosty count " + FrostyCountdown);
                FieryCountdown = (int)waveVector.Y;
                //Console.WriteLine("Fiery count " + FieryCountdown);
                EarthyCountdown = (int)waveVector.Z;
                //Console.WriteLine("Earthy count " + EarthyCountdown);
            }

            if (count++ % 30 == 0)
            {
                //Console.WriteLine("Spawn count " + spawnCount);
                if (spawnCount == 1 && EarthyCountdown > 0)
                {
                    SpawnEnemy(this, EnemyType.Earthy);
                    EarthyCountdown--;
                }
                if (EarthyCountdown == 0 && spawnCount == 1)
                {
                    spawnCount++;
                }


                if (spawnCount == 2 && FieryCountdown > 0)
                {
                    SpawnEnemy(this, EnemyType.Fiery);
                    FieryCountdown--;
                }
                if (FieryCountdown == 0 && spawnCount == 2)
                {
                    spawnCount++;
                }
                if (spawnCount == 3 && FrostyCountdown > 0)
                {
                    SpawnEnemy(this, EnemyType.Frosty);
                    FrostyCountdown--;
                }
                if (EarthyCountdown == 0 && spawnCount == 3)
                {
                    spawnCount++;
                }
            }

            if (this._game.mouseState.RightButton == ButtonState.Pressed)
            {
                TowerMenu.Active = false;
                DeselectAllTowers();
            }
            if (TowerMenu.Active)
            {
                TowerMenu.Update(gameTime);
            }

            base.Update(gameTime);
            count++;
        }