Ejemplo n.º 1
0
        public void OnOpening(object enterInformation)
        {
            var translation = GameInstance.GetService <TranslationProvider>();

            _overlay        = new UiOverlay();
            _pokeballSprite = _overlay.AddElement(new Image(GameInstance.Content.Load <Texture2D>(ResourceNames.Textures.Pokeball)));
            _pokeballSprite.SetPosition(new Vector2(GameInstance.ScreenBounds.Width, GameInstance.ScreenBounds.Height) * 0.5f);
            _pokeballSprite.SetOriginPercentage(new Vector2(0.5f));
            _pokeballSprite.EnterAnimation = new UiScaleAnimation(0.5f, Vector2.Zero, Vector2.One);
            _pokeballSprite.LeaveAnimation = new UiScaleAnimation(0.5f, Vector2.One, Vector2.Zero);
            _pokeballSprite.Scale          = Vector2.Zero;
            _pokeballSprite.AddCustomAnimation("Rotating", new UiRotationAnimation(0.5f, 0.0f, MathHelper.TwoPi), true);

            var loadingText = _overlay.AddElement(new StaticText(GameInstance.Content.Load <SpriteFont>(ResourceNames.Fonts.BigFont), translation.CreateValue("System", "GameLoadingMessage")));

            loadingText.SetPosition(new Vector2(GameInstance.ScreenBounds.Width * 0.5f, 400));
            loadingText.SetOriginPercentage(new Vector2(0.5f, 0.0f));
            loadingText.EnterAnimation = new UiAlphaAnimation(0.4f, 0.0f, 1.0f);
            loadingText.LeaveAnimation = new UiAlphaAnimation(0.4f, 1.0f, 0.0f);
            loadingText.Alpha          = 0.0f;

            _overlay.Showed += OverlayOnShowed;
            _overlay.Hidden += OnHidden;
            _overlay.Show();
        }
Ejemplo n.º 2
0
        public void OnOpening(object enterInformation)
        {
            if (!_isLoaded)
            {
                ActiveWorld = enterInformation as World;
                if (ActiveWorld == null)
                {
                    throw new InvalidOperationException("Did not receive loaded data.");
                }

                _renderStatisticsOverlay = new UiOverlay();
                _renderStatisticsOverlay.AddElement(new RenderStatisticsView(ActiveWorld));

                GameInstance.LoadedSave = TestMock.CreateTempSave();
                GameInstance.LoadedSave.Load(GameInstance.GetService <GameModeManager>().ActiveGameMode);

                _isLoaded = true;
            }

            _inputSystem      = GameInstance.GetService <InputSystem>();
            _screenManager    = GameInstance.GetService <ScreenManager>();
            _sceneRenderer    = GameInstance.GetService <SceneRenderer>();
            _collisionManager = GameInstance.GetService <CollisionManager>();
            _spriteBatch      = GameInstance.GetService <SpriteBatch>();
            _shapeRenderer    = GameInstance.GetService <ShapeRenderer>();
        }
Ejemplo n.º 3
0
        public void OnOpening(object enterInformation)
        {
            _overlay = new UiOverlay();
            var logoSprite = _overlay.AddElement(new Image(GameInstance.Content.Load<Texture2D>(ResourceNames.Textures.SquareLogo_256px)));
            logoSprite.SetPosition(new Vector2(GameInstance.ScreenBounds.Width * 0.5f, GameInstance.ScreenBounds.Height * 0.5f));
            logoSprite.SetOriginPercentage(new Vector2(0.5f));

            var highlightSprite = _overlay.AddElement(new Image(GameInstance.Content.Load<Texture2D>(ResourceNames.Textures.highlight)));
            highlightSprite.Alpha = 0.0f;
            highlightSprite.AddCustomAnimation("Highlight", new UiCustomDeltaAnimation(1.5f, OnUpdateHighlightPass));
            highlightSprite.CustomAnimationFinshed += CustomAnimationFinished;
            highlightSprite.SetPosition(new Vector2(GameInstance.ScreenBounds.Width * 0.5f+30, GameInstance.ScreenBounds.Height * 0.5f-160));

            logoSprite.EnterAnimation = new UiMultiAnimation(new UiAnimation[]
            {
                new UiAlphaAnimation(1.0f, 0.0f, 1.0f),
                new UiRotationAnimation(1.0f, 0.0f, MathHelper.TwoPi), 
            });
            
            _overlay.Showed += () => highlightSprite.PlayCustomAnimation("Highlight");
            _overlay.Show();
        }
