Example #1
0
    private void EnterState(GameState newState)
    {
        currentState = newState;

        switch (currentState)
        {
        case GameState.MENU_MAIN:
        {
            //Main menu prefab
            GameObject newObject = Instantiate(MainMenuPrefab, this.transform);
            newObject.transform.SetParent(this.transform);

            displayedGUI.Add(newObject);
            newObject = Instantiate(ConnectionStatusPrefab, this.transform);
            newObject.transform.SetParent(this.transform);
            newObject.name = connectionPanelName;
            displayedGUI.Add(newObject);

            SetStatus();
            break;
        }

        case GameState.MENU_SETTINGS:
        {
            GameObject newObject = Instantiate(AudioMenuPrefab, this.transform);
            newObject.transform.SetParent(this.transform);
            displayedGUI.Add(newObject);
            break;
        }

        case GameState.MENU_HELP:
        {
            GameObject newObject = Instantiate(HelpMenuPrefab, this.transform);
            newObject.transform.SetParent(this.transform);
            displayedGUI.Add(newObject);
            break;
        }

        case GameState.MENU_LOGIN:
        {
            GameObject newObject = Instantiate(LoginMenuPrefab, this.transform);
            newObject.transform.SetParent(this.transform);
            displayedGUI.Add(newObject);
            break;
        }

        case GameState.CHARACTER_SELECT:
        {
            GameObject newObject = Instantiate(CharacterSelectPrefab, this.transform);
            newObject.transform.SetParent(this.transform);
            displayedGUI.Add(newObject);

            wsManager.RegisterReceiver(newObject.GetComponent <CharacterSelectScreen>());
            //Retrieve character list
            wsManager.RequestCharacters();

            StartCoroutine(LoadSpriteFromWeb(Constants.BASE_ASSET_URL + Constants.TEST_SPRITE));
            break;
        }

        default:
        {
            ChangeState(GameState.MENU_MAIN);
            break;
        }
        }
    }