Beispiel #1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var ballTexture = Content.Load <Texture2D>(ASSET_NAME_BALL);

            _ball = new BallEntity(ballTexture, new Vector2(BALL_POS_X, BALL_POS_Y));

            _ballManager = new BallManager(_ball);

            var groundTexture = Content.Load <Texture2D>(ASSET_NAME_GROUND);

            _groundManager = new GroundManager(groundTexture, _ball, _entityManager);

            _ballInputController = new BallInputController(_ball);

            _scoreBoardFont = Content.Load <SpriteFont>(ASSET_NAME_SCORE_BOARD_FONT);
            _scoreBoard     = new ScoreBoardEntity(_scoreBoardFont, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), _ball);

            var wallTexture = Content.Load <Texture2D>(ASSET_NAME_WALL);

            _wallManager = new WallManager(wallTexture, _ball, _scoreBoard, _entityManager);

            _coinPickupSoundEffect = Content.Load <SoundEffect>(ASSET_NAME_COIN_PICKUP);

            _rotatingCoinAnimation = new TextureAnimation();

            _coin0 = Content.Load <Texture2D>(ASSET_NAME_COIN_0);
            _coin1 = Content.Load <Texture2D>(ASSET_NAME_COIN_1);
            _coin2 = Content.Load <Texture2D>(ASSET_NAME_COIN_2);
            _coin3 = Content.Load <Texture2D>(ASSET_NAME_COIN_3);
            _coin4 = Content.Load <Texture2D>(ASSET_NAME_COIN_4);

            _rotatingCoinAnimation.AddFrame(_coin0, ROTATING_COIN_ANIMATION_FRAME_DURATION);
            _rotatingCoinAnimation.AddFrame(_coin1, ROTATING_COIN_ANIMATION_FRAME_DURATION * 2);
            _rotatingCoinAnimation.AddFrame(_coin2, ROTATING_COIN_ANIMATION_FRAME_DURATION * 3);
            _rotatingCoinAnimation.AddFrame(_coin3, ROTATING_COIN_ANIMATION_FRAME_DURATION * 4);
            _rotatingCoinAnimation.AddFrame(_coin4, ROTATING_COIN_ANIMATION_FRAME_DURATION * 5);

            _rotatingCoinAnimation.Play();

            _coinManager = new CoinManager(_coin0, _ball, _scoreBoard, _entityManager, _coinPickupSoundEffect,
                                           _rotatingCoinAnimation);



            _entityManager.AddEntity(_ball);
            _entityManager.AddEntity(_ballManager);
            _entityManager.AddEntity(_groundManager);
            _entityManager.AddEntity(_scoreBoard);
            _entityManager.AddEntity(_wallManager);
            _entityManager.AddEntity(_coinManager);

            _groundManager.Initialize();
        }