Пример #1
0
        public void Update(Game game,ContentManager content, SpriteBatch spriteBatch, SpriteFont font, Player playerOne, List<Sprite> enemies, EnemyShots enemyShots, PlayerShots playerShots, List<Sprite> randomObjects, List<HealthBar> healthBars, Sprite playerOneSprite, GraphicsDeviceManager graphics, Player playerTwo = null, Sprite playerTwoSprite = null)
        {
            this.enemies = enemies;
            this.enemyShots = enemyShots;
            this.playerShots = playerShots;
            this.playerOneSprite = playerOneSprite;
            this.dinosaurOne = playerOne;
            this.playerTwoSprite = playerTwoSprite;
            this.dinosaurTwo = playerTwo;
            _halfScreenHeight = graphics.PreferredBackBufferHeight / 1.5f;

            gdm = graphics;
            sb = spriteBatch;
            cm = content;

            explosionSound = cm.Load<SoundEffect>("Sounds/explosion");
            laserPowerupSound = cm.Load<SoundEffect>("Sounds/Few");
            healthPowerupSound = cm.Load<SoundEffect>("Sounds/Few");
            enemyHit = cm.Load<SoundEffect>("Sounds/Few");
            playerHit = cm.Load<SoundEffect>("sounds/Punch");

            if (!playerOneSprite.IsInvincible)
            {
                CheckIfEnemyHitsPlayer();
            }

            CheckIfPowerupHitsPlayer();

            CheckIfPlayerHitSomething(game, spriteBatch, content, healthBars);

            checkIfPlayerIsHitByGroundItem(randomObjects);
        }
Пример #2
0
        public PlayerShots(ContentManager content, Player dinoOne, Sprite playerOneSprite, Player dinoTwo = null, Sprite playerTwoSprite = null)
        {
            shotsOne = new List<Vector2>();
            playerOneShotImage = content.Load<Texture2D>("Images/laserPurple");
            playerShot = content.Load<SoundEffect>("Sounds/laser");
            dinosaurOne = dinoOne;
            playerOne = playerOneSprite;

            if (dinoTwo != null && playerTwoSprite != null)
            {
                shotsTwo = new List<Vector2>();
                playerTwoShotImage = content.Load<Texture2D>("Images/laserBlue");
                dinosaurTwo = dinoTwo;
                playerTwo = playerTwoSprite;
            }
        }
Пример #3
0
        public void FireOne(Player dinosaur)
        {
            if (dinosaur.LasersPowerLevel == 1)
            {
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * 4);
            }

            else if (dinosaur.LasersPowerLevel == 2)
            {
                if (dinosaur.dinoChosen == Player.Chara.Ptera)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 - 40));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 + 20));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Trex)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 - 10));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 + 20));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Cera)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 - 10));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 + 12));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Bronto)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 5));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 5));
                }
            }

            else if (dinosaur.LasersPowerLevel == 3)
            {
                if (dinosaur.dinoChosen == Player.Chara.Ptera)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 - 43));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 + 17));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 - 37));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 30 - Vector2.UnitX * (4 + 23));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Trex)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 - 7));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 + 17));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 - 13));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 45 - Vector2.UnitX * (4 + 23));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Cera)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 - 7));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 + 9));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 - 13));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 85 - Vector2.UnitX * (4 + 15));
                }
                else if (dinosaur.dinoChosen == Player.Chara.Bronto)
                {
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 8));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 8));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 2));
                    shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 2));
                }
            }

            else if (dinosaur.LasersPowerLevel == 4)
            {
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 40 - Vector2.UnitX * 50);
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 40 + Vector2.UnitX * 40);
                shotsOne.Add(playerOne.Position - Vector2.UnitY * (100 - 80) - Vector2.UnitX * (4 - 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * (100 - 80) - Vector2.UnitX * (4 + 20));
            }

            else if (dinosaur.LasersPowerLevel == 5)
            {
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 40 - Vector2.UnitX * 50);
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 40 + Vector2.UnitX * 40);
                shotsOne.Add(playerOne.Position - Vector2.UnitY * (100 - 80) - Vector2.UnitX * (4 - 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * (100 - 80) - Vector2.UnitX * (4 + 20));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 - 40));
                shotsOne.Add(playerOne.Position - Vector2.UnitY * 100 - Vector2.UnitX * (4 + 40));
            }

            playerShot.Play();
        }
