コード例 #1
0
ファイル: MenuManager.cs プロジェクト: Mathux/tim-dodge
        public MenuManager(GameManager GameManager)
        {
            chooseMap = new ChooseMap();

            this.GameManager = GameManager;

            // Initialization of windows
            InitialMenu = new MenuWindow();
            PauseMenu   = new MenuWindow();
            ParamMenu   = new MenuWindow();
            Gameover    = new MenuWindow();
            Congrats    = new MenuWindow();
            SaveEditor  = new MenuWindow();
            QuitMenu    = new MenuWindow();
            Highscores  = new MenuWindow();

            // Construction of menus
            Difficulty = new MenuItem("Difficulty : Medium", choiceDiff);
            Initialize(InitialMenu, "Menu", new List <MenuItem> {
                new MenuItem("One Player", NewGame),
                new MenuItem("Two Players", NewMultiGame),
                Difficulty,
                //new MenuItem("Map Editor", NewEditor),
                new MenuItem("Parameters", Parameters),
                new MenuItem("Best Scores", BestScores),
                new MenuItem("Quit", Quit)
            }
                       );

            Initialize(PauseMenu, "Pause", new List <MenuItem> {
                new MenuItem("Resume", Resume),
                new MenuItem("Quit this game", BackInitialMenu),
                new MenuItem("Parameters", Parameters),
                new MenuItem("Best Scores", BestScores),
                new MenuItem("Quit", Quit)
            }
                       );

            if (Load.sounds.musicmute)
            {
                choiceMusicItem = new MenuItem("Activate Music", ChoiceMusic);
            }
            else
            {
                choiceMusicItem = new MenuItem("Deactivate Music", ChoiceMusic);
            }
            if (Load.sounds.sfxmute)
            {
                choiceSoundItem = new MenuItem("   Activate Sound Effects   ", ChoiceSound);
            }
            else
            {
                choiceSoundItem = new MenuItem("Deactivate Sound Effects", ChoiceSound);
            }

            Initialize(ParamMenu, "Parameters", new List <MenuItem> {
                choiceMusicItem,
                choiceSoundItem,
                //choiceCharlieItem,
                new MenuItem("Back to Menu", Previous)
            }
                       );

            Initialize(QuitMenu, "Quit the game ?", new List <MenuItem> {
                new MenuItem("No, I want to play more!", Previous),
                new MenuItem("Yes, leave me alone", Quit)
            }
                       );

            Initialize(Gameover, "Game Over", new List <MenuItem> {
                new MenuItem("Play Again", PlayAgain),
                new MenuItem("Back Menu", BackInitialMenu),
                new MenuItem("Quit the game", Quit)
            }
                       );

            YourName      = new KeyboardReader("You beat a highscore".Length);
            EnterYourName = new MenuItem(messageYourName, Load.FontMenu, Load.ColorTextMenu);             // Text updated by the update function
            Initialize(Congrats, "Congrats !", new List <MenuItem> {
                new MenuItem("You beat a highscore", Load.FontMenu, Load.ColorTextMenu),
                EnterYourName,
                new MenuItem("<Validate>", RecordHighscore)
            }
                       );
            Congrats.Opacity  = 0.9f;
            Congrats.Position = new Vector2(Congrats.Position.X, Gameover.ListItems[1].source.Y);
            //Congrats.AlignItemsX();

            YourPath      = new KeyboardReader("Save your map".Length);
            EnterYourPath = new MenuItem(messageYourPath, Load.FontMenu, Load.ColorTextMenu);             // Text updated by the update function
            Initialize(SaveEditor, "Saving !", new List <MenuItem> {
                new MenuItem("Save your map", Load.FontMenu, Load.ColorTextMenu),
                EnterYourPath,
                new MenuItem("<Validate>", RecordMap)
            }
                       );
            SaveEditor.Opacity  = 0.9f;
            SaveEditor.Position = new Vector2(SaveEditor.Position.X, 100);            //Gameover.ListItems[1].source.Y);
            //SaveEditor.AlignItems();

            // First Menu appearing
            CurrentMenu = new List <MenuWindow>();
            CurrentMenu.Add(InitialMenu);
        }
コード例 #2
0
ファイル: MenuManager.cs プロジェクト: Mathux/tim-dodge
 private void Initialize(MenuWindow mw, String Title, List <MenuItem> items)
 {
     mw.Title     = Title;
     mw.ListItems = items;
     mw.ConstructMenu();
 }