Пример #1
0
 /// <summary>
 /// Update all Sprites on this Screen.
 /// </summary>
 public virtual void Update()
 {
     if (BackgroundSprite != null)
     {
         BackgroundSprite.Update();
     }
     Sprites.Update();
     for (int i = 0; i < AdditionalSprites.Count; i++)
     {
         if (AdditionalSprites[i] is ISprite)
         {
             (AdditionalSprites[i] as ISprite).Update();
         }
     }
 }
Пример #2
0
 public virtual void Update(GameTime gameTime)
 {
     if (currentState.Equals(ItemState.Moving) || currentState.Equals(ItemState.Bounce))
     {
         MovingTime++;
     }
     if (MovingTime >= maxMovingTime)
     {
         itemSprite = null;
     }
     if (itemSprite != null && currentState != ItemState.Taken)
     {
         if (currentState.Equals(ItemState.Moving))
         {
             HandleHorizontalMovement();
             Fall(gameTime);
         }
         if (this.isInBlock)
         {
             this.isInvisible = false;
             yDifference      = moveUpVelocity * ((float)gameTime.ElapsedGameTime.Milliseconds / FIFTY);
             if (position.Y + this.itemSprite.Height > originalY)
             {
                 position.Y -= yDifference;
             }
             else
             {
                 this.Move();
                 this.isInBlock = false;
             }
         }
         itemSprite.Update(gameTime, (int)position.X, (int)position.Y);
     }
 }
Пример #3
0
        public virtual void Update(GameTime gameTime)
        {
            if (currentHealth != EnemyHealth.Flipped && deathTime >= deathTimeMax)
            {
                currentSprite = null;
            }
            if (currentSprite != null)
            {
                if (isSeen == true)
                {
                    isMoving = true;
                }
                else
                {
                    isMoving = false;
                }

                if (currentHealth == EnemyHealth.Flipped)
                {
                    DeathAnimation();
                }
                if (currentHealth != EnemyHealth.Normal)
                {
                    deathTime++;
                }

                HandleHorizontalMovement();
                Fall(gameTime);
                currentSprite.Update(gameTime, (int)position.X, (int)position.Y);
            }
        }
