public PlayerWorldCollisionComponent(MinerGame game,Player parentObject)
     : base(game, parentObject)
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Konstruktor służący do przekazywania obiektu gracza między poziomami
 /// </summary>
 /// <param name="game"></param>
 /// <param name="name"></param>
 /// <param name="player"></param>
 public Level(MinerGame game, string name, Player player)
 {
     _game = game;
     Name = name;
     Player = player;
 }
Esempio n. 3
0
        /// <summary>
        /// Ładuje poziom z pliku xml.
        /// </summary>
        public void Initialize()
        {
            var levelData = LevelData.Deserialize(GetLevelPath(Name));

            if (_saveData != null)
            {
                levelData.Objects = _saveData.GameObjects;

                _backgroundTexture = !String.IsNullOrEmpty(levelData.Background) ? _game.Content.Load<Texture2D>("Backgrounds/" + levelData.Background) : null;
                Player = new Player(_game)
                {
                    Oxygen = _saveData.Player.Oxygen,
                    Lives = _saveData.Player.Lives,
                    Dynamite = _saveData.Player.Dynamite,
                    Position = _saveData.Player.Position,
                    Points = _saveData.Player.Points
                };

                _keyCollected = _saveData.KeyCollected;
            }

            _backgroundTexture = !String.IsNullOrEmpty(levelData.Background) ? _game.Content.Load<Texture2D>("Backgrounds/" + levelData.Background) : null;
            _levelMusic = _game.Content.Load<Song>("Sounds/music");
            _levelEndMusic = _game.Content.Load<Song>("Sounds/level_end");
            SoundHelper.Play(_levelMusic,true);

            InitializePlayer(levelData);
            InitializeGameObjects(levelData, _saveData != null);
            InitializeTileMap(levelData);

            _cartGenerator = new CartGenerator(_game);
            Camera = new Camera(_game.GraphicsDevice.Viewport, this, Player);
            Size = new Vector2(Tiles.GetLength(0) * _tileDimensions.X, Tiles.GetLength(1) * _tileDimensions.Y);
        }
Esempio n. 4
0
        /// <summary>
        /// Tworzy (jeśli nie przekazano w konstrukotrze) i inicjalizuje obiekt gracza
        /// </summary>
        /// <param name="levelData"></param>
        private void InitializePlayer(LevelData levelData)
        {
            PlayerStartPosition = levelData.PlayerStartPosition;

            if (Player == null)
            {
                Player = new Player(_game);
            }
            Player.Respawn(PlayerStartPosition);

            Player.Died += PlayerDied;
            Player.DynamiteSet += PlayerSetDynamite;
        }
Esempio n. 5
0
 public Camera(Viewport viewport, Level level, Player playerToFollow)
 {
     _viewport = viewport;
     _level = level;
     _playerToFollow = playerToFollow;
 }