Example #1
0
        public Enemy(EnemyType type, Level l)
        {
            this.Type = type;
            Health = 1;
            VelocityModifier = 1.0f;

            InitializeTimer = 0;

            Alpha = 1.0f;
            alphaIncrease = 0.03f;
            level = l;

            DashCooldown = 0;

            Initialized = false;

            TwirlRotation = 0;
            SlowRotation = 0;

            ImprintSpawn = 0;

            Origin = new Vector2(Type.Texture.Width / 2, Type.Texture.Height / 2);

            if (Type.Equals(level.DashEnemy))
            {
                Animation = new Animation(Type.Texture, 40, 0.01f);
                Origin = new Vector2(Animation.FrameWidth / 2, Animation.Texture.Height / 2);
            }

            SpawnAnimation = new Animation(l.EnemySpawnTexture, 200.0f, 0.1f);
            SpawnAlpha = 0.01f;
        }
Example #2
0
        public Bullet(BulletType bType, Vector2 velocity, Level level)
        {
            this.Type = bType;
            this.Velocity = velocity;
            this.level = level;

            Reset();
        }
Example #3
0
        public TravelPoint(Level level)
        {
            this.level = level;

            Origin = new Vector2(level.WhitePoint.Width / 2.0f, level.WhitePoint.Height / 2.0f);

            r = new Random();

            Position = Vector2.Zero;
        }
