protected override void Update(GameTime gameTime)
{
#if true
level.getClientPlayer().EntityPacket = new EntityPacket(level.getClientPlayer()); //DIFFERENCE DETECTION
float x = 0, y = 0;
input.Update(this.IsActive, Mouse.GetState(), Keyboard.GetState(), GamePad.GetState(PlayerIndex.One));
chat.update();
mouseX = (int)input.MousePos.X;
mouseY = (int)input.MousePos.Y;
if (!chat.Open && !menu.Open)
{
if (input.KeyDown(Keys.LeftShift))
{
level.getClientPlayer().speed = 2;
}
else
{
level.getClientPlayer().speed = 1;
}
if (input.KeyDown(Keys.W))
{
y -= level.getClientPlayer().speed;
}
if (input.KeyDown(Keys.A))
{
x -= level.getClientPlayer().speed;
}
if (input.KeyDown(Keys.S))
{
y += level.getClientPlayer().speed;
}
if (input.KeyDown(Keys.D))
{
x += level.getClientPlayer().speed;
}
y += (int)Math.Round(input.CurrentGamepadState.ThumbSticks.Left.Y) * -1;
x += (int)Math.Round(input.CurrentGamepadState.ThumbSticks.Left.X);
if (input.KeyPressed(Keys.PageUp))
{
time.CurrentTime += 0.1f;
}
if (input.KeyPressed(Keys.PageDown))
{
time.CurrentTime -= 0.1f;
}
if (input.KeyPressed(Keys.T))
{
chat.Open = true;
}
if (input.KeyPressed(Keys.L))
{
if (playerlight)
{
playerlight = false;
}
else
{
playerlight = true;
}
}
}
if (input.KeyPressed(Keys.F11))
{
if (graphics.IsFullScreen)
{
graphics.IsFullScreen = false;
ChangeResolution(noFullscreenResolutionW, noFullscreenResolutionH);
}
else
{
graphics.IsFullScreen = true;
noFullscreenResolutionW = screenWidth;
noFullscreenResolutionH = screenHeight;
ChangeResolution(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
}
}
if (input.KeyPressed(Keys.Escape))
{
if (chat.Open)
{
chat.Open = false;
}
if (menu.Open)
{
menu.Open = false;
}
else
{
menu.Open = true;
}
}
switch (currentGamestate)
{
case GameState.Running:
if (input.CurrentMouseState.ScrollWheelValue > input.PreviousMouseState.ScrollWheelValue && input.KeyDown(Keys.LeftControl))
{
camera.AdjustZoom(0.2f);
}
if (input.CurrentMouseState.ScrollWheelValue < input.PreviousMouseState.ScrollWheelValue && input.KeyDown(Keys.LeftControl))
{
camera.AdjustZoom(-0.2f);
}
level.getClientPlayer().Move(new Vector2(x, y));
camera.CenterOn(new Vector2(level.getClientPlayer().Position.X + level.getClientPlayer().width / 2, level.getClientPlayer().Position.Y + level.getClientPlayer().height / 2), true);
inv.Update(input);
break;
case GameState.Editor:
editor.Update();
if (editor.tilesetScroll)
{
editor.moveTileset(new Vector2(x, y));
}
else
{
camera.MoveCamera(new Vector2(x, y));
}
if (editor.currentEditorMode == MapEditor.EditorMode.EntityAdd)
{
inv.Update(input);
}
break;
case GameState.Pause:
break;
}
level.update();
effectmanager.Update(input);
menu.update();
hb.Update(gameTime);
sound.update();
NetCode.Update(); //After all movement !important
input.UpdatePrev();
#endif
base.Update(gameTime);
}