Beispiel #1
0
    /// <summary>
    ///
    /// </summary>
    public void EnterName(InputField field = null)
    {
        if (field == null || string.IsNullOrEmpty(field.text))
        {
            return;
        }

        CachePlayerName = field.text;
        int check = bl_GameData.Instance.CheckPlayerName(CachePlayerName);

        if (check == 1)
        {
            MenusUI[9].SetActive(true);
            return;
        }
        else if (check == 2)
        {
            field.text = string.Empty;
            return;
        }

        playerName = CachePlayerName;
        playerName = playerName.Replace("\n", "");
        StartCoroutine(Fade(LobbyState.MainMenu));

        PhotonNetwork.playerName = playerName;
        ConnectPhoton();
        if (Chat != null && bl_GameData.Instance.UseLobbyChat)
        {
            Chat.Connect(AppVersion);
        }
    }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 void Awake()
 {
     bl_UtilityHelper.LockCursor(false);
     Application.targetFrameRate = 60;
     PhotonNetwork.autoJoinLobby = true;
     Chat               = GetComponent <bl_LobbyChat>();
     hostName           = string.Format(RoomNamePrefix, Random.Range(10, 999));
     RoomNameField.text = hostName;
     GameModes          = Enum.GetNames(typeof(GameMode));
     if (FindObjectOfType <bl_PhotonGame>() == null)
     {
         Instantiate(PhotonGamePrefab);
     }
     if (string.IsNullOrEmpty(PhotonNetwork.playerName))
     {
         // generate a name for this player, if none is assigned yet
         if (String.IsNullOrEmpty(playerName))
         {
             playerName           = string.Format(PlayerNamePrefix, Random.Range(1, 9999));
             PlayerNameField.text = playerName;
         }
         ChangeWindow(0);
     }
     else
     {
         StartCoroutine(Fade(LobbyState.MainMenu, 1.2f));
         if (!PhotonNetwork.connected)
         {
             ConnectPhoton();
         }
         ChangeWindow(2, 1);
         if (Chat != null && bl_GameData.Instance.UseLobbyChat)
         {
             Chat.Connect(AppVersion);
         }
     }
     GetPrefabs();
     SetUpOptionsHost();
     InvokeRepeating("UpdateServerList", 1, UpdateServerListEach);
     FadeImage.SetActive(false);
     if (PhotonStaticticsUI != null)
     {
         PhotonStaticticsUI.SetActive(ShowPhotonStatistics);
     }
     if (BackgroundSound != null)
     {
         BackSource             = gameObject.AddComponent <AudioSource>();
         BackSource.clip        = BackgroundSound;
         BackSource.volume      = 0;
         BackSource.playOnAwake = false;
         BackSource.loop        = true;
         StartCoroutine(FadeAudioBack(true));
     }
 }