Пример #4
0
 public void Update(GameTime gameTime)
 {
     if (!explode)
     {
         fireballLife = fireballLife - (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (fireballLife <= 0)
         {
             IsRemove = true;
         }
         else
         {
             if (IsLeft)
             {
                 FireballPhysicalProperty.MoveLeft();
             }
             else
             {
                 FireballPhysicalProperty.MoveRight();
             }
         }
     }
     else
     {
         explodeTime = explodeTime - (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (explodeTime <= 0)
         {
             IsRemove = true;
         }
     }
     FireballPhysicalProperty.Update(gameTime);
     sprite.Update(gameTime);
 }
        public void Update()
        {
            if (koopa.shell)
            {
                koopa.shellDuration--;
                if (koopa.shellDuration == 0)
                {
                    koopa.shell = false;
                    koopa.state.BeIdle();
                    koopa.speed.velocity.X = koopa.enemySpeed.velocity.X;
                    koopa.shellDuration    = ConstantNumber.SHELL_DURATION;
                }
            }

            if (koopa.moveLeft)
            {
                Left();
            }
            else
            {
                Right();
            }

            if (!koopa.isOnGround)
            {
                Fall();
            }

            koopaSprite.Update();
        }
Пример #6
0
        public void Update()
        {
            if (body.Awake)
            {
                if (state is EnemyIdleState)
                {
                    state = new EnemyWalkingState(this);
                    state.Walk();
                }

                sprite.Update();

                if (Math.Abs((initial - body.BottomCenter.X)) > range / 2)
                {
                    ChangeDirection();
                    state.Walk();
                }
            }
            else
            {
                if (state is EnemyWalkingState)
                {
                    state = new EnemyIdleState(this);
                    state.Idle();
                }
            }
        }
Пример #7
0
 public void Update()
 {
     scoreTextSprite.Text = fixText(GameUtilities.EmptyString + ScoringSystem.Player1Score.Score, scoreLength);
     coinSprite.Update();
     coinTextSprite.Text = HUDUtilities.MultiplicationSign + fixText(GameUtilities.EmptyString + CoinSystem.Instance.Coins, coinLength);
     timeTextSprite.Text = fixText(GameUtilities.EmptyString + MarioAttributes.Time, timeLength);
 }
Пример #8
0
 public void Update(GameTime gameTime)
 {
     Coin.Update(0.6f);
     if (gameTime == null)
     {
         throw new ArgumentNullException(nameof(gameTime));
     }
     if (Mode == 0)
     {
         GameMenu.Update(1);
     }
     else if (Mode == 2)
     {
         GameOver.Update(1);
     }
     else if (Mode == 3)
     {
         GameWin.Update(1);
     }
     else if (Mode == 1)
     {
         //will not change when arrives 0, or pulse the game, or Mario wins (touch the flag)
         RestOfTime -= (RestOfTime > 0 && !Scene.Mario.Win && !Stage.Pulse) ? (float)gameTime.ElapsedGameTime.TotalSeconds : 0;
         if (RestOfTime < 0)
         {
             Scene.Mario.Suicide(); RestOfTime = 0;
         }
         currScene.Update(gameTime);
     }
 }
Пример #9
0
 public virtual void Update(GameTime gameTime)
 {
     if (currentSprite != null)
     {
         currentSprite.Update(gameTime, (int)posX, (int)posY);
     }
 }
Пример #10
0
 /// <inheritdoc/>
 public void Update()
 {
     if (sprite.CurrentFrame < sprite.TotalFrames - 1)
     {
         sprite.Update();
     }
 }
Пример #11
0
 public void Update(GameTime gameTime)
 {
     if (ShouldLowerFlag)
     {
         sprite.Update(gameTime);
     }
 }
Пример #12
0
 public new void Update(GameTime gameTime)
 {
     ApplyForce(SimpleForce.gravity);
     ApplyForce(direction);
     base.Update(gameTime);
     lakituBallSprite.Update(gameTime);
 }
Пример #13
0
        public void Update()
        {
            if (Game1.Instance.isPkMode)
            {
                triggered = true;
                Fall();
            }
            else if (moveUp)
            {
                Up();
            }

            else if (triggered)
            {
                if (moveLeft)
                {
                    Left();
                }
                else
                {
                    Right();
                }

                if (!isOnGround)
                {
                    Fall();
                }
            }

            mushroomSprite.Update();
        }
Пример #14
0
 public void Update(GameTime gameTime)
 {
     koopa.Physics.Update(gameTime);
     koopa.EnemyPhysics.KoopaMove();
     sprite.Update(gameTime);
     koopa.EnemyPhysics.EnemyWalk();
 }
Пример #15
0
 public void Update()
 {
     topLeft.Update();
     topRight.Update();
     botLeft.Update();
     botRightl.Update();
 }
Пример #16
0
        public void Update()
        {
            currentDelay++;
            if (currentDelay == totalDelay)
            {
                selectorSprite.Update();
                currentDelay = 0;
            }

            if (game.currentMode.Equals("normal"))
            {
                offsetMultiplier = 0;
            }
            else if (game.currentMode.Equals("hard"))
            {
                offsetMultiplier = 1;
            }
            else if (game.currentMode.Equals("sudden death"))
            {
                offsetMultiplier = 2;
            }
            else if (game.currentMode.Equals("puzzle"))
            {
                offsetMultiplier = 3;
            }
            selectorSprite.Y = normalY + offsetMultiplier * selectorOffset;
        }
Пример #17
0
        public override bool Update()
        {
            if (!base.Update())
            {
                return(false);
            }

            if (m_needLayout)
            {
                Relayout();
            }

            if (m_label != null)
            {
                m_label.Update();
            }

            if (m_cursor != null)
            {
                m_cursor.Alpha = (int)(Math.Sin(WindowController.Instance.GetTime() / 1000.0f) * 255 + 128.5f); // blinks every 2 seconds
                m_cursor.Update();
            }

            return(true);
        }
Пример #18
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            GameKeyboard.Update();
            /// gameGamePad.Update();
            sprite.Update();

            base.Update(gameTime);

            //KeyboardState keyboardstate = Keyboard.GetState();
            //if (keyboardstate.IsKeyDown(Keys.D0))
            // Exit();

            // animatedSprite.Update();
            // staticSpriteUpdown.Update();
            // animatedSpriteLeftRight.Update();


            //if (keyboardstate.IsKeyDown(Keys.D1))
            //     sprite = staticSprite;
            //if (keyboardstate.IsKeyDown(Keys.D2))
            //     sprite = animatedSprite;
            // if (keyboardstate.IsKeyDown(Keys.D3))
            //     sprite = staticSpriteUpdown;
            // if (keyboardstate.IsKeyDown(Keys.D4))
            //     sprite = animatedSpriteLeftRight;
        }
Пример #19
0
        public void Update(float timeOfFrame)
        {
            if (MarioState.GetPowerType == MarioState.PowerType.Died && !Parameters.HasGravity)
            {
                Clock += timeOfFrame;
                if (Clock >= 20)
                {
                    Parameters.SetVelocity(0, -10); Parameters.HasGravity = true; Clock = 0;
                }
            }

            /*
             * In this Sprint, I cannot make Mario jumpHigher in JumpingState because the system read input per Update, not
             * read each 100ms (the frequency of collision update)
             */
            if (JumpHigher)
            {
                Parameters.SetVelocity(Math.Abs(Parameters.Velocity.X), Parameters.Velocity.Y - 0.5f);
                JumpHigher = false;
            }
            if (Parameters.Velocity.Y > 0 && timeOfFrame > 0 && !Dive && MarioState.GetActionType != MarioState.ActionType.Other)
            {
                ChangeToFalling();//change to falling
            }
            CurrentSprite.Update(timeOfFrame);
            DivingAndShooting();
        }
Пример #20
0
        public void Update()
        {
            if (moveUp)
            {
                Up();
            }

            else if (triggered)
            {
                if (moveLeft)
                {
                    Left();
                }
                else
                {
                    Right();
                }

                if (!isOnGround && falling)
                {
                    Fall();
                }
                else
                {
                    Rise();
                }
            }
            starSprite.Update();
        }
Пример #21
0
        //update
        public void Update(GameTime gameTime)
        {
            ElapsedFrames += (float)gameTime.ElapsedGameTime.TotalSeconds * 60;
            sprite.WasHit  = WasHit;
            if (WasHit)
            {
                if (ElapsedFrames > 5)
                {
                    WasHit        = false;
                    ElapsedFrames = 0;
                }
            }

            Boundary = new Rectangle((int)Location.X, (int)Location.Y, (int)WidthHeight.X, (int)WidthHeight.Y);
            if (bump)
            {
                bump = false;
                if (GetBlockType().Equals(Blocks.BRICK))
                {
                    sprite = new BrickBlockSprite((int)Location.X, (int)Location.Y, false, true);
                }
                else if (GetBlockType().Equals(Blocks.USED))
                {
                    sprite = new UsedBlockSprite((int)Location.X, (int)Location.Y);
                }
            }
            sprite.Update(gameTime);
        }
Пример #22
0
        public void Update()
        {
            if (_currentDistanceAway == ReturnDistance * 2)
            {
                _sprite.Hide();
            }
            UpdateFlippedDirection();

            switch (_direction)
            {
            case Direction.Up:
                _location.Y -= DistancePerFrame;
                break;

            case Direction.Down:
                _location.Y += DistancePerFrame;
                break;

            case Direction.Left:
                _location.X -= DistancePerFrame;
                break;

            case Direction.Right:
                _location.X += DistancePerFrame;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _currentDistanceAway += DistancePerFrame;
            Bounds = new Rectangle(_location.ToPoint(), Bounds.Size);

            _sprite.Update();
        }
        public void Update()
        {
            if (moveUp)
            {
                Up();
            }

            if (triggered)
            {
                if (moveLeft)
                {
                    Left();
                }
                else
                {
                    Right();
                }

                if (!isOnGround)
                {
                    Fall();
                }
            }
            poisonMushroomSprite.Update();
        }
 public override void Update()
 {
     if (goingUp)
     {
         if (block.position != desLocation)
         {
             block.position.Y--;
         }
         else
         {
             goingUp = false;
         }
     }
     else
     {
         if (block.position != originalLocation)
         {
             block.position.Y++;
         }
         else
         {
             block.state = new BrickBlockState(block);
         }
     }
     bumpedBrickBlockSprite.Update();
 }
Пример #25
0
 public void Update()
 {
     if (!type.Equals(GUIType.text))
     {
         sprite.Update();
     }
 }
Пример #26
0
 public void Update(GameTime gameTime)
 {
     goomba.Physics.Update(gameTime);
     goomba.EnemyPhysics.GoombaMove();
     sprite.Update(gameTime);
     goomba.EnemyPhysics.EnemyWalk();
 }
Пример #27
0
 public void Update(GameTime gameTime)
 {
     lakitu.MarioDistanceCollision.Handle(this.lakitu, game);
     lakitu.Movement.MoveEntity(lakitu, lakitu.Speed * gameTime.ElapsedGameTime.Milliseconds / 1000f, 0);
     AboveMario(lakitu.Position);
     lakituSprite.Update(gameTime);
 }
Пример #28
0
        public void Update()
        {
            if (goomba.killed)
            {
                goomba.timer--;
                if (goomba.timer == 0)
                {
                    goomba.killed = false;
                    goomba.Disappear();
                }
            }

            if (goomba.moveLeft)
            {
                Left();
            }
            else
            {
                Right();
            }

            if (!goomba.isOnGround)
            {
                goomba.Fall();
            }
            goombaSprite.Update();
        }
Пример #29
0
 public new void Update(GameTime gameTime)
 {
     if (Interval == 1)
     {
         Boom();
     }
     else if (Interval > 1)
     {
         --Interval;
     }
     if (!boom)
     {
         if (Interval == 0 && !DisableGravity)
         {
             ApplyForce(SimpleForce.gravity);
         }
         ApplyForce(direction);
         base.Update(gameTime);
         fireballSprite.Update(gameTime);
     }
     if (game.Mario.Position.X >= Position.X && game.Mario.Position.X <= Position.X + 1.5 &&
         game.Mario.Position.Y - game.Mario.Bounds.Height + 1 <= Position.Y && game.Mario.Position.Y + game.Mario.Bounds.Height + game.Mario.Bounds.Y >= Position.Y + 0.25)
     {
         game.Mario.CauseDamage();
     }
 }
Пример #30
0
 public void Update()
 {
     if (coolDown > 0)
     {
         coolDown--;
     }
     sprite.Update();
 }