Ejemplo n.º 4
0
        public void OnOpening(object enterInformation)
        {
            _overlay = new UiOverlay();
            var logoSprite = _overlay.AddElement(new Image(GameInstance.Content.Load <Texture2D>(ResourceNames.Textures.SquareLogo_256px)));

            logoSprite.SetPosition(new Vector2(GameInstance.ScreenBounds.Width * 0.5f, GameInstance.ScreenBounds.Height * 0.5f));
            logoSprite.SetOriginPercentage(new Vector2(0.5f));

            var highlightSprite = _overlay.AddElement(new Image(GameInstance.Content.Load <Texture2D>(ResourceNames.Textures.highlight)));

            highlightSprite.Alpha = 0.0f;
            highlightSprite.AddCustomAnimation("Highlight", new UiCustomDeltaAnimation(1.5f, OnUpdateHighlightPass));
            highlightSprite.CustomAnimationFinshed += CustomAnimationFinished;
            highlightSprite.SetPosition(new Vector2(GameInstance.ScreenBounds.Width * 0.5f + 30, GameInstance.ScreenBounds.Height * 0.5f - 160));

            logoSprite.EnterAnimation = new UiMultiAnimation(new UiAnimation[]
            {
                new UiAlphaAnimation(1.0f, 0.0f, 1.0f),
                new UiRotationAnimation(1.0f, 0.0f, MathHelper.TwoPi),
            });

            _overlay.Showed += () => highlightSprite.PlayCustomAnimation("Highlight");
            _overlay.Show();
        }
Ejemplo n.º 5
0
        protected override void OnInitialize(object enterInformation)
        {
            base.OnInitialize(enterInformation);
            _splash = new TimedSplash(Game);

            _mainOverlay = new UiOverlay();
            _mainOverlay.AddElement(new NinePatchImage(new NinePatchSprite(Game.Content.Load <Texture2D>("textures/border"), 12, 12), new Rectangle(0, 200, 200, 220)));
            _mainOverlay.AddElement(new Button2(Game, "Local Game", new Rectangle(20, 215, 160, 35), () => DoTransition(typeof(LocalGameConfigurationState))));
            _mainOverlay.AddElement(new Button2(Game, "Network Game", new Rectangle(20, 250, 160, 35), () => DoTransition(typeof(NetworkGameState))));
            _mainOverlay.AddElement(new Button2(Game, "Options", new Rectangle(20, 285, 160, 35), () => DoTransition(typeof(OptionMenuState))));
            _mainOverlay.AddElement(new Button2(Game, "Credits", new Rectangle(20, 320, 160, 35), () => DoTransition(typeof(CreditsState))));
            _mainOverlay.AddElement(new Button2(Game, "Quit", new Rectangle(20, 355, 160, 35), OnQuitClicked));
            _mainOverlay.Center(Game.GetScreenRectangle(), false, true);
            _mainOverlay.AddInputController(new KeyboardInputController(Game));
            _mainOverlay.AddInputController(new MouseInputController(Game));
        }
Ejemplo n.º 6
0
        public void OnOpening(object enterInformation)
        {
            if (!_isLoaded)
            {
                ActiveWorld = enterInformation as World;
                if (ActiveWorld == null) throw new InvalidOperationException("Did not receive loaded data.");

                _renderStatisticsOverlay = new UiOverlay();
                _renderStatisticsOverlay.AddElement(new RenderStatisticsView(ActiveWorld));

                GameInstance.LoadedSave = TestMock.CreateTempSave();
                GameInstance.LoadedSave.Load(GameInstance.GetService<GameModeManager>().ActiveGameMode);

                _isLoaded = true;
            }

            _inputSystem = GameInstance.GetService<InputSystem>();
            _screenManager = GameInstance.GetService<ScreenManager>();
            _sceneRenderer = GameInstance.GetService<SceneRenderer>();
            _collisionManager = GameInstance.GetService<CollisionManager>();
            _spriteBatch = GameInstance.GetService<SpriteBatch>();
            _shapeRenderer = GameInstance.GetService<ShapeRenderer>();
        }
