public Level(IServiceProvider serviceProvider, SpriteBatch spriteBatch, Vector2 baseScreenSize) { _baseScreenWidth = (int)baseScreenSize.X; _baseScreenHeight = (int)baseScreenSize.Y; _numberOfTilesWidth = _baseScreenWidth / Tile.Width; _numberOfTilesHeight = _baseScreenHeight / Tile.Height; _helperStruct = new HelperStruct(); _helperStruct.NumberOfTilesWidth = _numberOfTilesWidth; _helperStruct.NumberOfTilesHeight = _numberOfTilesHeight; _helperStruct.isPlayerMoveRight = false; _helperStruct.isPlayerMoveLeft = false; _helperStruct.isPlayerMoveUp = false; _helperStruct.isPlayerMoveDown = false; _content = new ContentManager(serviceProvider, "Content"); _spriteBatch = spriteBatch; _availableTile = Content.Load<Texture2D>("Tiles/AvailableTile"); _unAvailableTile = Content.Load<Texture2D>("Tiles/UnAvailableTile"); _pathTile = Content.Load<Texture2D>("Tiles/PathTile"); _targetTile = Content.Load<Texture2D>("Tiles/TargetTile"); _player = new Player(serviceProvider, spriteBatch, baseScreenSize, _helperStruct); }
public Player(IServiceProvider serviceProvider, SpriteBatch spriteBatch, Vector2 baseScreenSize, HelperStruct helperStruct) { _content = new ContentManager(serviceProvider, "Content"); _spriteBatch = spriteBatch; _baseScreenWidth = (int)baseScreenSize.X; _baseScreenHeight = (int)baseScreenSize.Y; _helperStruct = helperStruct; if (_characterTexture == null) _characterTexture = _content.Load<Texture2D>("Sprites/Player/Player"); _walkDown = new Animation(); _walkDown.AddFrame(new Rectangle(0, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(80, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(160, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(240, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(320, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(400, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(480, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(560, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkDown.AddFrame(new Rectangle(640, 160, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp = new Animation(); _walkUp.AddFrame(new Rectangle(0, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(80, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(160, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(240, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(320, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(400, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(480, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(560, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkUp.AddFrame(new Rectangle(640, 0, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft = new Animation(); _walkLeft.AddFrame(new Rectangle(0, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(80, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(160, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(240, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(320, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(400, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(480, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(560, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkLeft.AddFrame(new Rectangle(640, 80, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight = new Animation(); _walkRight.AddFrame(new Rectangle(0, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(80, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(160, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(240, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(320, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(400, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(480, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(560, 240, 80, 80), TimeSpan.FromSeconds(.25)); _walkRight.AddFrame(new Rectangle(640, 240, 80, 80), TimeSpan.FromSeconds(.25)); // Standing animations only have a single frame of animation: _standDown = new Animation (); _standDown.AddFrame(new Rectangle(0, 160, 80, 80), TimeSpan.FromSeconds(.25)); _standUp = new Animation (); _standUp.AddFrame(new Rectangle(0, 0, 80, 80), TimeSpan.FromSeconds(.25)); _standLeft = new Animation (); _standLeft.AddFrame(new Rectangle(0, 80, 80, 80), TimeSpan.FromSeconds(.25)); _standRight = new Animation (); _standRight.AddFrame(new Rectangle(0, 240, 80, 80), TimeSpan.FromSeconds(.25)); _currentAnimation = new Animation(); _currentAnimation = _walkRight; }