예제 #1
0
        /// <summary>
        /// Creates a new brain boss
        /// </summary>
        /// <param name="id">The game id to assign to the new object</param>
        /// <param name="content">A ContentManager to load content from</param>
        /// <param name="position">A position on the screen</param>
        public BrainBoss(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.brainSpritesheet  = content.Load <Texture2D>("Spritesheets/newsh5.shp.000000");
            this.psiOrbSpritesheet = content.Load <Texture2D>("Spritesheets/tyrian.shp.000000");

            this.brainSpriteBounds = new Rectangle(60, 143, 73, 80);
            this.psiOrbBounds      = new Rectangle(121, 172, 21, 21);
            this.psiOrbOrigin      = new Vector2(psiOrbBounds.Width / 2, psiOrbBounds.Height / 2);

            psiOrbOffset.X = brainSpriteBounds.Width / 2;
            psiOrbOffset.Y = brainSpriteBounds.Height / 2;

            this.Health = 100;

            this.position = position;

            centerOffset = new Vector2(brainSpriteBounds.Width / 2, brainSpriteBounds.Height / 2);

            psiEmitter = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.BrainBossPsyEmitter, position + centerOffset) as BrainBossPsiEmitter;

            protection = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.BrainBossProtection, position + centerOffset) as BrainBossProtection;

            targetPositionX = (int)position.X;
            targetPositionY = (int)(position.Y + ScrollingShooterGame.Game.GraphicsDevice.Viewport.Height / 5 - brainSpriteBounds.Height / 2);
        }
예제 #2
0
        /// <summary>
        /// Updates the brain boss
        /// </summary>
        /// <param name="elapsedTime">Time passed since last frame</param>
        public override void Update(float elapsedTime)
        {
            switch (state)
            {
                case BrainBossState.Protected:
                    //can't die in this state
                    Health = 999999;

                    if (protection.isDestroyed())
                    {
                        ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID);
                        state = BrainBossState.MovingToCenter;
                        protection = null;
                    }
                    break;
                case BrainBossState.MovingToCenter:
                    //can't die in this state
                    Health = 999999;

                    if (position.X < targetPositionX)
                        position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));
                    else if (position.X > targetPositionY)
                        position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));

                    if (position.Y < targetPositionY)
                        position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));
                    else if (position.Y > targetPositionY)
                        position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));

                    if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2)
                    {
                        state = BrainBossState.PsyAttack;
                        psiEmitter.startAttacking();
                    }

                    break;

                case BrainBossState.PsyAttack:
                    //can't die in this state
                    Health = 999999;

                    if (psiEmitter.isDestroyed())
                    {
                        //Health when can be hit
                        Health = 100;
                        state = BrainBossState.DeathCharge;
                    }
                    break;

                case BrainBossState.DeathCharge:
                    if (Health <= 0)
                    {
                        ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID);
                        ScrollingShooterGame.GameObjectManager.CreateExplosion(ID);
                        return;
                    }

                    Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset);
                    vector.Normalize();
                    vector *= MOVE_SPEED * elapsedTime;

                    position.X += vector.X;
                    position.Y += vector.Y;

                    lightningRecharge -= elapsedTime;
                    if (lightningRecharge <= 0)
                    {
                        lightningRecharge = .66f;

                        for (int i = 0; i < 15; i++)
                            ((EnemyLightningZap)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float)(rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width / 2);
                    }
                    break;
            }

            psiEmitter.updatePosition(this.position + centerOffset);
        }
예제 #3
0
        /// <summary>
        /// Creates a new brain boss
        /// </summary>
        /// <param name="id">The game id to assign to the new object</param>
        /// <param name="content">A ContentManager to load content from</param>
        /// <param name="position">A position on the screen</param>
        public BrainBoss(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.brainSpritesheet = content.Load<Texture2D>("Spritesheets/newsh5.shp.000000");
            this.psiOrbSpritesheet = content.Load<Texture2D>("Spritesheets/tyrian.shp.000000");

            this.brainSpriteBounds = new Rectangle(60, 143, 73, 80);
            this.psiOrbBounds = new Rectangle(121, 172, 21, 21);
            this.psiOrbOrigin = new Vector2(psiOrbBounds.Width / 2, psiOrbBounds.Height / 2);

            psiOrbOffset.X = brainSpriteBounds.Width / 2;
            psiOrbOffset.Y = brainSpriteBounds.Height / 2;

            this.Health = 100;

            this.position = position;

            centerOffset = new Vector2(brainSpriteBounds.Width / 2, brainSpriteBounds.Height / 2);

            psiEmitter = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.BrainBossPsyEmitter, position + centerOffset) as BrainBossPsiEmitter;

            protection = ScrollingShooterGame.GameObjectManager.CreateEnemy(EnemyType.BrainBossProtection, position + centerOffset) as BrainBossProtection;

            targetPositionX = (int)position.X;
            targetPositionY = (int)(position.Y + ScrollingShooterGame.Game.GraphicsDevice.Viewport.Height / 5 - brainSpriteBounds.Height / 2);
        }
