public void Update(GameTime gameTime)
{
var x = this.Position.X * 32;
var y = this.Position.Y * 32;
if (x == this.Sprite.Position.X && y == this.Sprite.Position.Y)
{
this.CanMove = true;
this.Camera.Update(this.PlayerSpeed, gameTime);
return;
}
var position = this.Sprite.Position;
if (x < this.Sprite.Position.X)
{
position.X = this.Sprite.Position.X - (this.PlayerSpeed * gameTime.UpdateTime);
if (x >= position.X)
{
this.CanMove = true;
position.X = x;
}
}
else if (x > this.Sprite.Position.X)
{
position.X = this.Sprite.Position.X + (this.PlayerSpeed * gameTime.UpdateTime);
if (x <= position.X)
{
this.CanMove = true;
position.X = x;
}
}
if (y < this.Sprite.Position.Y)
{
position.Y = this.Sprite.Position.Y - (this.PlayerSpeed * gameTime.UpdateTime);
if (y >= position.Y)
{
this.CanMove = true;
position.Y = y;
}
}
else if (y > this.Sprite.Position.Y)
{
position.Y = this.Sprite.Position.Y + (this.PlayerSpeed * gameTime.UpdateTime);
if (y <= position.Y)
{
this.CanMove = true;
position.Y = y;
}
}
this.Sprite.Position = position;
this.Camera.Update(this.PlayerSpeed, gameTime);
}