Ejemplo n.º 7
0
        protected override void LoadContent()
        {
            base.LoadContent();

            IsMouseVisible = true;

            var renderSettings = new RenderSettings
            {
                EnableShadows     = _gameConfig.ShadowsEnabled,
                EnableSoftShadows = _gameConfig.SoftShadows,
                ShadowMapSize     = 1024 // todo: reenable
            };

            RegisterService(GraphicsDevice);
            _renderer = RegisterService(SceneRendererFactory.Create(this, new WindowsSceneEffect(Content), renderSettings));
            RegisterService(new GameModeManager());
            _spriteBatch = RegisterService(new SpriteBatch(GraphicsDevice));
            _inputSystem = RegisterService(new InputSystem());
            RegisterService(new ShapeRenderer(_spriteBatch));
            _screenManager = RegisterService(new ScreenManager());
            RegisterService <TranslationProvider>(new TranslationProviderImp());
            _collisionManager = RegisterService(new CollisionManager());

            _notificationBarOverlay = new UiOverlay();
            RegisterService(_notificationBarOverlay.AddElement(new NotificationBar(400)));
            _notificationBarOverlay.Show();

#if DEBUG_RENDERING
            _collisionManager.DrawDebugShapes = true;
#endif
#if DEBUG
            GetService <ScreenManager>().SetScreen(typeof(MainMenuScreen));
#else
            ScreenManager.SetScreen(typeof(IntroScreen));
#endif
            GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
        }
Ejemplo n.º 8
0
        public void OnOpening(object enterInformation)
        {
            var graphicsDeviceManager = GameInstance.GetService <GraphicsDeviceManager>();

            graphicsDeviceManager.PreferMultiSampling = true;
            graphicsDeviceManager.ApplyChanges();

            _mainOverlay = new UiOverlay();

            var translation = GameInstance.GetService <TranslationProvider>();

            _mainOverlay.AddElement(new HexagonBackground());
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "StartNewGame"), new Vector2(26, 45), OnStartNewGame));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "LoadGame"), new Vector2(26, 107), OnLoadGame));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "Gamejolt"), new Vector2(26, 169), null));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "Options"), new Vector2(26, 231), null));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "QuitGame"), new Vector2(26, 293), OnExitGame));

            _mainOverlay.AddInputController(new KeyboardUiInputController());
            _mainOverlay.AutoEnumerateTabIndices();

            _closeDialog = new SelectionDialog(translation.CreateValue("System", "ReallyQuitGameQuestion"), translation.CreateValue("System", "UnsavedChangesLost"), new[]
            {
                new LeftSideButton(translation.CreateValue("System", "No"), new Vector2(50, 50), b =>
                {
                    _mainOverlay.CloseModal();
                }),
                new LeftSideButton(translation.CreateValue("System", "Yes"), new Vector2(50, 100), b =>
                {
                    GameInstance.GetService <ScreenManager>().NotifyQuitGame();
                })
            });

            var bar = new ControlBar();

            bar.AddEntry(translation.CreateValue("System", "Select"), Buttons.A, Keys.Enter);
            _mainOverlay.AddElement(bar);
            _mainOverlay.Show();
        }
Ejemplo n.º 9
0
        public void OnOpening(object enterInformation)
        {
            var graphicsDeviceManager = GameInstance.GetService<GraphicsDeviceManager>();
            graphicsDeviceManager.PreferMultiSampling = true;
            graphicsDeviceManager.ApplyChanges();

            _mainOverlay = new UiOverlay();

            var translation = GameInstance.GetService<TranslationProvider>();

            _mainOverlay.AddElement(new HexagonBackground());
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "StartNewGame"), new Vector2(26, 45), OnStartNewGame));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "LoadGame"), new Vector2(26, 107), OnLoadGame));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "Gamejolt"), new Vector2(26, 169), null));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "Options"), new Vector2(26, 231), null));
            _mainOverlay.AddElement(new LeftSideButton(translation.CreateValue("System", "QuitGame"), new Vector2(26, 293), OnExitGame));

            _mainOverlay.AddInputController(new KeyboardUiInputController());
            _mainOverlay.AutoEnumerateTabIndices();

            _closeDialog = new SelectionDialog(translation.CreateValue("System", "ReallyQuitGameQuestion"), translation.CreateValue("System", "UnsavedChangesLost"), new[]
            {
                new LeftSideButton(translation.CreateValue("System", "No"), new Vector2(50, 50), b =>
                {
                    _mainOverlay.CloseModal();
                }),
                new LeftSideButton(translation.CreateValue("System", "Yes"), new Vector2(50, 100), b =>
                {
                    GameInstance.GetService<ScreenManager>().NotifyQuitGame();
                })
            });

            var bar = new ControlBar();
            bar.AddEntry(translation.CreateValue("System", "Select"), Buttons.A, Keys.Enter);
            _mainOverlay.AddElement(bar);
            _mainOverlay.Show();
        }