예제 #4
0
        /// <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;
        }
예제 #5
0
        /// <summary>
        /// Updates the brain boss
        /// </summary>
        /// <param name="elapsedTime">Time passed since last frame</param>
        public override void Update(float elapsedTime)
        {
            //TODO: remove test timer when damage is implemented

            testTimer -= elapsedTime;

            if (testTimer <= 0)
            {
                takeDamage(1000);
                if (this.protection != null)
                    protection.takeDamage(1000);
                if (this.psiEmitter != null)
                    psiEmitter.takeDamage(1000);
                testTimer = 8f;
            }

            switch (state)
            {
                case BrainBossState.Protected:
                    if (protection.Health <= 0)
                    {
                        ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID);
                        state = BrainBossState.MovingToCenter;
                        protection = null;
                    }
                    break;
                case BrainBossState.MovingToCenter:
                    if (position.X < targetPositionX)
                        position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));
                    else if (position.X > targetPositionY)
                        position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));

                    if (position.Y < targetPositionY)
                        position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));
                    else if (position.Y > targetPositionY)
                        position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));

                    if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2)
                    {
                        state = BrainBossState.PsyAttack;
                        psiEmitter.startAttacking();
                    }

                    break;

                case BrainBossState.PsyAttack:

                    if (psiEmitter.Health <= 0)
                        state = BrainBossState.DeathCharge;
                    break;

                case BrainBossState.DeathCharge:
                    if (Health <= 0)
                    {
                        ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID);
                        ScrollingShooterGame.GameObjectManager.CreateExplosion(ID);
                        return;
                    }

                    Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset);
                    vector.Normalize();
                    vector *= MOVE_SPEED * elapsedTime;

                    position.X += vector.X;
                    position.Y += vector.Y;

                    for(int i = 0; i < 1; i++)
                        ((EnemyLightningZap) ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float) (rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width);

                    break;
            }

            psiEmitter.updatePosition(this.position + centerOffset);
        }
예제 #6
0
        /// <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.Bird:
                enemy = new Bird(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;

            case EnemyType.Mine:
                enemy = new Mine(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);
        }
예제 #7
0
        /// <summary>
        /// Updates the brain boss
        /// </summary>
        /// <param name="elapsedTime">Time passed since last frame</param>
        public override void Update(float elapsedTime)
        {
            //TODO: remove test timer when damage is implemented

            testTimer -= elapsedTime;

            if (testTimer <= 0)
            {
                takeDamage(1000);
                if (this.protection != null)
                {
                    protection.takeDamage(1000);
                }
                if (this.psiEmitter != null)
                {
                    psiEmitter.takeDamage(1000);
                }
                testTimer = 8f;
            }

            switch (state)
            {
            case BrainBossState.Protected:
                if (protection.Health <= 0)
                {
                    ScrollingShooterGame.GameObjectManager.DestroyObject(protection.ID);
                    state      = BrainBossState.MovingToCenter;
                    protection = null;
                }
                break;

            case BrainBossState.MovingToCenter:
                if (position.X < targetPositionX)
                {
                    position.X += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));
                }
                else if (position.X > targetPositionY)
                {
                    position.X -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionX - position.X));
                }

                if (position.Y < targetPositionY)
                {
                    position.Y += Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));
                }
                else if (position.Y > targetPositionY)
                {
                    position.Y -= Math.Min(MOVE_SPEED * elapsedTime, Math.Abs(targetPositionY - position.Y));
                }

                if (Math.Abs(targetPositionX - position.X) < 2 && Math.Abs(targetPositionY - position.Y) < 2)
                {
                    state = BrainBossState.PsyAttack;
                    psiEmitter.startAttacking();
                }

                break;

            case BrainBossState.PsyAttack:

                if (psiEmitter.Health <= 0)
                {
                    state = BrainBossState.DeathCharge;
                }
                break;

            case BrainBossState.DeathCharge:
                if (Health <= 0)
                {
                    ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID);
                    ScrollingShooterGame.GameObjectManager.CreateExplosion(ID);
                    return;
                }

                Vector2 vector = ScrollingShooterGame.Game.Player.GetPosition() - (position + centerOffset);
                vector.Normalize();
                vector *= MOVE_SPEED * elapsedTime;

                position.X += vector.X;
                position.Y += vector.Y;

                for (int i = 0; i < 1; i++)
                {
                    ((EnemyLightningZap)ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyLightningZap, this.position + centerOffset)).Initialize((float)(rand.NextDouble() * Math.PI * 2), this.brainSpriteBounds.Width);
                }

                break;
            }

            psiEmitter.updatePosition(this.position + centerOffset);
        }