public void Update(GameTime gameTime,InputHelper input) { if (_game.Game.IsActive) { if (input.IsNewPress((Keys)ClientKey.Debug)) { Enabled = !Enabled; } } }
public override void Update(GameTime gameTime,InputHelper input) { if (Gamemanager.Game.IsActive) { //Lets see if we need to end this game if (input.IsNewPress((Keys)ClientKey.Exit)) { Gamemanager.Pbag.Client.Disconnect("exit"); Gamemanager.SwitchState(GameState.MainMenuState); } if (input.IsNewPress((Keys)ClientKey.FullScreen)) { Gamemanager.Graphics.ToggleFullScreen(); } } //Update chunks to load close ones, unload far ones Gamemanager.Pbag.WorldManager.Update(gameTime,input); Gamemanager.Pbag.Player.Update(gameTime, input); Gamemanager.Pbag.Debugger.Update(gameTime, input); }
public override void Update(GameTime gameTime, InputHelper input) { _loadingangle += 0.01f; if (input.IsNewPress((Keys)ClientKey.Exit)) { _gamemanager.SwitchState(GameState.MainMenuState); } //If everything is loaded then lets play if (_gamemanager.Pbag.WorldManager.Everythingloaded()) { _gamemanager.SwitchState(GameState.MainGameState); //gamemanager.Pbag.ClientSender.SendPlayerInWorld(); } }
public void Update(GameTime gamefTime,InputHelper input) { //fTime increases at rate of 1 ingame day/night cycle per 20 minutes (actual value is 0 at dawn, 0.5pi at noon, pi at dusk, 1.5pi at midnight, and 0 or 2pi at dawn again) FTime += (float)(Math.PI / 36000); FTime %= MathHelper.TwoPi; foreach (Chunk c in Chunks) { c.Update(Player.Position,FTime); } //Update our moon and sun for the correct offset _sun.Update(FTime, _gamemanager.Pbag.Player.Position); _moon.Update(FTime, _gamemanager.Pbag.Player.Position); if (_gamemanager.Game.IsActive) { if (input.IsNewPress((Keys)ClientKey.WireFrame)) { _gamemanager.Pbag.WireMode = !_gamemanager.Pbag.WireMode; } } }
public void Update(GameTime gtime, InputHelper input) { if (_game.GameManager.Game.IsActive) { if (NoClip) //If noclipped { if (input.IsCurPress(Keys.LeftShift)) { Speed = 1.0f; } else { Speed = 0.5f; } if (input.IsCurPress((Keys)ClientKey.MoveForward)) { Position -= Cam.Forward * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveLeft)) { Position -= Cam.Right * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveBack)) { Position += Cam.Forward * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveRight)) { Position += Cam.Right * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveUp)) { Position += Vector3.Up * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveDown)) { Position += Vector3.Down * Speed; } } else { //if (input.IsCurPress(Keys.W)) //{ // Position -= Cam.Forward * Speed; //} //if (input.IsCurPress(Keys.A)) //{ // Position -= Cam.Right * Speed; //} //if (input.IsCurPress(Keys.S)) //{ // Position += Cam.Forward * Speed; //} //if (input.IsCurPress(Keys.D)) //{ // Position += Cam.Right * Speed; //} ////Execute standard movement //Vector3 footPosition = Position + new Vector3(0f, -1.5f, 0f); //Vector3 headPosition = Position + new Vector3(0f, 0.1f, 0f); //Vector3 midPosition = Position + new Vector3(0f, -0.7f, 0f); //if (game.WorldManager.BlockAtPoint(headPosition) == BlockTypes.Water) //{ // bUnderwater = true; //} //else //{ // bUnderwater = false; //} //vPlayerVel.Y += Gravity * (float)gtime.ElapsedGameTime.TotalSeconds; //if (game.WorldManager.SolidAtPointForPlayer(footPosition) || game.WorldManager.SolidAtPointForPlayer(headPosition)) //{ // BlockTypes standingOnBlock = game.WorldManager.BlockAtPoint(footPosition); // BlockTypes hittingHeadOnBlock = game.WorldManager.BlockAtPoint(headPosition); // // If the player has their head stuck in a block, push them down. // if (game.WorldManager.SolidAtPointForPlayer(headPosition)) // { // int blockIn = (int)(headPosition.Y); // Position.Y = (blockIn - 0.15f); // } // // If the player is stuck in the ground, bring them out. // // This happens because we're standing on a block at -1.5, but stuck in it at -1.4, so -1.45 is the sweet spot. // if (game.WorldManager.SolidAtPointForPlayer(footPosition)) // { // int blockOn = (int)(footPosition.Y); // Position.Y = (float)(blockOn + 1 + 1.45); // } // vPlayerVel.Y = 0; //} } } //Re-initialize aim and aimblock vectors VAim = new Vector3(); VAimBlock = new Vector3(); //Check along a path stemming from the camera's forward if there is a collision for (float i = 0; i <= 6; i += 0.01f) { if (i < 5.5f) { VAim = Cam.Position - Cam.Forward * i; try { BaseBlock select = _game.WorldManager.BlockAtPoint(VAim); if (select.AimSolid) { break; //If there is, break the loop with the current aim vector } } catch { VAim = new Vector3(-10, -10, -10); break; } } else { VAim = new Vector3(-10, -10, -10); } } //Otherwise set it to be an empty vector if (VAim != new Vector3(-10, -10, -10)) { VAimBlock = new Vector3((int)Math.Floor(VAim.X), (int)Math.Floor(VAim.Y), (int)Math.Floor(VAim.Z)); //Get the aim block based off of that aim vector } Cam.Position = Position; if (_game.GameManager.Game.IsActive) { if (Mousehasfocus) { if (!input.IsCurPress(Keys.LeftAlt)) { Cam.Rotate( //Rotate the camera based off of mouse position, set mouse position to be screen center MathHelper.ToRadians((input.MousePosition.Y - _game.GameManager.Device.DisplayMode.Height / 2) * Sensitivity * 0.1f), MathHelper.ToRadians((input.MousePosition.X - _game.GameManager.Device.DisplayMode.Width / 2) * Sensitivity * 0.1f), 0.0f ); Mouse.SetPosition(_game.GameManager.Device.DisplayMode.Width / 2, _game.GameManager.Device.DisplayMode.Height / 2); } else { Mousehasfocus = false; } } else { Mousehasfocus = true; } } else { Mousehasfocus = false; } CreateFaceMarker(); //Create the face marker's vertices - I need to redo this method if (input.IsNewPress((MouseButtons)ClientKey.ActionOne)) { //We cant do a thing with empty hand if (LeftHand != null) { LeftHand.Use(); } } if (input.IsNewPress((MouseButtons)ClientKey.ActionTwo)) { //We cant do a thing with empty hand if (RightHand != null) { RightHand.Use(); } } if (input.MouseScrollWheelVelocity < 0f) { Selectedblock -= 1; if (Selectedblock < 0) { Selectedblock = 0; } Selectedblocktype = (BlockTypes)Selectedblock; } if (input.MouseScrollWheelVelocity > 0f) { Selectedblock += 1; if (Selectedblock > 63) { Selectedblock = 63; } Selectedblocktype = (BlockTypes)Selectedblock; } //Update our camera Cam.Update(); //Send our position to the server _game.ClientSender.SendMovementUpdate(); }