コード例 #1
0
ファイル: MainMenuScreen.cs プロジェクト: sergik/Cardio
        public MainMenuScreen()
        {
            var newGameMenu = new GrowingMenuEntry("NEW GAME")
            {
                Position = new Vector2(120, 40),
            };

            newGameMenu.Selected += (o, e) =>
            {
                // Reset GameState if it was changed by previous games or by loading from file.
                ScreenManager.Game.Services.GetService<GameState>().Reset();
                LoadingScreen.Load(ScreenManager, false, new LevelMenuScreen());
            };

            MenuEntries.Add(newGameMenu);

            var demoLevelMenu = new GrowingMenuEntry("CONTINUE SAVED GAME")
            {
                Position = new Vector2(120, 120),
                IsVisible = File.Exists(SavedGame.DefaultSaveGameFile)
            };

            demoLevelMenu.Selected += ContinueSavedGame;
            MenuEntries.Add(demoLevelMenu);

            var exitMenuItem = new GrowingMenuEntry("EXIT")
            {
                Position = new Vector2(120, 200),
            };

            exitMenuItem.Selected += (o, e) => ScreenManager.Game.Exit();
            MenuEntries.Add(exitMenuItem);
        }
コード例 #2
0
        public override void LoadContent()
        {
            _infoText = Information[_random.Next(Information.Count)];

            var viewport = ScreenManager.Game.GraphicsDevice.Viewport;
            _infoPosition = new Vector2(viewport.Width / 2f, viewport.Height / 2f);

            _proceedButton = new GrowingMenuEntry("PLAY")
            {Position = new Vector2(viewport.Width - 150, viewport.Height - 60)};
            _proceedButton.Initialize(ScreenManager.Game);

            _tweetButton = new GrowingMenuEntry("POST TO TWITTER")
                               {
                                   Position = new Vector2(viewport.Width - 550, viewport.Height - 60),
                                   MaxScale = 1.1f
                               };
            _tweetButton.Initialize(ScreenManager.Game);

            var twitter = ScreenManager.Game.Services.GetService<ITwitter>();
            _tweetButton.Selected += (o, e) =>
                                         {
                                             if (!twitter.IsInitialized)
                                             {
                                                 return;
                                             }
                                             if (twitter.AuthenticationRequired)
                                             {
                                                 GoToTwitterScreen();
                                             }
                                             else
                                             {
                                                 _tweeted = twitter.SendTweet(_infoText);
                                             }
                                         };

            _reenterPin = new GrowingMenuEntry("REENTER PIN AND POST TO TWITTER")
            {
                Position = new Vector2(50, viewport.Height - 60),
                MaxScale = 1.1F
            };
            _reenterPin.Initialize(ScreenManager.Game);
            _reenterPin.Selected += (o, e) =>
                                        {
                                            if (twitter.IsInitialized)
                                            {
                                                GoToTwitterScreen();
                                            }
                                        };

            base.LoadContent();
        }
コード例 #3
0
ファイル: PauseMenuScreen.cs プロジェクト: sergik/Cardio
        public PauseMenuScreen()
        {
            var newGameMenu = new GrowingMenuEntry("MENU")
                                  {
                                      Position = new Vector2(300, 150),
                                  };
            newGameMenu.Selected +=
                (o, e) => LoadingScreen.Load(ScreenManager, true, new LevelMenuScreen());
            MenuEntries.Add(newGameMenu);

            var resumeGameMenu = new GrowingMenuEntry("RESUME GAME")
                                     {
                                         Position = new Vector2(300, 230),
                                     };
            resumeGameMenu.Selected += (o, e) => ExitScreen();
            MenuEntries.Add(resumeGameMenu);
        }
コード例 #4
0
ファイル: LevelThumbnail.cs プロジェクト: sergik/Cardio
 public LevelThumbnail()
 {
     _menuEntry = new GrowingMenuEntry("");
     TextOffset = new Vector2(0, 5);
 }
