Beispiel #1
0
    public static MenuStateManager GetMenuStateManager()
    {
        if (singleton == null)
        {
            singleton = new MenuStateManager();
        }

        return(singleton);
    }
 // Use this for initialization
 void Start()
 {
     text             = GetComponent <Text>();
     color            = text.color;
     text.color       = new Color(color.r, color.g, color.b, 0);
     rt               = GetComponent <RectTransform>();
     menu             = FindObjectOfType <Menu>();
     menuStateManager = FindObjectOfType <MenuStateManager>();
 }
Beispiel #3
0
    public void Update()

    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            MenuStateManager.enterStateUsingName(m_stateID);
            Time.timeScale = 0;
        }
    }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        KeyboardInput();
        MouseMovement();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            MenuStateManager.GetMenuStateManager().OpenIngameSettings();
        }
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        if (s_gameStateManager != null && s_gameStateManager != this)
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);

        s_gameStateManager = this;
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        networkManager  = GetComponent <NetworkManager>();
        settingsManager = GetComponent <SettingsManager>();
        menuStates      = MenuStateManager.GetMenuStateManager();
        networkManager.SetMenuStates(menuStates);

        UIInit();
        SetUIActions();

        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Beispiel #7
0
    private void RpcEndGame(GameManager.Team winningTeam, int blueScore, int redScore, string[] blueNames, int[] blueScores, string[] redNames, int[] redScores)
    {
        MenuStateManager menuStates = MenuStateManager.GetMenuStateManager();

        menuStates.EndGame();

        Dictionary <string, int> blueTeam = new Dictionary <string, int>();

        for (int loop = 0; loop < blueNames.Length; loop++)
        {
            blueTeam.Add(blueNames[loop], blueScores[loop]);
        }

        Dictionary <string, int> redTeam = new Dictionary <string, int>();

        for (int loop = 0; loop < redNames.Length; loop++)
        {
            redTeam.Add(redNames[loop], redScores[loop]);
        }

        GameObject.Find("EndGameCanvas").GetComponent <EndGameScoreManager>().SetScores(winningTeam, blueScore, redScore, blueTeam, redTeam);
    }
Beispiel #8
0
    public override void onGUI()
    {
        float offsetX = transform.position.x;
        float offsetY = transform.position.y;

        if (backgroundTexture)
        {
            GUI.DrawTexture(GUIHelper.screenRect(0, 0, 1, 1), backgroundTexture, ScaleMode.StretchToFill);
        }
        GUI.skin = guiSkin0;
        //draw a button which will increase the graphics quality
        if (addButton(GUIHelper.screenRect(offsetX - 0.15f, offsetY - .15f, .3f, .1f),
                      restartSTR))
        {
            MenuStateManager.enterStateUsingGameObject(null);
            unapuseGame();
            //load the first level.
            Application.LoadLevel(Application.loadedLevel);
        }

        //draw a button that will decrease the graphics quality
        if (addButton(GUIHelper.screenRect(offsetX - 0.15f, offsetY, .3f, .1f),
                      resumeSTR))
        {
            MenuStateManager.enterStateUsingGameObject(null);
            unapuseGame();
        }

        if (addButton(GUIHelper.screenRect(offsetX - 0.15f, offsetY + .15f, .3f, .1f),
                      mainMenuSTR))
        {
            MenuStateManager.enterStateUsingGameObject(null);
            unapuseGame();
            //load the first level.
            Application.LoadLevel(levelSceneIndex);
        }
    }
Beispiel #9
0
 public EnterPasswordState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #10
0
    private void RpcLobbyReturn()
    {
        MenuStateManager menuStates = MenuStateManager.GetMenuStateManager();

        menuStates.BackToLobby(isServer);
    }
 public void swapObjects(GameObject go)
 {
     MenuStateManager.enterStateUsingGameObject(go);
 }
Beispiel #12
0
 public void SetMenuStates(MenuStateManager menuStates)
 {
     this.menuStates = menuStates; //Can I do better than this?
 }
Beispiel #13
0
 public State(MenuStateManager menuStates)
 {
     this.menuStates = menuStates;
 }
