Пример #1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            _sfxHit           = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT);
            _sfxButtonPress   = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS);
            _sfxScoredReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED);

            _spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET);
            _fadeInTexture      = new Texture2D(GraphicsDevice, 1, 1);
            _fadeInTexture.SetData(new Color[] { Color.White });

            _tRex               = new TRex(_spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - TRex.GetHeight()), _sfxButtonPress);
            _tRex.DrawOrder     = 10;
            _tRex.JumpComplete += tRex_JumpComplete;
            _tRex.Died         += tRex_Died;

            _scoreBoard = new ScoreBoard(_spriteSheetTexture, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_y), _tRex);

            _inputController = new InputController(_tRex);

            _groundManager   = new GroundManager(_spriteSheetTexture, _entityManager, _tRex);
            _obstacleManager = new ObstacleManager(_entityManager, _tRex, _scoreBoard, _spriteSheetTexture);

            _gameOverScreen          = new GameOverScreen(_spriteSheetTexture, this);
            _gameOverScreen.Position = new Vector2(WINDOW_WIDTH / 2 - GameOverScreen.GAME_OVER_SPRITE_WIDTH / 2, WINDOW_HEIGHT / 2 - 30);

            _entityManager.AddEntity(_tRex);
            _entityManager.AddEntity(_groundManager);
            _entityManager.AddEntity(_scoreBoard);
            _entityManager.AddEntity(_obstacleManager);
            _entityManager.AddEntity(_gameOverScreen);

            _groundManager.Initialize();
        }