Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        netManagerHUD   = GameObject.Find("LobbyManager").GetComponent <RG_NetworkManagerHUD> ();
        netLobbyManager = GameObject.Find("LobbyManager").GetComponent <RG_NetworkLobbyManager> ();
        netId           = GetComponent <NetworkIdentity> ();
        slot            = GetComponent <NetworkLobbyPlayer> ().slot;
        vehicleNumber   = PlayerPrefs.GetInt("Vehicle Number", 0);

        if (netId.isLocalPlayer)
        {
            CmdVehicleNumber(vehicleNumber);
            netLobbyManager.SetPlayerTypeLobby(slot, vehicleNumber);
            isLocalPlayer = true;
            PlayerPrefs.SetInt("Slot", slot);
        }
        else
        {
            isLocalPlayer = false;
        }
        if (slot == 0 && netId.isLocalPlayer)
        {
            //This player is host
            GameObject.Find("LobbyManager").GetComponent <RG_NetworkManagerHUD>().EnableStartLobbyGameButton();
            GameObject.Find("Start Lobby Game Button").GetComponent <Button> ().onClick = buttonCallback;
        }
        if (slot == 0)
        {
            transform.name = "Player " + slot.ToString() + (" (HOST)");
        }
        else
        {
            if (isLocalPlayer)
            {
                SetStartFlag();
            }
            transform.name = "Player " + slot.ToString();
            //
        }
    }
        protected void ShowLobbyScenes()
        {
            var lobby = target as NetworkLobbyManager;

            if (lobby == null)
            {
                return;
            }
            var offlineObj = GetSceneObject(lobby.lobbyScene);

            EditorGUI.BeginChangeCheck();
            var newOfflineScene = EditorGUILayout.ObjectField(m_LobbySceneLabel, offlineObj, typeof(SceneAsset), false);

            if (EditorGUI.EndChangeCheck())
            {
                if (newOfflineScene == null)
                {
                    m_NetworkManager.offlineScene = "";
                    var prop = serializedObject.FindProperty("m_LobbyScene");
                    prop.stringValue = "";
                    EditorUtility.SetDirty(lobby);
                }
                else
                {
                    if (newOfflineScene.name != m_NetworkManager.offlineScene)
                    {
                        var sceneObj = GetSceneObject(newOfflineScene.name);
                        if (sceneObj == null)
                        {
                            Debug.LogWarning("The scene " + newOfflineScene.name + " cannot be used. To use this scene add it to the build settings for the project");
                        }
                        else
                        {
                            var prop = serializedObject.FindProperty("m_LobbyScene");
                            prop.stringValue = newOfflineScene.name;
                            m_NetworkManager.offlineScene = newOfflineScene.name;


                            RG_NetworkLobbyManager rg_NetworkLobbyManager = (RG_NetworkLobbyManager)target;
                            rg_NetworkLobbyManager.lobbyScene = newOfflineScene.name;



                            EditorUtility.SetDirty(lobby);
                        }
                    }
                }
            }
//			var onlineObj = GetSceneObject(lobby.playScene);
//			EditorGUI.BeginChangeCheck();
//			var newOnlineScene = EditorGUILayout.ObjectField(m_PlaySceneLabel, onlineObj, typeof(SceneAsset), false);
//			if (EditorGUI.EndChangeCheck()){
//				if (newOnlineScene == null){
//					m_NetworkManager.onlineScene = "";
//					var prop = serializedObject.FindProperty("m_PlayScene");
//					prop.stringValue = "";
//					EditorUtility.SetDirty(lobby);
//				}
//				else{
//					if (newOnlineScene.name != m_NetworkManager.onlineScene){
//						var sceneObj = GetSceneObject(newOnlineScene.name);
//						if (sceneObj == null){
//							Debug.LogWarning("The scene " + newOnlineScene.name + " cannot be used. To use this scene add it to the build settings for the project");
//						}
//						else{
//							var prop = serializedObject.FindProperty("m_PlayScene");
//							prop.stringValue = newOnlineScene.name;
//							m_NetworkManager.onlineScene = "";
//							EditorUtility.SetDirty(lobby);
//						}
//					}
//				}
//			}
        }