public override void Load(ContentManager content) { var playerTexture = content.Load <Texture2D>("avatar"); var initialPosition = _dungeon.GetInitialPlayerPosition(); base.LoadContent(playerTexture, initialPosition); _dungeon.UpdateFieldOfView(this); }
public ISpriteGamePadState HandleInput(Sprite player, GamePadCapabilities cap, GamePadState state) { ICamera camera = ServiceLocator <ICamera> .GetService(); Vector2 newLocation, cameraVector; if (state.ThumbSticks.Left.X < -SpeedThreshold) { newLocation = new Vector2(player.Location.X - _playerSpeed, player.Location.Y); cameraVector = new Vector2(_playerSpeed, 0.0f); } else if (state.ThumbSticks.Left.X > SpeedThreshold) { newLocation = new Vector2(player.Location.X + _playerSpeed, player.Location.Y); cameraVector = new Vector2(-_playerSpeed, 0.0f); } else if (state.ThumbSticks.Left.Y < -SpeedThreshold) { newLocation = new Vector2(player.Location.X, player.Location.Y + _playerSpeed); cameraVector = new Vector2(0.0f, -_playerSpeed); } else if (state.ThumbSticks.Left.Y > SpeedThreshold) { newLocation = new Vector2(player.Location.X, player.Location.Y - _playerSpeed); cameraVector = new Vector2(0.0f, _playerSpeed); } else { return(new StandingState()); } if (WithinBounds(player, newLocation)) { player.Location = newLocation; camera.FollowSprite(player, cameraVector); _dungeon.UpdateFieldOfView(player); } return(null); }