Exemplo n.º 1
0
 protected override void LoadContent()
 {
     MediaPlayer.Volume = 0.5f;
     SoundManager.InitSoundLists();
     background.Load(Content);
     cameraX      = 400;
     Camera.Scale = 1f;
     globalSounds.load(Content);
     magzzz.initializeAmmo();
     spriteBatch = new SpriteBatch(GraphicsDevice);
     spriteFont  = Content.Load <SpriteFont>("MyFont");
     CharactersHandler.InitList();
     MenusHandler.load(Content, this, Camera);
     TesteMapa = new Map();
     TesteMapa.Load(Content);
     GhostCharacter = CharactersHandler.getCharacter(5);
     //////mudar esta posicao para a posicao do menu!\\\\\\\\\\\\\\\\\
     GhostCharacter.SetCharacterPosition(new Vector2(cameraX, 350));
     CharactersHandler.AddPlayer(GhostCharacter);
     Camera.Focus = CharactersHandler.Players[0];
     GhostCharacter.Load(Content);
     Interface.load(Content);
 }
Exemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Camera.Transform);

            if (gameState != GameState.running && gameState != GameState.Paused && gameState != GameState.Win && gameState != GameState.CharacterChangeScene)
            {
                MenusHandler.draw(spriteBatch, this, GhostCharacter, Camera);
            }
            else
            {
                background.Draw(spriteBatch);
                TesteMapa.secondDraw(spriteBatch);
                CharactersHandler.DrawPlayers(spriteBatch);
                Interface.draw(spriteBatch, Camera, CharactersHandler.getActiveCharacter());
                if (gameState == GameState.Paused || gameState == GameState.Win || gameState == GameState.CharacterChangeScene)
                {
                    MenusHandler.draw(spriteBatch, this, CharactersHandler.getActiveCharacter(), Camera);
                }
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 3
0
        protected override void Update(GameTime gameTime)
        {
            Input.Update();
            background.Update(gameTime);

            //desenha os menus que nao sao ingame
            //se nao esta in game ou nao existe vencedor
            if (gameState != GameState.running && gameState != GameState.Win && gameState != GameState.CharacterChangeScene)
            {
                if (playonce2 == false && gameState != GameState.Paused)
                {
                    SoundManager.playMusic("menuMusic");
                    playonce2 = true;
                    playonce  = false;
                }
                MenusHandler.Update(gameTime, this, Content, Camera, Interface);
                if (gameState != GameState.Paused)
                {
                    cameraX         = 400;
                    Camera.Position = new Vector2(cameraX, 350);
                    Camera.Scale    = 1f;
                }
            }

            //se tiver in game!!!

            else
            {
                if (gameState == GameState.Win || gameState == GameState.CharacterChangeScene)
                {
                    MenusHandler.Update(gameTime, this, Content, Camera, Interface);
                }
                else
                {
                    if (playonce == false)
                    {
                        SoundManager.playMusic("ingameMusic");
                        playonce  = true;
                        playonce2 = false;
                    }
                    Interface.update(gameTime);
                    Camera.Scale = 0.7f;
                    TesteMapa.update(gameTime);

                    if (Keyboard.GetState().IsKeyDown(Keys.Escape) && gameState == GameState.running)
                    {
                        gameState = GameState.Paused;
                    }

                    if (Input.IsPressed(Keys.K) && Collisions.bulletsOnScreen.Count == 0 && !CharactersHandler.isWinner())
                    {
                        gameState             = GameState.CharacterChangeScene;
                        Characters.weaponUsed = false;
                        SoundManager.playSound("FX001");
                    }

                    if (hud.roundTime <= 0 && Collisions.bulletsOnScreen.Count == 0)
                    {
                        gameState             = GameState.CharacterChangeScene;
                        Characters.weaponUsed = false;
                        SoundManager.playSound("FX001");
                        if (CharactersHandler.isWinner())
                        {
                            SoundManager.playSound("FX052");
                            gameState = GameState.Win;
                            MenusHandler.winMenu.loadInGame(Camera);
                            auxMapa = false;
                        }
                    }
                    if (CharactersHandler.isWinner())
                    {
                        cameraX = (int)CharactersHandler.getWinner().CharacterPosition().X;
                    }

                    if (Input.IsDown(Keys.Right) && cameraX < 2210 && gameState == GameState.running && !CharactersHandler.isWinner())
                    {
                        cameraX += 10;
                    }
                    if (Input.IsDown(Keys.Left) && cameraX > 370 && gameState == GameState.running && !CharactersHandler.isWinner())
                    {
                        cameraX -= 10;
                    }


                    GhostCharacter.SetCharacterPosition(new Vector2(cameraX, 350));
                    CharactersHandler.updatePlayers(gameTime);
                }
            }


            //Console.WriteLine("X:{0}   Y:{1}", CharactersHandler.getActiveCharacterRectangle().X, CharactersHandler.getActiveCharacterRectangle().Y);
            base.Update(gameTime);
        }