Exemplo n.º 1
0
 private void UpdateMenuItemBackgroundImage(MenuCube menuCube, bool isSoundEnabled)
 {
     menuCube.SetTextImage(CreateImagePath("options_cube", new Dictionary <string, string>
     {
         { "sounds", isSoundEnabled ? "on" : "off" }
     }));
 }
Exemplo n.º 2
0
 private void HandleKeyboardInput()
 {
     if (_platform.Input.HasEvent(UISButton.Left, true))
     {
         _activeCube.SelectPreviousItem();
     }
     else if (_platform.Input.HasEvent(UISButton.Right, true))
     {
         _activeCube.SelectNextItem();
     }
     else if (_platform.Input.HasEvent(UISButton.Enter, true))
     {
         ActivateSelectedItem();
     }
     else if (_platform.Input.HasEvent(UISButton.Escape, true) ||
              _platform.Input.HasEvent(UISButton.Back, true))
     {
         if (_activeCube.PreviousMenu != null)
         {
             _activeCube.Destroy();
             _activeCube = _activeCube.PreviousMenu;
             _platform.SoundManager.PlaySound(MenuEventSound);
         }
     }
 }
        private void CreateLevelsCubes()
        {
            var tutorialCube = CreateLevelMenuCube("level_cube_tutorial_text");

            tutorialCube.Items = new List <MenuItem>
            {
                new MenuItem
                {
                    Activated = obj => StateManager.Instance.ChangeState(GameState.TutorialLevel)
                }
            };
            tutorialCube.Spawn(-50f);

            var lockedLevel1Cube = CreateLevelMenuCube("level_cube_level2_text");

            lockedLevel1Cube.Items = new List <MenuItem>
            {
                new MenuItem
                {
                    Activated = obj => StateManager.Instance.ChangeState(GameState.Demo2)
                }
            };
            lockedLevel1Cube.Spawn(0f);



            //var lockedLevel2Cube = CreateLevelMenuCube( "level_cube_locked_text" );
            //lockedLevel2Cube.Spawn( 50f );

            _levelCubes.Add(tutorialCube);
            _levelCubes.Add(lockedLevel1Cube);
            //_levelCubes.Add( lockedLevel2Cube );

            _activeCube = tutorialCube;
        }
        private MenuCube CreateLevelMenuCube(string textImage)
        {
            MenuCube menuCube = new MenuCube(ContentManager);

            menuCube.SetTextImage(textImage);

            return(menuCube);
        }
        private void SelectCube(int index)
        {
            Vector3 selectedCubeScale = new Vector3(2, 2, 2);

            if (_activeCube != null)
            {
                GameWorldManager.Instance.GetEntity(_activeCube.Id).SetScale(Vector3.One);
            }

            _activeCube = _levelCubes[index];
            GameWorldManager.Instance.GetEntity(_activeCube.Id).SetScale(selectedCubeScale);
            _selectedCubeIndex = index;
        }
Exemplo n.º 6
0
        private void CreateMenus()
        {
            _mainMenuCube = new MenuCube(ContentManager)
            {
                Title          = "Main menu",
                SelectionSound = MenuItemSelectionSound,
                Items          = new List <MenuItem>
                {
                    new MenuItem {
                        Title = "Play!", Activated = args => StateManager.Instance.ChangeState(GameState.SelectLevelMenu)
                    },
                    new MenuItem {
                        Title = "Options", Activated = args => ActivateMenuCube(_optionsMenuCube)
                    },
                    new MenuItem {
                        Title = "Editor", Activated = args => StateManager.Instance.ChangeState(GameState.Editor)
                    },
                    new MenuItem {
                        Title = "Exit", Activated = args => _platform.Game.Exit()
                    }
                }
            };
            _mainMenuCube.SetTextImage("main_cube_text_flat");

            _optionsMenuCube = new MenuCube(ContentManager)
            {
                Title          = "Options menu",
                PreviousMenu   = _mainMenuCube,
                SelectionSound = MenuItemSelectionSound,
                Items          = new List <MenuItem>
                {
                    new SwitchMenuItem
                    {
                        OnTitle   = "On", OffTitle = "Off", Prefix = "Sounds",
                        IsOn      = _platform.Settings.IsMusicEnabled,
                        Activated = args =>
                        {
                            _platform.Settings.IsMusicEnabled = ( bool )args;
                            UpdateMenuItemBackgroundImage(_optionsMenuCube, ( bool )args);
                            _platform.Settings.Save();
                        }
                    }
                }
            };
            UpdateMenuItemBackgroundImage(_optionsMenuCube, _platform.Settings.IsMusicEnabled);
        }
Exemplo n.º 7
0
 private void ActivateMenuCube(MenuCube cube)
 {
     _activeCube = cube;
     _activeCube.Spawn(25f);
 }