Update() public method

public Update ( ) : void
return void
Beispiel #1
0
        public virtual void Update(GameTime gameTime)
        {
            étatTactile = TouchPanel.GetState();
            if (étatTactile.Count > 0)
            {
                foreach (TouchLocation location in étatTactile)
                {
                    Point touchLocation = new Point((int)location.Position.X, (int)location.Position.Y);
                    foreach (Bouton bouton in Boutons)
                    {
                        if (bouton.emplacementBouton.Contains(touchLocation))
                        {
                            bouton.Agir();
                        }
                    }
                }
            }

            if (background1.rectangle.Y > fenêtre.Height)
            {
                background1.rectangle.Y = background2.rectangle.Y - background1.texture.Height;
            }
            if (background2.rectangle.Y > fenêtre.Height)
            {
                background2.rectangle.Y = background1.rectangle.Y - background2.texture.Height;
            }

            background1.Update();
            background2.Update();
        }
Beispiel #2
0
 private void UpdateGameObjectsBeforeTime(float deltaTime, float gameTime)
 {
     _backgroundAudience.Update(deltaTime, _player.GetScaledVelocity().Y);
     _scrollingBackground.Update(deltaTime, _player.GetScaledVelocity().Y);
     _player.Update(deltaTime, gameTime);
     _stage.Update(deltaTime, gameTime);
     _winWrestler.Update(deltaTime, gameTime);
 }
        private void UpdatePlayerClimbing(float deltaTime)
        {
            _cinematicSceneVariable_1 -= deltaTime;
            if (_cinematicSceneVariable_1 <= 0)
            {
                _cinematicSceneVariable_1 = GameInfo.PlayerSpriteFlipRate;

                SpriteEffects playerSpriteEffects = _playerSprite.SpriteEffects;
                switch (playerSpriteEffects)
                {
                case SpriteEffects.None:
                    _playerSprite.SpriteEffects = SpriteEffects.FlipHorizontally;
                    break;

                case SpriteEffects.FlipHorizontally:
                    _playerSprite.SpriteEffects = SpriteEffects.None;
                    break;

                case SpriteEffects.FlipVertically:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            if (_cinematicSceneVariable_2 > 0)
            {
                _cinematicSceneVariable_2 -= deltaTime;
                if (_cinematicSceneVariable_2 <= 0)
                {
                    if (_cinematicScreenVariable_3 == 0)
                    {
                        SoundManager.Instance.PlaySound(_voiceOver_3);
                        _cinematicSceneVariable_2 = GameInfo.WaitTimeForThrowingCommentary;
                    }
                    else
                    {
                        SoundManager.Instance.PlaySound(_voiceOver_4);
                    }

                    _cinematicScreenVariable_3 += 1;
                }
            }

            _dummyPlayer.GameObject.Position = _playerSprite.Position;

            _winWrestler.Position += Vector2.UnitY * GameInfo.CinematicScrollMoveSpeed * deltaTime;
            _stage.Position       += Vector2.UnitY * GameInfo.CinematicScrollMoveSpeed * deltaTime;
            _starSprite.Position  += Vector2.UnitY * GameInfo.CinematicScrollMoveSpeed * deltaTime;

            _audienceScrolling.Update(deltaTime, -GameInfo.CinematicScrollMoveSpeed);
            _cinematicBackgroundScroller.Update(deltaTime);
        }
Beispiel #4
0
        public virtual void Update(GameTime gameTime)
        {
            /******************************CODE POUR LE HEROS***************************
            ***************************************************************************/

            if (Heros.isVisible)
            {
                score += 1;
            }
            else
            {
                ScreenManager.getInstance(fenêtre).ChangeCurrentScreen(ScreenManager.Screens.Menu);
            }
            Heros.UpdateHeros(ennemis, accelreading.X, gameTime);

            /******************************CODE POUR LES ENNEMIS************************
            ***************************************************************************/

            foreach (Personnages perso in ennemis)
            {
                perso.Update(Heros, gameTime);
            }

            for (int i = ennemis.Count - 1; i >= 0; i--)
            {
                if (!ennemis[i].isVisible && !ennemis[i].explose && !ennemis[i].ArmePerso.isVisible)
                {
                    ennemis.RemoveAt(i);
                    score += 100;
                }
            }

            /******************************CODE POUR LE BACKGROUND*********************
             ***************************************************************************/

            if (background1.rectangle.Y > fenêtre.Height)
            {
                background1.rectangle.Y = background2.rectangle.Y - background1.texture.Height;
            }
            if (background2.rectangle.Y > fenêtre.Height)
            {
                background2.rectangle.Y = background1.rectangle.Y - background2.texture.Height;
            }

            background1.Update();
            background2.Update();

            /******************************CODE POUR LE TEST***************************
             ***************************************************************************/
            if (ennemis.Count == 0)
            {
                ensemble1.Apparaitre(Vector2.Zero, ennemis);
            }
        }
Beispiel #5
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here

            playerObject.update();
            foreach (BombObject b in bombObjectList)
            {
                b.update();
            }
            foreach (BattleShip bs in battleship)
            {
                bs.update();
            }
            foreach (ProtectFighter fl in protectObjectList)
            {
                fl.update();
            }
            foreach (AircraftCarrier ac in aircraftcarriers)
            {
                ac.update();
            }
            foreach (GameObject g in gameObjectList)
            {
                g.update();
            }
            foreach (BomberObject g in bomberObjectList)
            {
                g.update();
            }

            foreach (DestroyerObject1 d1 in destroyerobjcet1list)
            {
                d1.update();
            }
            //  bonus.update(gameTime);
            gameInfoObject.update(gameTime);
            gameController.control();

            /*      if (gameController.getCarrier()!=null)
             *        gameController.getCarrier().update();*/
            // this is for the scrolling background;
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            myBackground.Update(elapsed * 100);
            base.Update(gameTime);
        }
Beispiel #6
0
        protected override void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _scrollingBackground.Update(elapsed * 100);

            if (_gameOver && !_playGameOver)
            {
                _upgrade.GameOver            = true;
                _ship.GameOver               = true;
                _spaceInvadersBoard.GameOver = true;
                _playGameOver = true;
            }

            if (_playGameOver && _play)
            {
                AssetsManager.GameOver.Play();
                _playGameOver = false;
                _play         = false;
            }
            else if (_playYouWin && _play)
            {
                AssetsManager.YouWin.Play();
                _playYouWin = false;
                _play       = false;
            }

            if (_spaceInvadersBoard.SpaceInvaderList.Count <= 0)
            {
                _playYouWin = true;
            }

            _spaceInvadersBoard.Update(gameTime);
            _ship.Update(gameTime);
            _upgrade.Update(gameTime);

            foreach (SpaceInvaderObject SpaceInvader in _spaceInvadersBoard.SpaceInvaderList)
            {
                SpaceInvader.UpdateShipPosition(_ship.ShipPosition);

                //Invader hits ship
                if (SpaceInvader.HasWeapon)
                {
                    foreach (InvaderBullet Bullet in SpaceInvader.InvaderWeapon.Bullets)
                    {
                        if (CheckCollision(Bullet, _ship))
                        {
                            Bullet.Hit = true;
                            _ship.Lives--;
                        }
                    }
                }

                //Game Over
                if (CheckCollision(_ship, SpaceInvader) || _ship.Lives <= 0)
                {
                    _gameOver = true;
                }
            }

            for (int i = 0; i < _upgrade.LaserUpgrades.Count; i++)
            {
                if (CheckCollision(_upgrade.LaserUpgrades[i], _ship))
                {
                    _ship.Weapon.WeaponState = WeaponState.Laser;
                    AssetsManager.UpgradeSoundEffect.Play();
                    _upgrade.LaserUpgrades[i].DisposeFromList();
                    _upgrade.LaserUpgrades.RemoveAt(i);
                }
            }

            for (int i = 0; i < _upgrade.RocketUpgrades.Count; i++)
            {
                if (CheckCollision(_upgrade.RocketUpgrades[i], _ship))
                {
                    _ship.Weapon.WeaponState = WeaponState.Rocket;
                    AssetsManager.UpgradeSoundEffect.Play();
                    _upgrade.RocketUpgrades[i].DisposeFromList();
                    _upgrade.RocketUpgrades.RemoveAt(i);
                }
            }

            if (_ship.Weapon.WeaponState == WeaponState.Normal)
            {
                foreach (NormalBullet Bullet in _ship.Weapon.NormalWeapon.Bullets)
                {
                    foreach (SpaceInvaderObject SpaceInvader in _spaceInvadersBoard.SpaceInvaderList)
                    {
                        if (CheckCollision(Bullet, SpaceInvader))
                        {
                            SpaceInvader.Hit = true;
                            Bullet.Hit       = true;
                        }
                    }
                }
            }
            else if (_ship.Weapon.WeaponState == WeaponState.Rocket)
            {
                foreach (RocketBullet Bullet in _ship.Weapon.RocketWeapon.Bullets)
                {
                    foreach (SpaceInvaderObject SpaceInvader in _spaceInvadersBoard.SpaceInvaderList)
                    {
                        if (CheckCollision(Bullet, SpaceInvader))
                        {
                            SpaceInvader.Hit = true;
                            Bullet.Hit       = true;
                        }
                    }
                }
            }
            else if (_ship.Weapon.WeaponState == WeaponState.Laser)
            {
                foreach (LaserBullet Bullet in _ship.Weapon.LaserWeapon.Bullets)
                {
                    foreach (SpaceInvaderObject SpaceInvader in _spaceInvadersBoard.SpaceInvaderList)
                    {
                        if (CheckCollision(Bullet, SpaceInvader))
                        {
                            SpaceInvader.Hit = true;
                            Bullet.Hit       = true;
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #7
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>
        public override void Update(GameTime gameTime)
        {
            // Allows the game to exit


            keyState = Keyboard.GetState();
            scrollingbackgroundtop.Update(gameTime);
            scrollingbackgroundbottom.Update(gameTime);

            validationobjectengine.Update(gameTime);
            validationobjectengine.validationrect = ballobjectengine.BALLPOSITIONOFTRUTH;
            if (gokuPlayer.State == MediaState.Stopped)
            {
                // UnloadContent();
                //isDisposed = true;
                gWinRect.X = 0;
                gWinRect.Y = 0;
            }

            keyState = Keyboard.GetState();
            forward.Update(gameTime);
            #region KEYBOARD COMMANDS TO CONTROL AFTER VIDEO JESUS IS GOD!
            if (keyState.IsKeyDown(Keys.Enter) && (gokuPlayer.State == MediaState.Stopped))
            {
                // ScreenManager.Instance.AddScreen(new OpeningTitleScreen(isLooped));

                UnloadContent();
                gokuPlayer.Dispose();
                gokuVidTexture.Dispose();
                ScreenManager.Instance.AddScreen(new OpeningTitleScreen());
            }

            if (keyState.IsKeyDown(Keys.P))
            {
                //ScreenManager.Instance.AddScreen(new PlayVideoGameState(isLooped));

                UnloadContent();
                gokuPlayer.Dispose();
                gokuVidTexture.Dispose();
                //ScreenManager.Instance.AddScreen(new EndingTitleScreen());
            }

            #endregion
            //   homebase.explosionartrect.X = theball.ballrect.X;
            // homebase.explosionartrect.Y = theball.ballrect.Y;
            ballobjectengine.Update(gameTime);
            //homebase.Update(gameTime);
            timer.Update(gameTime);


            // collisions are in the update method. finger ocllisons with falling stuff pheonomina
            if ((ballobjectengine.BallPositionOfTruth.Intersects(leapcollisionmax)) || (leapcollisionmax.Intersects(ballobjectengine.BallPositionOfTruth)) || (leapcollisionmax.X == ballobjectengine.BallPositionOfTruth.X && leapcollisionmax.Y == ballobjectengine.BallPositionOfTruth.Y))
            //     if (leapcollisionmax.Intersects(ballobjectengine.BallPositionOfTruth))
            {
                validationobjectengine.arttrigger   = true;
                validationobjectengine.soundtrigger = true;
                if (playsound == false)
                {
                    boom.Play();
                    playsound = true;
                }
                if (colorcontrol == false)
                {
                    BallObjectEngine.objectcolor = Color.White;
                    colorcontrol = true;
                }

                if (isscorehit == false)
                {
                    score     += 1;
                    isscorehit = true;
                    playsound  = false;
                }
            }
            // TODO: Add your update logic here\

            /*
             *    if (bottombaserect.Intersects(theball.Ballrect))
             *    {
             *        ishit = true;
             *    }
             *
             *    if (!bottombaserect.Intersects(theball.Ballrect))
             *    {
             *        ishit = false;
             *    }
             */

            ballobjectengine.ReceiveFrom_TimeEngine(timer.SendTo_BallObjectEngine());

            // theball.Ballpositionoftruth.X;
        }
        public override void Update(GameTime gameTime)
        {
            #region JESUS IS LORD  SOUND REPEATING  JESUS IS LORD!
            if (MediaPlayer.State == MediaState.Stopped)
            {
                MediaPlayer.Play(backgroundMusic);
            }

            #endregion

            //    backwardscode.Update(gameTime);
            forward.Update(gameTime);
            //     scrollingbackgroundtop.Update(gameTime);
            //  scrollingbackgroundbottom.Update(gameTime);
            backwards.Update(gameTime);
            #region JESUS IS LORD CHARACTER CONTROL ALGORITHIMS

            /*
             * if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.G))
             * {
             *  gokuRect.X = gokuRect.X + 1;
             *
             *
             *  redRect.X = redRect.X + 2;
             *
             * }
             *
             * if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.S))
             * {
             *  supermanRect.X = supermanRect.X - 1;
             *  blueRect.X = blueRect.X - 2;
             * }
             *
             * keyState = Keyboard.GetState();
             *
             * if ((gokuRect.X - 250) >= (supermanRect.X))
             *  ScreenManager.Instance.AddScreen(new TitleScreen());
             * if (displayEndScenes)
             * {
             *  if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.D3))
             *  {
             *      ScreenManager.Instance.AddScreen(new GokuWins());
             *  }
             *
             *  if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.D4))
             *  {
             *      ScreenManager.Instance.AddScreen(new SuperManWins());
             *  }
             *
             * }
             */
            #endregion

            /*
             *
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             *
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             *
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             *
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             *
             * if (hitboxrect[0].Intersects(leapcollisionb))
             * {
             *  broken[0] = true;
             *  hitsound.Play();
             * }
             */


            #region JESUS IS LORD AND IN CONTROL -  THIS CHANGES STATE TO THE OPENING VIDEO
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Enter))
            {
                MediaPlayer.Stop();

                ScreenManager.Instance.AddScreen(new TicTacToeGameScreen());
                // not now readd  ScreenManager.Instance.AddScreen(new ResumeVideoGame());
            }
            #endregion
        }
        /// <summary>
        /// Scrolling
        /// </summary>
        /// <param name="?"></param>
        /// <param name="?"></param>
        protected void UpdateMap(ScrollingBackground bg, GameTime gameTime)
        {
            if (bg == null) return;

            bg.Update(gameTime);
        }