Пример #4
0
        private Vector2 hardAIMovement(GraphicsDeviceManager graphics, Vector2 position, Vector2 movement, float speed ,Sprite playerOneSprite, Sprite playerTwoSprite = null, Player one = null, Player two = null)
        {
            if (playerTwoSprite == null)
            {
                TargetPlayerOne = true;
            }
            if (TargetPlayerOne)
            {
                if (position.X > playerOneSprite.Position.X + 10 && position.X < graphics.PreferredBackBufferWidth)
                {
                    movement.X = -speed;
                }
                else if (position.X < playerOneSprite.Position.X - 10 && position.X > 0)
                {
                    movement.X = speed;
                }

                if (one.Health == 0 && playerTwoSprite != null)
                {
                    TargetPlayerOne = false;
                }
            }
            else
            {
                if (playerTwoSprite != null)
                {
                    if (position.X > playerTwoSprite.Position.X + 10 && position.X < graphics.PreferredBackBufferWidth)
                    {
                        movement.X = -speed;
                    }
                    else if (position.X < playerTwoSprite.Position.X - 10 && position.X > 0)
                    {
                        movement.X = speed;
                    }

                    if (two.Health == 0)
                    {
                        TargetPlayerOne = true;
                    }
                }
            }

            return movement;
        }
