Exemplo n.º 1
0
 public ResultScreen(Game1 game, GameplayScreenState gameplayState, Texture2D background) : base(game)
 {
     this.gameplayState = gameplayState;
     this.background    = background;
     panel = new UIPanel(game)
     {
         Position = new Vector2(100, 100),
         Size     = Game.WindowSize - new Vector2(200, 200),
     };
 }
Exemplo n.º 2
0
        public GameplayHelpScreen(Game1 game, GameResources resources, GameplayScreenState gameplayState, Texture2D background) : base(game)
        {
            this.gameplayState = gameplayState;
            this.background    = background;

            panel = new UIPanel(game)
            {
                Position = new Vector2(100, 100),
                Size     = Game.WindowSize - new Vector2(200, 200),
            };

            helpPages = new HelpPage[] {
                new HelpPage1(resources, game),
                new HelpPage2(resources, game),
                new HelpPage3(resources, game),
            };

            prevButton = new UIButton(resources)
            {
                Position = new Vector2(180, Game.WindowSize.Y - 150),
                Size     = new Vector2(100, 50),
                Text     = "Prev",
            };
            prevButton.OnClick += () =>
            {
                State.CurrentPage--;
            };

            nextButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X - 180, Game.WindowSize.Y - 150),
                Size     = new Vector2(100, 50),
                Text     = "Next",
            };
            nextButton.OnClick += () =>
            {
                State.CurrentPage++;
            };
        }
Exemplo n.º 3
0
        public GameplayPauseScreen(Game1 game, GameResources resources, GameplayScreenState gameplayState, Texture2D background) : base(game)
        {
            this.gameplayState = gameplayState;
            this.background    = background;

            panel = new UIPanel(game)
            {
                Position = new Vector2(100, 100),
                Size     = Game.WindowSize - new Vector2(200, 200),
            };

            continueGameButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 2, 250),
                Size     = new Vector2(200, 100),
                Text     = "Continue",
            };
            continueGameButton.OnClick += () =>
            {
                ReturnToGame();
            };

            saveButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 4, 250),
                Size     = new Vector2(200, 100),
                Text     = "Save",
            };
            saveButton.OnClick += () =>
            {
                string json = JsonConvert.SerializeObject(this.gameplayState, new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.Auto,
                    Formatting       = Formatting.Indented,
                });
                File.WriteAllText("save.json", json);
            };

            loadButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 4, 360),
                Size     = new Vector2(200, 100),
                Text     = "Load",
            };
            loadButton.OnClick += () =>
            {
                string json = File.ReadAllText("save.json");
                this.gameplayState = JsonConvert.DeserializeObject <GameplayScreenState>(json, new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.Auto
                });
                ReturnToGame();
            };

            restartGameButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 2, 360),
                Size     = new Vector2(200, 100),
                Text     = "Restart",
            };
            restartGameButton.OnClick += () =>
            {
                Game.SetCurrentScreen(new GameplayScreen(game));
            };

            goBackButton = new UIButton(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 2, 470),
                Size     = new Vector2(200, 100),
                Text     = "Go back",
            };
            goBackButton.OnClick += () =>
            {
                Game.SetCurrentScreen(new MainMenuScreen(game));
            };

            pausedText = new UIText(resources)
            {
                Position = new Vector2(Game.WindowSize.X / 2, 150),
                Text     = "Paused",
            };

            MediaPlayer.Pause();
        }