예제 #1
0
        public void Update(GameTime gameTime)
        {
            _rotationMatrix = Matrix.CreateRotationX(Camera.UpDownRotation) * Matrix.CreateRotationY(Camera.LeftRightRotation);
            _lookVector     = Vector3.Transform(Vector3.Forward, _rotationMatrix);
            //Debug.WriteLine("_lookVector " + _lookVector);

            _lookVector.Normalize();

            UpdateParticles(gameTime);
            UpdateSounds();

            PlayerIndex controlIndex;

            if (_game.InputState.IsKeyDown(Keys.Space, _game.ActivePlayerIndex, out controlIndex))
            {
                Vector3 footPosition = _position + new Vector3(0f, -1.5f, 0f);
                //XXX fly mode
                //if (_world.SolidAtPoint(footPosition) &&  _playerVelocity.Y == 0)
                //{
                _playerVelocity.Y = WorldSettings.PLAYERJUMPVELOCITY;
                float amountBelowSurface = ((ushort)footPosition.Y) + 1 - footPosition.Y;
                _position.Y += amountBelowSurface + 0.01f;
                //}
            }

            if (_game.InputState.IsKeyPressed(Keys.Up, _game.ActivePlayerIndex, out controlIndex))
            {
                _world.CURRENTMAPLEVEL++;
                _world.AddFloor();
            }
            if (_game.InputState.IsKeyPressed(Keys.Down, _game.ActivePlayerIndex, out controlIndex))
            {
                _world.CURRENTMAPLEVEL--;
                _world.RemoveFloor();
            }

            if (_onBlockSlection)
            {
                _blockSelection.FindAimedBlock();
            }

            UpdatePosition(gameTime);

            float headbobOffset = (float)Math.Sin(_headBob) * 0.06f;

            Camera.Position = _position; //+ new Vector3(0, 0.15f + headbobOffset, 0);

            CheckBuild(gameTime);

            _previousMouseState = Mouse.GetState();
        }