Пример #5
0
        public Vector2 Update(EnemyType enemyType, Vector2 position, Vector2 movement, GraphicsDeviceManager graphics, Sprite playerOneSprite, Sprite playerTwoSprite = null, Player one = null, Player two = null)
        {
            Vector2 AIMovement = Vector2.Zero;

            if (enemyType.type == Etype.Simple)
            {
                AIMovement = simpleAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Gunner)
            {
                AIMovement = gunnerAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Bomber)
            {
                AIMovement = bomberAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Darting)
            {
                AIMovement = dartingAIMovement(graphics, position, movement);
            }
            else if (type == Etype.Blinking)
            {
                // update ai
                AIMovement = createBlinking(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Hard)
            {
                AIMovement = hardAIMovement(graphics, position, movement, enemyType.speed, playerOneSprite, playerTwoSprite, one, two);
            }
            else if (type == Etype.Level1MidBoss)
            {
                // update ai
                AIMovement = createLevel1MidBoss(graphics, position, movement);
            }
            else if (type == Etype.Level1Boss)
            {
                AIMovement = createLevel1Boss(graphics, position, movement);
            }
            else if (type == Etype.Level2MidBoss)
            {
                AIMovement = createLevel2MidBoss(graphics, position, movement);
            }
            else if (type == Etype.Level3Boss)
            {
                AIMovement = createLevel3Boss(graphics, position, movement);
            }
            return AIMovement;
        }
Пример #6
0
        public void Update(GameTime gameTime, GraphicsDeviceManager graphics, Sprite playerOneSprite, Sprite playerTwoSprite, Player one, Player two)
        {
            base.Update(gameTime);
            if (this.enemyType != null)
            {
                Movement = enemyType.Update(enemyType, Position, Movement, graphics, playerOneSprite, playerTwoSprite, one, two);
            }

            Position += Movement * (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            InvincibleTimeLeft -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;
        }
Пример #7
0
        public void Update(KeyboardState state, Sprite player, Player dino, PlayerShots playerShots, GraphicsDeviceManager graphics, GameTime gameTime, GameState gameState)
        {
            _oldKeyPressed = _currentKeyPressed;
            _currentKeyPressed = state;

            _movement = Vector2.Zero;

            if (dino.PlayerIndex == PlayerIndex.One)
            {
                if ((_currentKeyPressed.IsKeyDown(Keys.A) || _currentKeyPressed.IsKeyDown(Keys.Left)) && player.Position.X > 50)
                {
                    _movement -= Vector2.UnitX * .7f;
                }
                if ((_currentKeyPressed.IsKeyDown(Keys.D) || _currentKeyPressed.IsKeyDown(Keys.Right)) && player.Position.X < graphics.PreferredBackBufferWidth - 50)
                {
                    _movement += Vector2.UnitX * .7f;
                }
                if ((_currentKeyPressed.IsKeyDown(Keys.W) || _currentKeyPressed.IsKeyDown(Keys.Up)) && player.Position.Y > (graphics.PreferredBackBufferHeight / 2) + 100)
                {
                    _movement -= Vector2.UnitY * .5f;
                }
                if ((_currentKeyPressed.IsKeyDown(Keys.S) || _currentKeyPressed.IsKeyDown(Keys.Down)) && player.Position.Y < graphics.PreferredBackBufferHeight - player.Texture.Height)
                {
                    _movement += Vector2.UnitY * .5f;
                }
            }
            else if (dino.PlayerIndex == PlayerIndex.Two)
            {
                if (_currentKeyPressed.IsKeyDown(Keys.L) && player.Position.X > 50)
                {
                    _movement -= Vector2.UnitX * .7f;
                }
                if (_currentKeyPressed.IsKeyDown(Keys.OemQuotes)&& player.Position.X < graphics.PreferredBackBufferWidth - 50)
                {
                    _movement += Vector2.UnitX * .7f;
                }
                if (_currentKeyPressed.IsKeyDown(Keys.P) && player.Position.Y > (graphics.PreferredBackBufferHeight / 2) + 100)
                {
                    _movement -= Vector2.UnitY * .5f;
                }
                if (_currentKeyPressed.IsKeyDown(Keys.OemSemicolon) && player.Position.Y < graphics.PreferredBackBufferHeight - player.Texture.Height)
                {
                    _movement += Vector2.UnitY * .5f;
                }
            }

            // Jamie Key
            if(_currentKeyPressed.IsKeyDown(Keys.J) && !_oldKeyPressed.IsKeyDown(Keys.J))
            {
                if (dino._laserPowerLevel < 5)
                    dino._laserPowerLevel += 1;
                else
                    dino._laserPowerLevel = 1;
            }

            if (_currentKeyPressed.IsKeyDown(Keys.Space) || _currentKeyPressed.IsKeyDown(Keys.F) || _currentKeyPressed.IsKeyDown(Keys.Enter))
            {
                if (dino.LaserCharge > 0)
                {

                    if (dino.PlayerIndex == PlayerIndex.One)
                    {
                        if (_currentKeyPressed.IsKeyDown(Keys.F) || _currentKeyPressed.IsKeyDown(Keys.Space))
                        {
                            playerShots.FireOne(dino);
                            dino._currentCharge -= 1;
                        }
                    }
                    else if (dino.PlayerIndex == PlayerIndex.Two)
                    {
                        if (_currentKeyPressed.IsKeyDown(Keys.Enter))
                        {
                            playerShots.FireTwo(dino);
                            dino._currentCharge -= 1;
                        }
                    }
                }
            }

            if (player.IsInMarsh)
            {
                player.Movement += _movement / 3;
            }
            else
            {
                player.Movement += _movement;
            }
            player.Update(gameTime);
            _movement.X = 0f;
            _movement.Y = 0f;
            player.Movement = _movement;
            player.Update(gameTime);
        }
Пример #8
0
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            gameState = GameState.TitleScreen;
            previousState = gameState;

            upgradeScreen = null;
            startScreen = null;
            characterScreen = null;
            multiplayerLobby = null;
            deathScreen = null;
            levelBeginning = null;
            pauseScreen = null;
            loadingScreen = null;

            levelCreator = null;

            Random rand = new Random();
            currentLevel = null;

            enemies = null;
            explosions = null;
            shotBehavior = null;
            enemyShots = null;
            playerShots = null;
            hbOne = null;
            hbTwo = null;
            bossLifeBar = null;
            cbOne = null;
            cbTwo = null;
            backGroundMusic = null;
            playerOneMeterTitle = null;
            playerTwoMeterTitle = null;
            meterLabel = null;
            playerOneMarker = null;
            playerTwoMarker = null;

            dinosaurOne = null;
            dinosaurTwo = null;
            playerOneSprite = null;
            playerTwoSprite = null;
            collisions = null;
            font = null;

            playerOneCounter = 0;
            playerTwoCounter = 0;
            levelIncrement = 0;

            singlePlayer = false;
            explodedOne = false;
            explodedTwo = false;

            input = null;
            padInput = null;
        }
Пример #9
0
        protected void LoadCharacter()
        {
            if (startScreen.SinglePlayer)
            {
                singlePlayer = true;
                dinosaurOne = new Player(Content, graphics, characterScreen.Character, 1);
                dinosaurOne.ControlScheme = startScreen.ControlScheme;

                ValidateCharacter(1);

                playerOneSprite.Position = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight - 250);
            }
            else if (startScreen.MultiPlayer)
            {
                singlePlayer = false;
                dinosaurOne = new Player(Content, graphics, multiplayerLobby.playerOne, 1);
                dinosaurTwo = new Player(Content, graphics, multiplayerLobby.playerTwo, 2);
                dinosaurOne.ControlScheme = multiplayerLobby.firstPlayerControl;
                dinosaurTwo.ControlScheme = multiplayerLobby.secondPlayerControl;

                ValidateCharacter(1);
                ValidateCharacter(2);

                playerOneSprite.Position = new Vector2(graphics.PreferredBackBufferWidth / 3, graphics.PreferredBackBufferHeight - 250);
                playerTwoSprite.Position = new Vector2(graphics.PreferredBackBufferWidth - (graphics.PreferredBackBufferWidth / 3), graphics.PreferredBackBufferHeight - 250);
            }

            playerShots = new PlayerShots(Content, dinosaurOne, playerOneSprite, dinosaurTwo, playerTwoSprite);
            shotBehavior = new ShotBehavior(Content);
            enemyShots = new EnemyShots(Content);

            CreateScreens();
            GenerateLevel();
        }