コード例 #5
0
ファイル: LevelShop.cs プロジェクト: sergik/Cardio
        private void CreateTabs()
        {
            var guns = new GrowingMenuEntry("GUNS");
            guns.Position = new Vector2(Position.X, Position.Y + 100);
            guns.Selected += (s, e) =>
                                 {
                                     ItemsSetToDisplay.Clear();
                                     ItemsSetToDisplay.AddRange(Guns);
                                     InitializeItemsPositions();
                                 };
            Tabs.Add(guns);

            var shields = new GrowingMenuEntry("SHIELDS");
            shields.Position = new Vector2(Position.X, Position.Y + 140);
            shields.Selected += (s, e) =>
                                    {
                                        ItemsSetToDisplay.Clear();
                                        ItemsSetToDisplay.AddRange(Shields);
                                        InitializeItemsPositions();
                                    };
            Tabs.Add(shields);

            var bodies = new GrowingMenuEntry("BODIES");
            bodies.Position = new Vector2(Position.X, Position.Y + 180);
            bodies.Selected += (s, e) =>
                                    {
                                        ItemsSetToDisplay.Clear();
                                        ItemsSetToDisplay.AddRange(Bodies);
                                        InitializeItemsPositions();
                                    };
            Tabs.Add(bodies);

            _selectedTab = Tabs[0];
        }
コード例 #6
0
ファイル: LevelShop.cs プロジェクト: sergik/Cardio
        public void HandleInput()
        {
            if (InputManager.IsMouseButtonTriggered(x => x.LeftButton))
             {
                 var tab = Tabs.FirstOrDefault(
                     t => t.EntryArea.Contains(InputManager.CurrentMouseState.X, InputManager.CurrentMouseState.Y));
                 if (tab != null)
                 {
                     tab.OnSelectEntry();
                     _selectedTab = tab;
                 }
             }

            for (int index = 0; index < ItemsSetToDisplay.Count; index++)
            {
                var item = ItemsSetToDisplay[index];
                item.HandleInput();
            }
        }
コード例 #7
0
ファイル: LevelShopItem.cs プロジェクト: sergik/Cardio
        public virtual void Initialize(Game game)
        {
            Game = game;
            SpriteBatch = game.Services.GetService<SpriteBatch>();

            LoadComponent();
            Component.Initialize(Game, SpriteBatch, null);

            BuyButton = new GrowingMenuEntry("buy");
            BuyButton.Position = Position + new Vector2(1050, 40);
            BuyButton.Initialize(game);

            LoadContent();
        }
コード例 #8
0
        private void InitializeButtons()
        {
            _fromClipboard = new GrowingMenuEntry("PASTE FROM CLIPBOARD") { Position = new Vector2(550, 290) };
            _fromClipboard.Selected += (o, e) =>
                                       {
                                           _pinTextBox.Text = Clipboard.GetText();
                                       };
            MenuEntries.Add(_fromClipboard);

            var submitPin = new GrowingMenuEntry("SUBMIT PIN AND POST TWEET") { Position = new Vector2(180, 420) };
            submitPin.Selected += (o, e) =>
                                      {
                                          if (!string.IsNullOrEmpty(_pinTextBox.Text))
                                          {
                                              if (_twitter.IsInitialized &&
                                                  _twitter.AuthenticateWith(_pinTextBox.Text) &&
                                                  _twitter.SendTweet(TextToSendAsTweet))
                                              {
                                                  Tweeted = true;
                                                  TweenSent.Fire(this, () => EventArgs.Empty);
                                              }
                                          }
                                      };
            MenuEntries.Add(submitPin);

            var back = new GrowingMenuEntry("BACK") { Position = new Vector2(40, ScreenManager.Game.GraphicsDevice.Viewport.Height - 40) };
            back.Selected += (o, e) => ExitScreen();
            MenuEntries.Add(back);
        }