Beispiel #14
0
 public ErrorMessageState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #15
0
 public SettingsState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #16
0
 public IngameMenuState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #17
0
        public void Update(GameTime gameTime)
        {
            ComponentManager cm = ComponentManager.GetInstance();
            GameStateManager gm = GameStateManager.GetInstance();

            ActivateMenuButtons();
            ActivateMenuBackground();
            ClearMenu();
            DecrementSelectCooldown = true;
            exitPause = false;
            bool enterPause = false;

            foreach (var controlEntity in cm.GetComponentsOfType <PlayerControlComponent>())
            {
                PlayerControlComponent controlComp = (PlayerControlComponent)controlEntity.Value;

                // If we are in some kind of menu state
                if (GameStateManager.GetInstance().State == GameState.Menu)
                {
                    // Apply effects on menu background
                    foreach (var menuBackground in cm.GetComponentsOfType <MenuBackgroundComponent>())
                    {
                        MenuBackgroundComponent men = (MenuBackgroundComponent)menuBackground.Value;

                        if (men.HasFadingEffect && men.IsActive)
                        {
                            FadeEffect(gameTime, men);
                        }
                        if (men.HasMovingEffect && men.IsActive)
                        {
                            MoveEffect(gameTime, men);
                        }
                    }
                    if (DecrementSelectCooldown)
                    {
                        SelectCooldown         -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                        DecrementSelectCooldown = false;
                    }

                    // Makes the menu button selection smooth
                    if (SelectCooldown <= 0.0f)
                    {
                        Vector2 stickDir = controlComp.Movement.GetDirection();
                        //Check navigation in the menu
                        if (Math.Abs(stickDir.Y) > 0.5f)
                        {
                            //if the stick has been pushed in a direction
                            Point direction = MoveSystem.CalcDirection(stickDir.X, stickDir.Y);
                            cm.GetComponentForEntity <MenuButtonComponent>(ActiveButtonsList[SelectedButton]).Ishighlighted = false;
                            //stop sound for last button
                            if (cm.HasEntityComponent <SoundComponent>(ActiveButtonsList[SelectedButton]))
                            {
                                cm.GetComponentForEntity <SoundComponent>(ActiveButtonsList[SelectedButton]).Sounds["Selected"].Action = SoundAction.Stop;
                            }
                            SelectedButton = (SelectedButton + direction.Y) % ActiveButtonsList.Count;
                            if (SelectedButton < 0)
                            {
                                SelectedButton = ActiveButtonsList.Count - 1;
                            }
                            cm.GetComponentForEntity <MenuButtonComponent>(ActiveButtonsList[SelectedButton]).Ishighlighted = true;
                            //start sound for new button selected
                            if (cm.HasEntityComponent <SoundComponent>(ActiveButtonsList[SelectedButton]))
                            {
                                cm.GetComponentForEntity <SoundComponent>(ActiveButtonsList[SelectedButton]).Sounds["Selected"].Action = SoundAction.Play;
                            }
                            SelectCooldown = MaxSelectCooldown;
                        }
                    }

                    // Check if highlighted button was pressed "use"
                    if (controlComp.Interact.IsButtonDown())
                    {
                        if (cm.HasEntityComponent <SoundComponent>(ActiveButtonsList[SelectedButton]))
                        {
                            cm.GetComponentForEntity <SoundComponent>(ActiveButtonsList[SelectedButton]).Sounds["Pressed"].Action = SoundAction.Play;
                        }
                        cm.GetComponentForEntity <MenuButtonComponent>(ActiveButtonsList[SelectedButton]).Use();
                    }

                    // 1 Player
                    if (gm.State == GameState.OnePlayerGame)
                    {
                        //remove the temporary menu controller
                        cm.RemoveEntity(controlEntity.Key);
                        cm.AddEntityWithComponents(factory.CreatePlayerOne(100, 128));
                        MenuStateManager.GetInstance().State = MenuState.None;
                        gm.State = GameState.Restart;
                        break;
                    }
                    // 2 Players
                    if (gm.State == GameState.TwoPlayerGame)
                    {
                        //remove the temporary menu controller
                        cm.RemoveEntity(controlEntity.Key);
                        cm.AddEntityWithComponents(factory.CreatePlayerOne(100, 128));
                        cm.AddEntityWithComponents(factory.CreatePlayerTwo(256, 128));
                        MenuStateManager.GetInstance().State = MenuState.None;
                        gm.State = GameState.Restart;
                        break;
                    }
                }
                if (controlComp.Menu.IsButtonDown())
                {
                    //Debug.WriteLine(gm.State + " c " + gm.LastState);
                    if (MenuStateManager.GetInstance().State == MenuState.PauseMainMenu && gm.State == GameState.Menu)
                    {
                        //// Exit the Pausemenu if menu button is pressed from GameState "Menu"
                        Debug.WriteLine(gm.LastState + " a " + gm.State);
                        gm.State = gm.LastState;
                        MenuStateManager.GetInstance().State = MenuState.None;
                    }
                    else if ((gm.State == GameState.Game || gm.State == GameState.GameOver) && gm.LastState != GameState.Menu)
                    {
                        // Enter the PauseMenu if menu button is pressed from GameState "Game"
                        Debug.WriteLine(gm.LastState + " b " + gm.State);
                        gm.State = GameState.Menu;
                        MenuStateManager.GetInstance().State = MenuState.PauseMainMenu;
                    }
                    else
                    {
                        gm.LastState = gm.State;
                    }
                }

                if (gm.State == GameState.ExitToMenu)
                {
                    ActiveButtonsList.Clear();
                    SelectedButton = 0;
                    MenuStateManager.GetInstance().State = MenuState.MainMenu;
                }
            }
        }