Пример #10
0
        public void Update(GamePadState state, Sprite player, Player dino, PlayerShots playerShots, GraphicsDeviceManager graphics, GameTime gameTime, GameState gameState)
        {
            _oldInput = _currentInput;
            _currentInput = state;

            _movement = Vector2.Zero;

            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickRight)) && player.Position.X > 50)
            {
                _movement -= Vector2.UnitX * .7f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickLeft)) && player.Position.X < graphics.PreferredBackBufferWidth - 50)
            {
                _movement += Vector2.UnitX * .7f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickDown)) && player.Position.Y > (graphics.PreferredBackBufferHeight / 2) + 100)
            {
                _movement -= Vector2.UnitY * .5f;
            }
            if ((_currentInput.IsButtonUp(Buttons.LeftThumbstickUp)) && player.Position.Y < graphics.PreferredBackBufferHeight - player.Texture.Height)
            {
                _movement += Vector2.UnitY * .5f;
            }

            // Jamie Key
            if (_currentInput.IsButtonDown(Buttons.Y) && !_oldInput.IsButtonDown(Buttons.Y))
            {
                if (dino._laserPowerLevel < 5)
                    dino._laserPowerLevel += 1;
                else
                    dino._laserPowerLevel = 1;
            }

            if (_currentInput.Buttons.A  == ButtonState.Pressed)
            {
                if (dino.LaserCharge > 0)
                {
                    dino._currentCharge -= 1;

                    if (dino.PlayerIndex == PlayerIndex.One)
                    {
                        playerShots.FireOne(dino);
                    }
                    else if (dino.PlayerIndex == PlayerIndex.Two)
                    {
                        playerShots.FireTwo(dino);
                    }
                }
            }

            if (player.IsInMarsh)
            {
                player.Movement += _movement / 3;
            }
            else
            {
                player.Movement += _movement;
            }
            player.Update(gameTime);
            _movement.X = 0f;
            _movement.Y = 0f;
            player.Movement = _movement;
            player.Update(gameTime);
        }