예제 #1
0
        public void Update(GameTime gameTime)
        {
            MarioAnimatedState.Update(gameTime);
            CheckDead();

            MarioPhysics.Update(gameTime);
            time += gameTime.ElapsedGameTime.TotalSeconds;
            if (time > delay)
            {
                action = true;
                time   = Constant.Constant.Instance.InitialTime;
            }
        }
예제 #2
0
        public void Update(GameTime gametime)
        {
            if (damageTimer == Util.Instance.DamageTimer)
            {
                canTakeDamage = true;
                isFlash       = false;
                damageTimer   = Util.Instance.Zero;
            }
            if (!canTakeDamage)
            {
                damageTimer++;
            }

            if (CurrentPowerState is MarioStarBigState || CurrentPowerState is MarioStarSmallState)
            {
                if (starTimer == Util.Instance.FiveHundreds)
                {
                    if (CurrentPowerState is MarioStarBigState)
                    {
                        CurrentPowerState = new MarioBigState(this);
                    }
                    else
                    {
                        CurrentPowerState = new MarioSmallState(this);
                    }
                    starTimer = Util.Instance.Zero;
                }
                starTimer++;
            }

            foreach (Fireball fireball in fireballs)
            {
                fireball.Update(gametime);
            }
            foreach (ScoreObject score in ScoreObjects)
            {
                score.Update(gametime);
            }

            Rectangle = new Rectangle((int)Location.X, (int)Location.Y, CurrentAnimationState.Width, CurrentAnimationState.Height);
            if (IsIdle)
            {
                PreviousAnimationState = CurrentAnimationState;
                CurrentAnimationState.Idle();
                MarioPhysics.Idle();
            }
            IsIdle = true;

            if (!isAlive)
            {
                CurrentAnimationState = new MarioDeadState();
            }

            CurrentAnimationState.Update(gametime);
            MarioPhysics.Update(gametime);
            CheckDeath();

            if (CurrentAnimationState is MarioDeadState)
            {
                deathTimer++;
            }
            if (deathTimer == Util.Instance.TwoHundreds)
            {
                deathTimer = Util.Instance.Zero;
                resetWorld = true;
            }
        }