Esempio n. 1
0
        public World(int viewportWidth, int viewportHeight, float scale)
        {
            _boxLength *= scale;
            _startPositionForNewBall = new Vector2(viewportWidth / 2f, (viewportHeight/3f) * 2f);

            _viewportRect = new Rectangle(0, 0,
                viewportWidth,
                viewportHeight);
            _ballsModel = new BallsModel(this, (int)_boxLength, (int)_boxLength, _startPositionForNewBall, _startDirectionForNewBall);
            _frameModel = new FrameModel(this);
            _playerModel = new PlayerModel(this, scale);
            CurrentLevel = LoadLevel(1, scale);
            CurrentState = GameState.Normal;
        }
Esempio n. 2
0
        public LevelModel LoadLevel(int levelNumber)
        {
            var levelData = _levelSerializer.LoadFromFile(levelNumber);

            var level = new LevelModel { LevelNumber = levelData.LevelNumber };

            foreach (var brickData in levelData.Bricks)
            {
                level.AddBrick(brickData,
                    ConvertColumnNumberToXPosition(brickData.ColumnNumber),
                    ConvertRowNumberToYPosition(brickData.RowNumber),
                    _scale);
            }

            return level;
        }
Esempio n. 3
0
 public void LoadLevel(LevelModel levelModel)
 {
     CurrentLevel = levelModel;
 }