コード例 #1
0
ファイル: bl_Lobby.cs プロジェクト: BlackZIjian/DestroyFps
 /// <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));
     }
 }
コード例 #2
0
    /// <summary>
    ///
    /// </summary>
    void Awake()
    {
#if ULSP
        DataBase = FindObjectOfType <bl_DataBase>();
        if (DataBase == null && bl_LoginProDataBase.Instance.ForceLoginScene)
        {
            bl_UtilityHelper.LoadLevel("Login");
            return;
        }
#endif
        PhotonNetwork.AddCallbackTarget(this);
        PhotonNetwork.UseRpcMonoBehaviourCache = true;
        bl_UtilityHelper.LockCursor(false);
        StartCoroutine(StartFade());
        Chat               = GetComponent <bl_LobbyChat>();
        hostName           = string.Format(RoomNamePrefix, Random.Range(10, 999));
        RoomNameField.text = hostName;
        if (FindObjectOfType <bl_PhotonGame>() == null)
        {
            Instantiate(PhotonGamePrefab);
        }
        if (BackgroundSound != null)
        {
            BackSource = GetComponent <AudioSource>();
            if (BackSource == null)
            {
                BackSource = gameObject.AddComponent <AudioSource>();
            }
            BackSource.clip        = BackgroundSound;
            BackSource.volume      = 0;
            BackSource.playOnAwake = false;
            BackSource.loop        = true;
        }
        DisableAllWindows();
        if (bl_GameData.isDataCached)
        {
            SetUpGameModes();
            LoadSettings();
            SetUpUI();
        }
        if (BackgroundSound != null)
        {
            StartCoroutine(FadeAudioBack(true));
        }
        FadeImage.SetActive(false);
        if (PhotonStaticticsUI != null)
        {
            PhotonStaticticsUI.SetActive(ShowPhotonStatistics);
        }
#if LOCALIZATION
        bl_Localization.Instance.OnLanguageChange += OnLanguageChange;
#endif
    }