Example #1
0
 private void levelComplete()
 {
     currentLevel.stopBGM();
     currentLevelIndex++;
     if (currentLevelIndex == levelFileList.Length)
     {
         gamestate         = PGameState.Title;
         currentLevelIndex = 0;
     }
     else
     {
         gamestate = PGameState.IntroScrn;
     }
     UnloadContent();
     LoadContent();
 }
Example #2
0
        private void processDeath()
        {
            Console.WriteLine(player.Plives);
            player.Plives -= 1;
            //used to set lives to correct value after reset
            float lives = player.Plives;

            if (player.Plives <= 0)
            {
                currentLevel.stopBGM();
                gamestate         = PGameState.Title;
                currentLevelIndex = 0;
                UnloadContent();
                LoadContent();
            }
            else
            {
                UnloadContent();
                LoadContent();
                player.Plives = lives;
                currentLevel.playBGM();
            }
        }
Example #3
0
        //CONSTRUCTOR
        public Pgame()
        {
            //Initialize graphics object and content directory
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //Set initial screen paramaters
            Vector2 res = LevelReader.readResolution("settings.txt");

            startingwidth  = (int)res.X;
            startingheight = (int)res.Y;
            //Console.Out.WriteLine(startingwidth + " " + startingheight);
            startfullscreen  = LevelReader.readFullScreen("settings.txt");
            volume           = LevelReader.readVolume("settings.txt");
            bgmvolume        = LevelReader.readBGMVolume("settings.txt");
            gamepadConnected = LevelReader.readGamepadSetting("settings.txt");

            graphics.PreferredBackBufferHeight = startingheight;
            graphics.PreferredBackBufferWidth  = startingwidth;
            //this.lastscale = 1;
            //this.currentscale = 1;
            graphics.IsFullScreen = startfullscreen;

            screenRect        = new Rectangle();
            screenRect.X      = 0;
            screenRect.Y      = 0;
            screenRect.Width  = startingwidth;
            screenRect.Height = startingheight;

            //Init attacks;
            pAttacks = new ArrayList();

            gamestate = PGameState.Title;

            //Set initial player, level position
            //levelloc = Vector2.Zero;
        }
Example #4
0
        private void processGamepadInput()
        {
            //Current Keyboard state
            KeyboardState keys = Keyboard.GetState();

            PCgamepad.MyGamePadState pad     = PCgamepad.GetState(PlayerIndex.One);
            GamePadState             xboxpad = GamePad.GetState(PlayerIndex.One);

            if (gamestate == PGameState.Game)
            {
                // Allows the game to exit manually
                if (xboxpad.Buttons.Back == ButtonState.Pressed ||
                    keys.IsKeyDown(Keys.Escape) ||
                    pad.Buttons.Select == ButtonState.Pressed)
                {
                    UnloadContent();
                    this.Exit();
                }

                //Movement processing section
                if (keys.IsKeyDown(Keys.Right) || xboxpad.DPad.Right == ButtonState.Pressed ||
                    pad.DPad.Right == ButtonState.Pressed)
                {
                    player.rightPressed();
                }
                else if (keys.IsKeyDown(Keys.Left) || xboxpad.DPad.Left == ButtonState.Pressed ||
                         pad.DPad.Left == ButtonState.Pressed)
                {
                    player.leftPressed();
                }
                else
                {
                    player.moveNotPressed();
                }

                //Jump processing section
                if (keys.IsKeyDown(Keys.Space) || xboxpad.Buttons.A == ButtonState.Pressed ||
                    pad.Buttons.Cross == ButtonState.Pressed)
                {
                    player.jumpPressed();
                }
                else
                {
                    player.jumpNotPressed();
                }

                //Attack processing section
                if (keys.IsKeyDown(Keys.Z) || xboxpad.Buttons.X == ButtonState.Pressed ||
                    pad.Buttons.Square == ButtonState.Pressed)
                {
                    Psprite attack = player.attackPressed();
                    if (attack != null)
                    {
                        pAttacks.Add(attack);
                    }
                }
                //Weapon switch
                if (keys.IsKeyDown(Keys.X) || xboxpad.Buttons.Y == ButtonState.Pressed ||
                    pad.Buttons.Triangle == ButtonState.Pressed)
                {
                    if (!yPressed)
                    {
                        if (player.cWeapon == Player.Weapon.EnergyShot)
                        {
                            player.cWeapon = Player.Weapon.Pyrokinesis;
                        }
                        else if (player.cWeapon == Player.Weapon.Pyrokinesis)
                        {
                            player.cWeapon = Player.Weapon.EnergyShot;
                        }
                    }
                    yPressed = true;
                }
                else
                {
                    yPressed = false;
                }

                //Screen Resize Block
                if (keys.IsKeyDown(Keys.F1))
                {
                    scaleScreen(800, 600, false);
                }
                else if (keys.IsKeyDown(Keys.F2))
                {
                    scaleScreen(1024, 768, false);
                }
                else if (keys.IsKeyDown(Keys.F3))
                {
                    scaleScreen(640, 480, false);
                }
                else if (keys.IsKeyDown(Keys.F4))
                {
                    scaleScreen(1680, 1050, true);
                }
            }
            else if (gamestate == PGameState.IntroScrn)
            {
                currentLevel.playIntroBGM();
                if (pad.Buttons.Start == ButtonState.Pressed)
                {
                    startPressed = true;
                }
                else if (startPressed)
                {
                    startPressed = false;
                    gamestate    = PGameState.Game;
                    currentLevel.playBGM();
                }
            }
            else if (gamestate == PGameState.Title)
            {
                if (pad.Buttons.Start == ButtonState.Pressed)
                {
                    startPressed = true;
                }
                else if (startPressed)
                {
                    startPressed = false;
                    gamestate    = PGameState.IntroScrn;
                }
            }
        }