Beispiel #18
0
 public MainMenuState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #19
0
 public SearchServersState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #20
0
 public ServerBrowserState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #21
0
 public LobbyState(MenuStateManager menuStates) : base(menuStates)
 {
 }
Beispiel #22
0
        // Initializes Menu buttons
        private void ActivateMenuButtons()
        {
            if (GameStateManager.GetInstance().State == GameState.Menu)
            {
                ComponentManager cm = ComponentManager.GetInstance();
                ActiveButtonsList = new List <int>();

                //Set buttons to "active" and add them to the buttonList
                var menuButtonComps = cm.GetComponentsOfType <MenuButtonComponent>();

                foreach (var button in menuButtonComps)
                {
                    MenuButtonComponent buttonComp = (MenuButtonComponent)button.Value;

                    switch (MenuStateManager.GetInstance().State)
                    {
                    case MenuState.MainMenu:
                        if (buttonComp.Type == MenuButtonType.MainMenuButton)
                        {
                            buttonComp.IsActive = true;
                        }
                        else
                        {
                            buttonComp.IsActive = false;
                        }
                        break;

                    case MenuState.PauseMainMenu:
                        if (buttonComp.Type == MenuButtonType.PauseMainMenuButton)
                        {
                            buttonComp.IsActive = true;
                        }
                        else
                        {
                            buttonComp.IsActive = false;
                        }
                        break;

                    case MenuState.None:
                        buttonComp.IsActive = false;
                        break;
                    }

                    if (buttonComp.IsActive)
                    {
                        ActiveButtonsList.Add(button.Key);
                        //ActiveButtonsList.Insert(buttonComp.OrderPosition, button.Key);
                    }
                }
                if (ActiveButtonsList.Count > 0 && cm.GetComponentForEntity <MenuButtonComponent>(ActiveButtonsList[0]).OrderPosition != 0)
                {
                    ActiveButtonsList.Reverse();
                }
                int checkButtons = 0;
                foreach (var button in ActiveButtonsList)
                {
                    if (cm.GetComponentForEntity <MenuButtonComponent>(button).Ishighlighted)
                    {
                        checkButtons++;
                    }
                }
                if (ActiveButtonsList.Count > 0 && checkButtons <= 0)
                {
                    SelectedButton = 0;
                    cm.GetComponentForEntity <MenuButtonComponent>(ActiveButtonsList[0]).Ishighlighted = true;
                }
            }
        }