Example #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Is this a trial?
            IsTrial = Guide.IsTrialMode;

            // The gamepad states of all the players
            gps1 = GamePad.GetState(PlayerIndex.One);
            gps2 = GamePad.GetState(PlayerIndex.Two);
            gps3 = GamePad.GetState(PlayerIndex.Three);
            gps4 = GamePad.GetState(PlayerIndex.Four);

            // Menu Timer
            MenuTimer += gameTime.ElapsedGameTime.Milliseconds;

            // Volume
            if (!MediaPlayer.Volume.Equals(MusicVolume))
            {
                MediaPlayer.Volume = MusicVolume;
            }

            bool AButtonHit = (gps1.IsButtonDown(Buttons.A)
                || gps2.IsButtonDown(Buttons.A) || gps2.IsButtonDown(Buttons.Start)
                || gps3.IsButtonDown(Buttons.A) || gps3.IsButtonDown(Buttons.Start)
                || gps4.IsButtonDown(Buttons.A) || gps4.IsButtonDown(Buttons.Start));

            bool StartButtonHit = (gps1.IsButtonDown(Buttons.Start)
                 || gps2.IsButtonDown(Buttons.Start)
                 || gps3.IsButtonDown(Buttons.Start)
                 || gps4.IsButtonDown(Buttons.Start));

            bool BButtonHit = (gps1.IsButtonDown(Buttons.B)
                || gps2.IsButtonDown(Buttons.B)
                || gps3.IsButtonDown(Buttons.B)
                || gps4.IsButtonDown(Buttons.B));

            bool BackButtonHit = (gps1.IsButtonDown(Buttons.Back)
                 || gps2.IsButtonDown(Buttons.Back)
                 || gps3.IsButtonDown(Buttons.Back)
                 || gps4.IsButtonDown(Buttons.Back));

            bool DownButtonHit = (gps1.ThumbSticks.Left.Y < -0.5f || gps1.IsButtonDown(Buttons.DPadDown)
                || gps2.ThumbSticks.Left.Y < -0.5f || gps2.IsButtonDown(Buttons.DPadDown)
                || gps3.ThumbSticks.Left.Y < -0.5f || gps3.IsButtonDown(Buttons.DPadDown)
                || gps4.ThumbSticks.Left.Y < -0.5f || gps4.IsButtonDown(Buttons.DPadDown));

            bool UpButtonHit = (gps1.ThumbSticks.Left.Y > 0.5f || gps1.IsButtonDown(Buttons.DPadUp)
                || gps2.ThumbSticks.Left.Y > 0.5f || gps2.IsButtonDown(Buttons.DPadUp)
                || gps3.ThumbSticks.Left.Y > 0.5f || gps3.IsButtonDown(Buttons.DPadUp)
                || gps4.ThumbSticks.Left.Y > 0.5f || gps4.IsButtonDown(Buttons.DPadUp));

            bool LeftButtonHit = (gps1.ThumbSticks.Left.X < -0.5f || gps1.IsButtonDown(Buttons.DPadLeft)
                || gps2.ThumbSticks.Left.X < -0.5f || gps2.IsButtonDown(Buttons.DPadLeft)
                || gps3.ThumbSticks.Left.X < -0.5f || gps3.IsButtonDown(Buttons.DPadLeft)
                || gps4.ThumbSticks.Left.X < -0.5f || gps4.IsButtonDown(Buttons.DPadLeft));

            bool RightButtonHit = (gps1.ThumbSticks.Left.X > 0.5f || gps1.IsButtonDown(Buttons.DPadRight)
                || gps2.ThumbSticks.Left.X > 0.5f || gps2.IsButtonDown(Buttons.DPadRight)
                || gps3.ThumbSticks.Left.X > 0.5f || gps3.IsButtonDown(Buttons.DPadRight)
                || gps4.ThumbSticks.Left.X > 0.5f || gps4.IsButtonDown(Buttons.DPadRight));

            bool YButtonHit = (gps1.IsButtonDown(Buttons.Y)
                 || gps2.IsButtonDown(Buttons.Y)
                 || gps3.IsButtonDown(Buttons.Y)
                 || gps4.IsButtonDown(Buttons.Y));

            // Player select readys
            if (!gps1.IsButtonDown(Buttons.Y))
            {
                SelectButtonOneReady = true;
            }
            if (!gps2.IsButtonDown(Buttons.Y))
            {
                SelectButtonTwoReady = true;
            }
            if (!gps3.IsButtonDown(Buttons.Y))
            {
                SelectButtonThreeReady = true;
            }
            if (!gps4.IsButtonDown(Buttons.Y))
            {
                SelectButtonFourReady = true;
            }

            if (!AButtonHit)
            {
                AButtonReady = true;
            }
            if (!BackButtonHit)
            {
                BackButtonReady = true;
            }
            if (!StartButtonHit)
            {
                StartButtonReady = true;
            }
            if (!BButtonHit)
            {
                BButtonReady = true;
            }
            if (!YButtonHit)
            {
                YButtonReady = true;
            }

            // Update highscores
            if (level != null)
            {
                // Update the highscore component
                level.hsc_.Update(gameTime);
            }

            switch (gameState)
            {
                case GameState.BadEggStudios:
                    {
                        if (BadEggStudiosTimer == 2500)
                        {
                            MediaPlayer.Play(MenuSong);
                        }

                        // Reduce the timer
                        if (!Guide.IsVisible)
                        {
                            BadEggStudiosTimer -= 16;
                        }

                        if (BadEggStudiosTimer < 0)
                        {
                            gameState = GameState.MainMenu;
                        }

                        // If there is no level loaded, load ALL the level data (AND HIGHSCORES)
                        if (level == null && BadEggStudiosTimer < 0)
                        {
                            // Initialize highscores
                            HighscoreComponent hsc = new HighscoreComponent(this, null, "Pew Pew Pod");
                            Components.Add(hsc);

                            level = new Level(Content);
                            level.LoadContent();
                            level.Initialize();
                        }
                        break;
                    }
                case GameState.Exit:
                    {
                        this.Exit();
                        break;
                    }
                case GameState.Extras:
                    {
                        // Color rotation
                        if (!MenuColor.Equals(Color.Yellow))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Yellow, ColorTransitionSpeed);
                        }

                        if (ExtrasPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (ExtrasPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (BButtonHit && BButtonReady)
                            {
                                BButtonReady = false;

                                MenuClickSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                                gameState = GameState.MainMenu;
                            }
                        }

                        if (Math.Abs(ExtrasPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-ExtrasPosition.X);
                        }

                        break;
                    }
                case GameState.Options:
                    {
                        // Color rotation
                        if (!MenuColor.Equals(Color.Purple))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Purple, ColorTransitionSpeed);
                        }

                        if (OptionsPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (OptionsPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (BButtonHit && BButtonReady)
                            {
                                BButtonReady = false;

                                MenuClickSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                                gameState = GameState.MainMenu;
                            }

                            if (BackButtonHit && BackButtonReady)
                            {
                                BackButtonReady = false;
                                level.hsc_.userWantsToLoad_ = true;
                                level.hsc_.storage_ = null;

                                data_ = new Highscore[10];
                                localScores_ = new Highscore[10];
                            }

                            if (DownButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (OptionsElementSelected)
                                {
                                    case "Music":
                                        {
                                            OptionsElementSelected = "SoundEffects";
                                            break;
                                        }
                                    case "SoundEffects":
                                        {
                                            OptionsElementSelected = "Rumble";
                                            break;
                                        }
                                    case "Rumble":
                                        {
                                            OptionsElementSelected = "Music";
                                            break;
                                        }
                                }

                                MenuTimer = 0;
                            }
                            else if (UpButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (OptionsElementSelected)
                                {
                                    case "Music":
                                        {
                                            OptionsElementSelected = "Rumble";
                                            break;
                                        }
                                    case "SoundEffects":
                                        {
                                            OptionsElementSelected = "Music";
                                            break;
                                        }
                                    case "Rumble":
                                        {
                                            OptionsElementSelected = "SoundEffects";
                                            break;
                                        }
                                }

                                MenuTimer = 0;
                            }

                            if (RightButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (OptionsElementSelected)
                                {
                                    case "Music":
                                        {
                                            MusicVolumeInt += 5;
                                            if (MusicVolumeInt > 100)
                                            {
                                                MusicVolumeInt = 100;
                                            }
                                            break;
                                        }
                                    case "SoundEffects":
                                        {
                                            SoundEffectVolumeInt += 5;
                                            if (SoundEffectVolumeInt > 100)
                                            {
                                                SoundEffectVolumeInt = 100;
                                            }
                                            break;
                                        }
                                    case "Rumble":
                                        {
                                            IsRumbleOn = !IsRumbleOn;
                                            break;
                                        }
                                }

                                MenuTimer = 0;
                            }
                            else if (LeftButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (OptionsElementSelected)
                                {
                                    case "Music":
                                        {
                                            MusicVolumeInt -= 5;
                                            if (MusicVolumeInt < 0)
                                            {
                                                MusicVolumeInt = 0;
                                            }
                                            break;
                                        }
                                    case "SoundEffects":
                                        {
                                            SoundEffectVolumeInt -= 5;
                                            if (SoundEffectVolumeInt < 0)
                                            {
                                                SoundEffectVolumeInt = 0;
                                            }
                                            break;
                                        }
                                    case "Rumble":
                                        {
                                            IsRumbleOn = !IsRumbleOn;
                                            break;
                                        }
                                }

                                MenuTimer = 0;
                            }
                        }

                        if (Math.Abs(OptionsPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-OptionsPosition.X);
                        }

                        // Set sounds
                        MusicVolume = ((float)MusicVolumeInt) / 100.0f;
                        SoundEffectVolume = ((float)SoundEffectVolumeInt) / 100.0f;

                        break;
                    }
                case GameState.Highscores:
                    {
                        // Color rotation
                        if (!MenuColor.Equals(Color.Green))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Green, ColorTransitionSpeed);
                        }

                        if (HighscoresPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (HighscoresPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (BButtonHit && BButtonReady)
                            {
                                BButtonReady = false;

                                MenuClickSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                                gameState = GameState.MainMenu;
                            }

                            // Rotate highscores
                            if (AButtonHit && AButtonReady)
                            {
                                AButtonReady = false;

                                switch (HighscoresElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            HighscoresElementSelected = "Survival";
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            HighscoresElementSelected = "Zones";
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            HighscoresElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            HighscoresElementSelected = "ThinkFast";
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            HighscoresElementSelected = "Arcade";
                                            break;
                                        }
                                }
                            }

                            // Choose storage
                            if (BackButtonHit && BackButtonReady)
                            {
                                level.hsc_.userWantsToLoad_ = true;
                                BackButtonReady = false;
                            }
                        }

                        if (Math.Abs(HighscoresPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-HighscoresPosition.X);
                        }

                        if (!HighscoresElementSelected.Equals("Waypoint"))
                        {
                            RebuildLocalHighscores(HighscoresElementSelected);
                            RebuildHighscores(HighscoresElementSelected);
                        }
                        else
                        {
                            RebuildLocalHighscores("Travel");
                            RebuildHighscores("Travel");
                        }

                        break;
                    }
                case GameState.MainMenu:
                    {
                        // Color rotation
                        if (LastColor.Equals(Color.Green))
                        {
                            if (!MenuColor.Equals(Color.Turquoise))
                            {
                                MenuColor = Color.Lerp(Color.Green, Color.Turquoise, ColorPulseAmount);
                                ColorPulseAmount += ColorPulseSpeed;
                            }
                            else
                            {
                                LastColor = Color.Turquoise;
                                ColorPulseAmount = 0;
                            }
                        }
                        else if (LastColor.Equals(Color.Turquoise))
                        {
                            if (!MenuColor.Equals(Color.Red))
                            {
                                MenuColor = Color.Lerp(Color.Turquoise, Color.Red, ColorPulseAmount);
                                ColorPulseAmount += ColorPulseSpeed;
                            }
                            else
                            {
                                LastColor = Color.Red;
                                ColorPulseAmount = 0;
                            }
                        }
                        else if (LastColor.Equals(Color.Red))
                        {
                            if (!MenuColor.Equals(Color.Yellow))
                            {
                                MenuColor = Color.Lerp(Color.Red, Color.Yellow, ColorPulseAmount);
                                ColorPulseAmount += ColorPulseSpeed;
                            }
                            else
                            {
                                LastColor = Color.Yellow;
                                ColorPulseAmount = 0;
                            }
                        }
                        if (LastColor.Equals(Color.Yellow))
                        {
                            if (!MenuColor.Equals(Color.Green))
                            {
                                MenuColor = Color.Lerp(Color.Yellow, Color.Green, ColorPulseAmount);
                                ColorPulseAmount += ColorPulseSpeed;
                            }
                            else
                            {
                                LastColor = Color.Green;
                                ColorPulseAmount = 0;
                            }
                        }

                        if (MainMenuPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (MainMenuPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (AButtonHit && AButtonReady)
                            {
                                AButtonReady = false;

                                MenuClickSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                                switch (MenuElementSelected)
                                {
                                    case "Play":
                                        {
                                            gameState = GameState.GameSelect;

                                            // Change the selected element
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                    case "Highscores":
                                        {
                                            gameState = GameState.Highscores;
                                            break;
                                        }
                                    case "Options":
                                        {
                                            gameState = GameState.Options;
                                            break;
                                        }
                                    case "Extras":
                                        {
                                            gameState = GameState.Extras;
                                            break;
                                        }
                                    case "Exit":
                                        {
                                            gameState = GameState.Exit;
                                            break;
                                        }
                                }
                            }

                            // Are we trying to buy the game?
                            if (gps1.IsButtonDown(Buttons.X))
                            {
                                if (CanPlayerBuyGame(PlayerIndex.One))
                                {
                                    Guide.ShowMarketplace(PlayerIndex.One);
                                }
                                else
                                {
                                    SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                        "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                        new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                }
                            }
                            else if (gps2.IsButtonDown(Buttons.X))
                            {
                                if (CanPlayerBuyGame(PlayerIndex.Two))
                                {
                                    Guide.ShowMarketplace(PlayerIndex.Two);
                                }
                                else
                                {
                                    SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                        "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                        new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                }
                            }
                            else if (gps3.IsButtonDown(Buttons.X))
                            {
                                if (CanPlayerBuyGame(PlayerIndex.Three))
                                {
                                    Guide.ShowMarketplace(PlayerIndex.Three);
                                }
                                else
                                {
                                    SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                        "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                        new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                }
                            }
                            else if (gps4.IsButtonDown(Buttons.X))
                            {
                                if (CanPlayerBuyGame(PlayerIndex.Four))
                                {
                                    Guide.ShowMarketplace(PlayerIndex.Four);
                                }
                                else
                                {
                                    SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                        "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                        new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                }
                            }

                            // Highscores
                            if (BackButtonHit && BackButtonReady)
                            {
                                level.hsc_.userWantsToLoad_ = true;
                                BackButtonReady = false;
                            }
                        }

                        if (Math.Abs(MainMenuPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-MainMenuPosition.X);
                        }

                        // Menu selection
                        if (UpButtonHit && MenuTimer > ChangeElementTime)
                        {
                            switch (MenuElementSelected)
                            {
                                case "Play":
                                    {
                                        MenuElementSelected = "Exit";
                                        break;
                                    }
                                case "Highscores":
                                    {
                                        MenuElementSelected = "Play";
                                        break;
                                    }
                                case "Options":
                                    {
                                        MenuElementSelected = "Highscores";
                                        break;
                                    }
                                case "Extras":
                                    {
                                        MenuElementSelected = "Options";
                                        break;
                                    }
                                case "Exit":
                                    {
                                        MenuElementSelected = "Extras";
                                        break;
                                    }
                            }

                            MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                            MenuTimer = 0;
                        }
                        else if (DownButtonHit && MenuTimer > ChangeElementTime)
                        {
                            switch (MenuElementSelected)
                            {
                                case "Play":
                                    {
                                        MenuElementSelected = "Highscores";
                                        break;
                                    }
                                case "Highscores":
                                    {
                                        MenuElementSelected = "Options";
                                        break;
                                    }
                                case "Options":
                                    {
                                        MenuElementSelected = "Extras";
                                        break;
                                    }
                                case "Extras":
                                    {
                                        MenuElementSelected = "Exit";
                                        break;
                                    }
                                case "Exit":
                                    {
                                        MenuElementSelected = "Play";
                                        break;
                                    }
                            }

                            MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);

                            MenuTimer = 0;
                        }

                        break;
                    }
                case GameState.GameSelect:
                    {
                        if (!MenuColor.Equals(Color.Turquoise))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Turquoise, ColorTransitionSpeed);
                        }

                        if (GameSelectPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (GameSelectPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (BButtonHit && BButtonReady)
                            {
                                gameState = GameState.MainMenu;
                                BButtonReady = false;

                                // Change selected Element
                                MenuElementSelected = "Play";
                            }

                            if (AButtonHit && AButtonReady)
                            {
                                gameState = GameState.PlayerSelect;
                                AButtonReady = false;

                                // Reset player selects
                                PlayerOneChosen = false;
                                PlayerTwoChosen = false;
                                PlayerThreeChosen = false;
                                PlayerFourChosen = false;

                                // Choose the matchtype
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            gameType = Level.MatchType.Arcade;
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            gameType = Level.MatchType.Survival;
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            gameType = Level.MatchType.Zones;
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            gameType = Level.MatchType.Travel;
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            gameType = Level.MatchType.ThinkFast;
                                            break;
                                        }
                                    case "Versus":
                                        {
                                            gameType = Level.MatchType.Versus;
                                            break;
                                        }
                                }

                                MenuClickSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                        }

                        if (Math.Abs(GameSelectPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-GameSelectPosition.X);
                        }

                        // Menu Selection
                        if (!Guide.IsTrialMode)
                        {
                            if (LeftButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Zones";
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            GameElementSelected = "Survival";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "Versus";
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Versus":
                                        {
                                            GameElementSelected = "ThinkFast";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                            else if (RightButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Survival";
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            GameElementSelected = "Zones";
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "ThinkFast";
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            GameElementSelected = "Versus";
                                            break;
                                        }
                                    case "Versus":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                            else if (UpButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            GameElementSelected = "ThinkFast";
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            GameElementSelected = "Versus";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            GameElementSelected = "Survival";
                                            break;
                                        }
                                    case "Versus":
                                        {
                                            GameElementSelected = "Zones";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                            else if (DownButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Survival":
                                        {
                                            GameElementSelected = "ThinkFast";
                                            break;
                                        }
                                    case "Zones":
                                        {
                                            GameElementSelected = "Versus";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                    case "ThinkFast":
                                        {
                                            GameElementSelected = "Survival";
                                            break;
                                        }
                                    case "Versus":
                                        {
                                            GameElementSelected = "Zones";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                        }
                        else
                        {
                            if (DownButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                            else if (UpButtonHit && MenuTimer > ChangeElementTime)
                            {
                                switch (GameElementSelected)
                                {
                                    case "Arcade":
                                        {
                                            GameElementSelected = "Waypoint";
                                            break;
                                        }
                                    case "Waypoint":
                                        {
                                            GameElementSelected = "Arcade";
                                            break;
                                        }
                                }

                                MenuTimer = 0;

                                MenuScrollSound.Play(Game1.Global.SoundEffectVolume, 0, 0);
                            }
                        }

                        break;
                    }
                case GameState.PlayerSelect:
                    {
                        PlayerSelect(gameTime);
                        // level = null;

                        if (!MenuColor.Equals(Color.Red))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Red, ColorTransitionSpeed);
                        }

                        if (PlayerSelectPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (PlayerSelectPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (BButtonHit && BButtonReady)
                            {
                                gameState = GameState.GameSelect;
                                BButtonReady = false;
                            }
                        }

                        if (Math.Abs(PlayerSelectPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-PlayerSelectPosition.X);
                        }
                        break;
                    }

                case GameState.Loading:
                    {
                        // Make a new level
                        if (level == null)
                        {
                            level = new Level(Content);
                        }

                        if (GameStartFade < 1.0f)
                        {
                            GameStartFade += 0.05f;
                        }
                        else
                        {
                            gameState = GameState.Level;
                            GameStartFade = 0;
                        }
                        break;
                    }
                case GameState.StartLevel:
                    {
                        // Holds the player indexes ingame
                        List<PlayerIndex> pi = new List<PlayerIndex>();

                        // If we haven't started a game, start a single player one
                        if (PlayerOneChosen)
                        {
                            pi.Add(PlayerIndex.One);
                        }
                        if (PlayerTwoChosen)
                        {
                            pi.Add(PlayerIndex.Two);
                        }
                        if (PlayerThreeChosen)
                        {
                            pi.Add(PlayerIndex.Three);
                        }
                        if (PlayerFourChosen)
                        {
                            pi.Add(PlayerIndex.Four);
                        }

                        if (gameType.Equals(Level.MatchType.Versus))
                        {
                            if (pi.Count >= 2)
                            {
                                level.StartMatch(Level.MatchType.Versus, pi);
                            }
                            else
                            {
                                gameState = GameState.PlayerSelect;
                            }
                        }
                        else if (gameType.Equals(Level.MatchType.Arcade))
                        {
                            level.StartMatch(Level.MatchType.Arcade, pi);
                        }
                        else if (gameType.Equals(Level.MatchType.Zones))
                        {
                            level.StartMatch(Level.MatchType.Zones, pi);
                        }
                        else if (gameType.Equals(Level.MatchType.Travel))
                        {
                            level.StartMatch(Level.MatchType.Travel, pi);
                        }
                        else if (gameType.Equals(Level.MatchType.Survival))
                        {
                            level.StartMatch(Level.MatchType.Survival, pi);
                        }
                        else if (gameType.Equals(Level.MatchType.ThinkFast))
                        {
                            level.StartMatch(Level.MatchType.ThinkFast, pi);
                        }

                        gameState = GameState.Loading;
                        break;
                    }
                case GameState.GameModeTutorial:
                    {
                        if (!MenuColor.Equals(Color.Red))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Red, ColorTransitionSpeed);
                        }

                        if (GameModeTutorialPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (GameModeTutorialPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (AButtonHit && AButtonReady)
                            {
                                gameState = GameState.StartLevel;
                                AButtonReady = false;
                            }

                            if (BButtonHit && BButtonReady)
                            {
                                gameState = GameState.PlayerSelect;
                                BButtonReady = false;
                            }

                            if (RightButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.PlayerTutorial;
                                MenuTimer = 0;
                            }
                        }

                        if (Math.Abs(GameModeTutorialPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-GameModeTutorialPosition.X);
                        }
                        break;
                    }
                case GameState.PlayerTutorial:
                    {
                        if (!MenuColor.Equals(Color.Red))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Red, ColorTransitionSpeed);
                        }

                        if (PlayerTutorialPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (PlayerTutorialPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (AButtonHit && AButtonReady)
                            {
                                gameState = GameState.StartLevel;
                                AButtonReady = false;
                            }

                            if (BButtonHit && BButtonReady)
                            {
                                gameState = GameState.PlayerSelect;
                                BButtonReady = false;
                            }

                            if (RightButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.EnemyTutorial;
                                MenuTimer = 0;
                            }
                            else if (LeftButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.GameModeTutorial;
                                MenuTimer = 0;
                            }
                        }

                        if (Math.Abs(PlayerTutorialPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-PlayerTutorialPosition.X);
                        }
                        break;
                    }
                case GameState.EnemyTutorial:
                    {
                        if (!MenuColor.Equals(Color.Red))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Red, ColorTransitionSpeed);
                        }

                        if (EnemyTutorialPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (EnemyTutorialPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (AButtonHit && AButtonReady)
                            {
                                gameState = GameState.StartLevel;
                                YButtonReady = false;
                            }

                            if (BButtonHit && BButtonReady)
                            {
                                gameState = GameState.PlayerSelect;
                                BButtonReady = false;
                            }

                            if (RightButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.ControlsTutorial;
                                MenuTimer = 0;
                            }
                            else if (LeftButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.PlayerTutorial;
                                MenuTimer = 0;
                            }
                        }

                        if (Math.Abs(EnemyTutorialPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-EnemyTutorialPosition.X);
                        }
                        break;
                    }
                case GameState.ControlsTutorial:
                    {
                        if (!MenuColor.Equals(Color.Red))
                        {
                            MenuColor = Color.Lerp(MenuColor, Color.Red, ColorTransitionSpeed);
                        }

                        if (BButtonHit && BButtonReady)
                        {
                            gameState = GameState.PlayerSelect;
                            BButtonReady = false;
                        }

                        if (ControlsTutorialPosition.X < 0)
                        {
                            MoveMenus(SlideSpeed);
                        }
                        else if (ControlsTutorialPosition.X > 0)
                        {
                            MoveMenus(-SlideSpeed);
                        }
                        else
                        {
                            if (AButtonHit && AButtonReady)
                            {
                                gameState = GameState.StartLevel;
                                AButtonReady = false;
                            }

                            if (LeftButtonHit && MenuTimer > ChangeElementTime)
                            {
                                gameState = GameState.EnemyTutorial;
                                MenuTimer = 0;
                            }
                        }

                        if (Math.Abs(ControlsTutorialPosition.X) < SlideSpeed)
                        {
                            MoveMenus(-ControlsTutorialPosition.X);
                        }
                        break;
                    }
                case GameState.Level:
                    {
                        if (!Guide.IsVisible)
                        {
                            level.Update(gameTime);

                            if (level.ReturnToMenu && level.BackgroundFade > 0.9f)
                            {
                                gameState = GameState.MainMenu;
                                MediaPlayer.Play(MenuSong);
                            }

                            if (level.GameOver && (level.Particles.Count <= 0 || level.ScoreSubmitted))
                            {
                                // Are we trying to buy the game?
                                if (gps1.IsButtonDown(Buttons.X))
                                {
                                    if (CanPlayerBuyGame(PlayerIndex.One))
                                    {
                                        Guide.ShowMarketplace(PlayerIndex.One);
                                    }
                                    else
                                    {
                                        SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                            "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                            new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                    }
                                }
                                else if (gps2.IsButtonDown(Buttons.X))
                                {
                                    if (CanPlayerBuyGame(PlayerIndex.Two))
                                    {
                                        Guide.ShowMarketplace(PlayerIndex.Two);
                                    }
                                    else
                                    {
                                        SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                            "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                            new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                    }
                                }
                                else if (gps3.IsButtonDown(Buttons.X))
                                {
                                    if (CanPlayerBuyGame(PlayerIndex.Three))
                                    {
                                        Guide.ShowMarketplace(PlayerIndex.Three);
                                    }
                                    else
                                    {
                                        SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                            "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                            new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                    }
                                }
                                else if (gps4.IsButtonDown(Buttons.X))
                                {
                                    if (CanPlayerBuyGame(PlayerIndex.Four))
                                    {
                                        Guide.ShowMarketplace(PlayerIndex.Four);
                                    }
                                    else
                                    {
                                        SimpleMessageBox.ShowMessageBox("Purchase Pew Pew Pod",
                                            "You must be logged into a profile that has purchasing priviledges in order to buy Pew Pew Pod. Please try again with a different profile.",
                                            new string[] { "Ok" }, 0, MessageBoxIcon.Warning);
                                    }
                                }
                            }
                        }
                        break;
                    }
                case GameState.Paused:
                    {
                        UpdatePause(gameTime);
                        break;
                    }
            }

            // If we are in a menu, update the planets
            if (gameState.Equals(GameState.MainMenu)
                || gameState.Equals(GameState.PlayerSelect)
                || gameState.Equals(GameState.GameSelect)
                || gameState.Equals(GameState.ControlsTutorial)
                || gameState.Equals(GameState.EnemyTutorial)
                || gameState.Equals(GameState.Extras)
                || gameState.Equals(GameState.GameModeTutorial)
                || gameState.Equals(GameState.Highscores)
                || gameState.Equals(GameState.Options)
                || gameState.Equals(GameState.PlayerTutorial)
                || gameState.Equals(GameState.StartLevel)
                || gameState.Equals(GameState.Loading))
            {
                foreach (Particle p in Planets)
                {
                    p.Update(gameTime);
                }

                foreach (BackgroundStar s in Layer1)
                {
                    s.Update();
                }
            }

            // If the guide is open, pause the music
            if ((Guide.IsVisible || gameState.Equals(GameState.Paused)) && MediaPlayer.State.Equals(MediaState.Playing))
            {
                MediaPlayer.Pause();
            }
            else if ((!Guide.IsVisible && !gameState.Equals(GameState.Paused)) && MediaPlayer.State.Equals(MediaState.Paused))
            {
                MediaPlayer.Resume();
            }

            if (level != null && gameState.Equals(GameState.MainMenu) && HighscoreComponent.Global.Enabled == false)
            {
                HighscoreComponent.Global.Enabled = true;
                System.Diagnostics.Trace.WriteLine("Switched highscores to on, because they were off.");
            }

            // Do not rumble controllers if we aren't in a level, or we turned rumble off
            if (!gameState.Equals(GameState.Level))
            {
                GamePad.SetVibration(PlayerIndex.One, 0, 0);
                GamePad.SetVibration(PlayerIndex.Two, 0, 0);
                GamePad.SetVibration(PlayerIndex.Three, 0, 0);
                GamePad.SetVibration(PlayerIndex.Four, 0, 0);
            }

            base.Update(gameTime);
        }
Example #5
0
        public Pod(PlayerIndex playerIndex, Level level)
        {
            this.PlayerIndex = playerIndex;
            this.level = level;

            Initialize();
        }
Example #6
0
        public Level(ContentManager content)
        {
            this.Content = content;

            matchType = MatchType.None;

            // Set this level equal to this level
            Global = this;
        }