コード例 #1
0
    public void addPlayer()
    {
        string playerName = InputPlayerNameController.instance.getText();

        if (string.IsNullOrEmpty(playerName))
        {
            ErrorMessageController.instance.setMessage("Please input a name");
            ErrorMessageController.instance.open(true);
        }
        else
        {
            if (validateName(playerName))
            {
                if (lastIndx >= -1 && lastIndx < listPlayer.Length - 1)
                {
                    Game    newGame = new Game();
                    Profile prof    = new Profile();
                    prof.profileName       = playerName;
                    prof.musicVol          = 5.0f;
                    prof.effectsVol        = 5.0f;
                    newGame.currentProfile = prof;
                    Game.current           = newGame;
                    SaveLoad.AddSavedGame(newGame);

                    ++lastIndx;
                    listPlayer[lastIndx].gameObject.SetActive(true);
                    listPlayer[lastIndx].setName(playerName);

                    if (lastIndx == 0)
                    {
                        updateSelected(listPlayer[lastIndx].getName());
                        listPlayer[lastIndx].selected(true);
                    }

                    SaveLoad.list.latestGame = playerName;
                    Debug.Log(SaveLoad.list.savedGames.Count);
                }
                else
                {
                    ErrorMessageController.instance.setMessage("Too many users");
                    ErrorMessageController.instance.open(true);
                }
            }
            else
            {
                ErrorMessageController.instance.setMessage("Name already taken");
                ErrorMessageController.instance.open(true);
            }
        }
    }
コード例 #2
0
    public void addPlayerIntro()
    {
        string playerName = InputPlayerNameIntro.instance.getText();

        if (string.IsNullOrEmpty(playerName))
        {
            ErrorMessageController.instance.setMessage("Please input a name");
            ErrorMessageController.instance.open(true);
        }
        else
        {
            if (validateName(playerName))
            {
                if (lastIndx >= -1 && lastIndx < listPlayer.Length - 1 && validateName(playerName))
                {
                    Game    newGame = new Game();
                    Profile prof    = new Profile();
                    prof.profileName       = playerName;
                    newGame.currentProfile = prof;


                    ++lastIndx;
                    listPlayer[lastIndx].gameObject.SetActive(true);
                    listPlayer[lastIndx].setName(playerName);

                    if (lastIndx == 0)
                    {
                        lastSelected = 0;
                        IntroCanvasController.instance.open(false);
                        MainMenu.instance.setProfileName(playerName, 0);
                        MainMenu.instance.Open(true);
                    }

                    Game.current = newGame;
                    SaveLoad.AddSavedGame(newGame);
                }
            }
            else
            {
                ErrorMessageController.instance.setMessage("Name already taken");
                ErrorMessageController.instance.open(true);
            }
        }
    }