Exemplo n.º 1
0
        private void LoadGameAssets()
        {
            new GameStringsLoader(_localizedStringsRepository, _gameCulture);

            _assetsLoader = new AssetsLoader(Content);
            _assetsLoader.LoadResources();
            _mousePointer = _assetsLoader.OtherSprites["manina"];
            _soundManager = new SoundManager(_assetsLoader);

            var gameFactory = new Func <InfartGame>(
                () => new InfartGame(
                    _assetsLoader,
                    _soundManager,
                    _orchestrator,
                    _settingsRepository,
                    _localizedStringsRepository));

            var dialogDefinition = new Rectangle(
                _matrixScaleProvider.VirtualWidth / 2 - 350, 24, 700, _matrixScaleProvider.VirtualHeight - 60);

            var rateMeDialog = new RateMeDialog(
                launchesUntilPrompt: 2,
                maxRateShowTimes: 2,
                rateAppUri: _rateMeUri,
                dialogDefinition: dialogDefinition,
                font: _assetsLoader.Font,
                localizedStringsRepository: _localizedStringsRepository,
                rateMeDialogStrings: _gameCulture.TwoLetterISOLanguageName == "it"
                    ? (RateMeDialogStrings) new DefaultItalianRateMeDialogStrings(GameName)
                    : (RateMeDialogStrings) new DefaultEnglishRateMeDialogStrings(GameName),
                webPageOpener: _webPageOpener,
                settingsRepository: _settingsRepository,
                buttonADefinition: new Rectangle(
                    dialogDefinition.X + 150,
                    dialogDefinition.Y + 350,
                    140, 40),
                buttonBDefinition: new Rectangle(
                    dialogDefinition.X + dialogDefinition.Width - 140 - 150,
                    dialogDefinition.Y + 350,
                    140, 40),
                backgroundColor: Color.DarkGray.WithAlpha(1f),
                buttonsBackgroundColor: (new Color(255, 18, 67)).WithAlpha(1f),
                buttonsShadowColor: Color.Black,
                backgroundShadowColor: Color.Black.WithAlpha(1f),
                titleColor: Color.Black,
                buttonsTextColor: new Color(255, 234, 135),
                titlePositionOffset: new Vector2(dialogDefinition.Width / 2, 80f),
                buttonTextPadding: 40f,
                titlePadding: 160f);

            var menuFactory = new Func <MainMenuPage>(
                () => new MainMenuPage(
                    _assetsLoader,
                    rateMeDialog,
                    _soundManager,
                    _matrixScaleProvider,
                    _localizedStringsRepository));

            var scoreFactory = new Func <ScorePage>(
                () => new ScorePage(
                    _assetsLoader,
                    _settingsRepository,
                    _matrixScaleProvider,
                    _localizedStringsRepository));

            _orchestrator = new GameOrchestrator(
                gameFactory,
                menuFactory,
                scoreFactory,
                GraphicsDevice,
                _assetsLoader,
                _settingsRepository,
                _matrixScaleProvider,
                _webPageOpener,
                _localizedStringsRepository);

            _inputListeners = new List <IInputListener>();

            if (_isPc)
            {
                var mouseListener = new MouseListener(_matrixScaleProvider);
                mouseListener.MouseDown += MouseListener_MouseClicked;
                _inputListeners.Add(mouseListener);
            }
            else
            {
                var touchListener = new TouchListener(_matrixScaleProvider);
                touchListener.TouchStarted += TouchListener_TouchEnded;

                var gamepadListener = new GamePadListener();
                gamepadListener.ButtonDown += GamepadListener_ButtonDown;

                _inputListeners.Add(touchListener);
                _inputListeners.Add(gamepadListener);
            }

            var keyboardListener = new KeyboardListener();

            keyboardListener.KeyPressed += KeyboardListener_KeyPressed;
            _inputListeners.Add(keyboardListener);
        }