Example #1
0
        public void Update(GameTime theGameTime, Level level, InputState inputState)
        {
            Acceleration = Vector2.Zero;

            var curstate = mCurrentState;
            CheckCollisions(level, inputState.IsInteracting(null));
            if (curstate == State.Air && (mCurrentState == State.Ground || mCurrentState == State.Platform))
                level.PlaySoundEffect(mLandingEffect);

            UpdateMovement(inputState);
            if (UpdateJump(inputState))
                level.PlaySoundEffect(mJumpEffect);
            UpdateDuck(inputState);

            Acceleration.Y = (mCurrentState == State.Air || mCurrentState == State.GravityPortal  || mCurrentState == State.Portal ? 1 : 0) * level.Gravity * Level.METERS_TO_UNITS;
            if (Angle != 0)
            {
                if(Angle > 0)
                    Angle = (float)Math.Max(0, Angle - Math.PI * theGameTime.ElapsedGameTime.TotalSeconds / 2);
                else
                    Angle = (float)Math.Min(0, Angle + Math.PI * theGameTime.ElapsedGameTime.TotalSeconds / 2);

            }

            base.Update(theGameTime);

            mFlip = mGunhand.Update(inputState.CurrentMouseState, mIsDucking, this, level.Position);
            UpdateProjectile(theGameTime, inputState, level);
        }