Exemplo n.º 1
0
        private Enemy CreateEnemyFromDef(EnemyDef definition)
        {
            Enemy enemy = new Enemy(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

            if (definition.EnemyType == "cannon_fodder")
            {
                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, 250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_low")
            {
                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, -250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_straight")
            {
                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 14);
            }
            else if (definition.EnemyType == "up_l")
            {
                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, -375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, 200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "down_l")
            {
                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, 375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, -200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Unknown enemy type.");
            }

            return(enemy);
        }
Exemplo n.º 2
0
        private void UpdateEnemySpawns(double gameTime)
        {
            if (_upComingEnemies.Count == 0)
            {
                return;
            }

            EnemyDef lastElement = _upComingEnemies[0];

            if (gameTime > lastElement.LaunchTime)
            {
                _upComingEnemies.RemoveAt(0);
                _enemies.Add(CreateEnemyFromDef(lastElement));
            }
        }
Exemplo n.º 3
0
        private void UpdateEnemySpawns(double gameTime)
        {
            // If no upcoming enemies then there's nothing to spawn.
            if (_upComingEnemies.Count == 0)
            {
                return;
            }

            EnemyDef lastElement = _upComingEnemies[_upComingEnemies.Count - 1];

            if (gameTime < lastElement.LaunchTime)
            {
                _upComingEnemies.RemoveAt(_upComingEnemies.Count - 1);
                _enemies.Add(CreateEnemyFromDef(lastElement));
            }
        }
Exemplo n.º 4
0
        //private void UpdateEnemySpawns(double gameTime)
        //{
        //    // If no upcoming enemies then there's nothing to spawn
        //    if (_upComingEnemies.Count == 0)
        //    {
        //        return;
        //    }
        //    EnemyDef lastElement = _upComingEnemies[_upComingEnemies.Count - 1];
        //    if (gameTime < lastElement.LaunchTime)
        //    {
        //        _upComingEnemies.RemoveAt(_upComingEnemies.Count - 1);
        //        _enemies.Add(CreateEnemyFromDef(lastElement));
        //    }
        //}
        private Enemy CreateEnemyFromDef(EnemyDef definition)
        {
            Enemy enemy = new Enemy(_textureManager, _effectsManager, _bulletManager);

            if (definition.EnemyType == "cannon_fodder")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }

            if (definition.EnemyType == "cannon_fodder_high")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, 250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }

            else if (definition.EnemyType == "cannon_fodder_low")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, -250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }

            else if (definition.EnemyType == "cannon_fodder_straight")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 14);
            }

            else if (definition.EnemyType == "up_l")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(500, -375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, 200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }

            else if (definition.EnemyType == "down_l")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(500, 375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, -200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }

            //else
            //{
            //    System.Diagnostics.Debug.Assert(false, "Unknown enemy type.");
            //}
            return enemy;
        }
Exemplo n.º 5
0
        private Enemy CreateEnemyFromDef(EnemyDef definition)
        {
            Enemy enemy = null;

            if (definition.EnemyType == "cannon_fodder")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, 250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_low")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(0, -250, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "cannon_fodder_straight")
            {
                enemy = new Cruiser(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));
                enemy.Path = new Path(_pathPoints, 16);
            }
            else if (definition.EnemyType == "asteroid")
            {
                enemy = new Asteroid(_textureManager, _effectsManager, _playerCharacter);

                Random random = new Random();
                double y      = random.Next((int)_bounds.Top, (int)_bounds.Bottom);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, y, 0));
                _pathPoints.Add(new Vector(-1400, y, 0));

                enemy.Path = new Path(_pathPoints, 20);
            }
            else if (definition.EnemyType == "up_1")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, -375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, 200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "down_1")
            {
                enemy = new CannonFodder(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(500, 375, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(500, 0, 0));
                _pathPoints.Add(new Vector(-1400, -200, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else if (definition.EnemyType == "boss")
            {
                enemy = new Boss(_textureManager, _effectsManager, _bulletManager, _playerCharacter);

                List <Vector> _pathPoints = new List <Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(300, 0, 0));

                enemy.Path = new Path(_pathPoints, 10);
            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Uknown enemy type.");
            }

            return(enemy);
        }