Beispiel #1
0
        /// <summary>
        /// Creates a new instance of the Lavabug
        /// </summary>
        /// <param name="id">the id tag</param>
        /// <param name="content">>A ContentManager to load resources with</param>
        /// <param name="position">The position of the Lavabug in the game world</param>
        public Lavabug(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            //spritesheet
            spritesheet = content.Load<Texture2D>("Spritesheets/accessories");
            this.Health = 30;
            spriteBounds[0].X = 4;
            spriteBounds[0].Y = 20;
            spriteBounds[0].Width = 70;
            spriteBounds[0].Height = 132;
            laserFired = content.Load<SoundEffect>("SFX/gamalaser");

            _mandible1 = (Mandible)ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Mandible, new Vector2(150, 120));
            _mandible2 = (Mandible)ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Mandible, new Vector2(500, 120));

            //spritebounds
        }
        /// <summary>
        /// Factory method for spawning enemies.
        /// </summary>
        /// <param name="enemyType">The type of enemy to spawn</param>
        /// <param name="position">The location to spawn the enemy</param>
        /// <returns></returns>
        public Enemy CreateEnemy(EnemyType enemyType, Vector2 position)
        {
            Enemy enemy;
            uint id = NextID();

            switch (enemyType)
            {
                case EnemyType.Dart:
                    enemy = new Dart(id, content, position);
                    break;

                case EnemyType.GreenGoblin:
                    enemy = new GreenGoblin(id, content, position);
                    break;

                case EnemyType.LaserDrone:
                    enemy = new LaserDrone(id, content, position);
                    break;

                case EnemyType.Cobalt:
                    enemy = new Cobalt(id, content, position);
                    break;

                case EnemyType.JetMinion:
                    enemy = new JetMinion(id, content, position);
                    break;

                case EnemyType.Seed:
                    enemy = new Seed(id, content, position);
                    break;

                case EnemyType.Bomber:
                    enemy = new Bomber(id, content, position);
                    break;

                case EnemyType.Arrow:
                    enemy = new Arrow(id, content, position);
                    break;

                case EnemyType.TurretSingle:
                    enemy = new TurretSingle(id, content, position);
                    break;

                case EnemyType.TurretDouble:
                    enemy = new TurretDouble(id, content, position);
                    break;

                case EnemyType.TurretTower:
                    enemy = new TurretTower(id, content, position);
                    break;

                case EnemyType.StdBaddy:
                    enemy = new StdBaddy(id, content, position);
                    break;

                case EnemyType.BeamShip:
                    enemy = new BeamShip(id, content, position);
                    break;

                case EnemyType.Kamikaze:
                    enemy = new Kamikaze(id, content, position);
                    break;

                case EnemyType.Panzer:
                    enemy = new Panzer(id, content, position);
                    break;

                case EnemyType.Panzer2:
                    enemy = new Panzer2(id, content, position);
                    break;

                case EnemyType.Lavabug:
                    enemy = new Lavabug(id, content, position);
                    break;

                case EnemyType.Lavabug2:
                    enemy = new Lavabug2(id, content, position);
                    break;

                case EnemyType.Mandible:
                    enemy = new Mandible(id, content, position, lavaFlip);
                    lavaFlip = !lavaFlip;
                    break;

                case EnemyType.BladeSpinner:
                    enemy = new BladeSpinner(id, content, position);
                    break;

                case EnemyType.DeerTickDown:
                    enemy = new DeerTick(id, content, position, DeerTickDirection.Straight);
                    break;

                case EnemyType.DeerTickLeft:
                    enemy = new DeerTick(id, content, position, DeerTickDirection.Left);
                    break;

                case EnemyType.DeerTickRight:
                    enemy = new DeerTick(id, content, position, DeerTickDirection.Right);
                    break;

                case EnemyType.Turret:
                    enemy = new Turret(id, content, position);
                    break;

                case EnemyType.JTurret:
                    enemy = new JTurret(id, content, position);
                    break;

                case EnemyType.DrillLeft:
                    enemy = new Drill(id, content, true);
                    break;

                case EnemyType.DrillRight:
                    enemy = new Drill(id, content, false);
                    break;

                case EnemyType.SuicideBomber:
                    enemy = new SuicideBomber(id, content, position);
                    break;

                case EnemyType.LavaFighter:
                    enemy = new LavaFighter(id, content, position);
                    break;

                case EnemyType.TwinJet:
                    enemy = new TwinJet(id, content, position);
                    break;

                case EnemyType.AlienTurret:
                    enemy = new AlienTurret(id, content, position);
                    break;

                case EnemyType.RightClaw:
                    enemy = new RightClaw(id, content, position);
                    break;

                case EnemyType.LeftClaw:
                    enemy = new LeftClaw(id, content, position);
                    break;

                case EnemyType.BrainBoss:
                    enemy = new BrainBoss(id, content, position);
                    break;

                case EnemyType.BrainBossPsyEmitter:
                    enemy = new BrainBossPsiEmitter(id, content, position);
                    break;

                case EnemyType.BrainBossProtection:
                    enemy = new BrainBossProtection(id, content, position);
                    break;

                default:
                    throw new NotImplementedException("The enemy type " + Enum.GetName(typeof(EnemyType), enemyType) + " is not supported");
            }

            enemy.ObjectType = ObjectType.Enemy;
            QueueGameObjectForCreation(enemy);
            return enemy;
        }
        /// <summary>
        /// Factory method for spawning enemies.
        /// </summary>
        /// <param name="enemyType">The type of enemy to spawn</param>
        /// <param name="position">The location to spawn the enemy</param>
        /// <returns></returns>
        public Enemy CreateEnemy(EnemyType enemyType, Vector2 position)
        {
            Enemy enemy;
            uint  id = NextID();

            switch (enemyType)
            {
            case EnemyType.Dart:
                enemy = new Dart(id, content, position);
                break;

            case EnemyType.GreenGoblin:
                enemy = new GreenGoblin(id, content, position);
                break;


            case EnemyType.LaserDrone:
                enemy = new LaserDrone(id, content, position);
                break;

            case EnemyType.Cobalt:
                enemy = new Cobalt(id, content, position);
                break;

            case EnemyType.JetMinion:
                enemy = new JetMinion(id, content, position);
                break;

            case EnemyType.Seed:
                enemy = new Seed(id, content, position);
                break;

            case EnemyType.Bomber:
                enemy = new Bomber(id, content, position);
                break;

            case EnemyType.Arrow:
                enemy = new Arrow(id, content, position);
                break;

            case EnemyType.StdBaddy:
                enemy = new StdBaddy(id, content, position);
                break;

            case EnemyType.beamShip:
                enemy = new beamShip(id, content, position);
                break;

            case EnemyType.Kamikaze:
                enemy = new Kamikaze(id, content, position);
                break;

            case EnemyType.Panzer:
                enemy = new Panzer(id, content, position);
                break;

            case EnemyType.Panzer2:
                enemy = new Panzer2(id, content, position);
                break;

            case EnemyType.Lavabug:
                enemy = new Lavabug(id, content, position);
                break;

            case EnemyType.Lavabug2:
                enemy = new Lavabug2(id, content, position);
                break;

            case EnemyType.Mandible:
                enemy    = new Mandible(id, content, position, lavaFlip);
                lavaFlip = !lavaFlip;
                break;

            case EnemyType.BladeSpinner:
                enemy = new BladeSpinner(id, content, position);
                break;

            case EnemyType.DeerTickDown:
                enemy = new DeerTick(id, content, position, DeerTickDirection.Straight);
                break;

            case EnemyType.DeerTickLeft:
                enemy = new DeerTick(id, content, position, DeerTickDirection.Left);
                break;

            case EnemyType.DeerTickRight:
                enemy = new DeerTick(id, content, position, DeerTickDirection.Right);
                break;

            case EnemyType.Turret:
                enemy = new Turret(id, content, position);
                break;

            case EnemyType.JTurret:
                enemy = new JTurret(id, content, position);
                break;

            case EnemyType.DrillLeft:
                enemy = new Drill(id, content, true);
                break;

            case EnemyType.DrillRight:
                enemy = new Drill(id, content, false);
                break;

            case EnemyType.SuicideBomber:
                enemy = new SuicideBomber(id, content, position);
                break;

            default:
                throw new NotImplementedException("The enemy type " + Enum.GetName(typeof(EnemyType), enemyType) + " is not supported");
            }

            QueueGameObjectForCreation(enemy);
            return(enemy);
        }
        /// <summary>
        /// Updates the Lavabug
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // Pause the scrolling
            if (-ScrollingShooterGame.LevelManager.scrollDistance / 2 <= position.Y - 50) ScrollingShooterGame.LevelManager.Scrolling = false;

            // Sense the player's position
            PlayerShip player = ScrollingShooterGame.Game.Player;
            Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y);

            if (mandibles == false && ScrollingShooterGame.LevelManager.Scrolling == false)
            {
                _mandible1 = (Mandible)ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Mandible,
                  new Vector2(this.position.X - 30, this.position.Y));
                _mandible2 = (Mandible)ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Mandible,
                    new Vector2(this.position.X + 11, this.position.Y));
                mandibles = true;
            }

            if (this.Health <= 200)
            {
                _mandible1.isFired = true;
                _mandible2.isFired = true;
            }
            if (stage == 1 && this.Health <= 100)
            {
                stage = 2;
                bug1 = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Lavabug2,
                    new Vector2(this.position.X - 10, this.position.Y + 10));
                bug2 = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.Lavabug2,
                  new Vector2(this.position.X + 10, this.position.Y + 10));
            }

            if (stage == 2)
            {
                Health = 100;
                if (bug1.Health <= 0 && bug2.Health <= 0)
                    Health = 0;
            }

            // Move in front of player
            //this.position.Y = playerPosition.Y;
            this.position.X = playerPosition.X;

            //fire at player
            Fire(elapsedTime);
        }