本文整理汇总了C#中UnityEngine.Networking.NetworkConnection.GetPlayerController方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection.GetPlayerController方法的具体用法?C# NetworkConnection.GetPlayerController怎么用?C# NetworkConnection.GetPlayerController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Networking.NetworkConnection
的用法示例。
在下文中一共展示了NetworkConnection.GetPlayerController方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalReplacePlayerForConnection
internal bool InternalReplacePlayerForConnection(NetworkConnection conn, GameObject playerGameObject, short playerControllerId)
{
NetworkIdentity identity;
PlayerController controller;
if (!GetNetworkIdentity(playerGameObject, out identity))
{
if (LogFilter.logError)
{
Debug.LogError("ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
}
return false;
}
if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
{
return false;
}
if (LogFilter.logDev)
{
Debug.Log("NetworkServer ReplacePlayer");
}
if (conn.GetPlayerController(playerControllerId, out controller))
{
controller.unetView.SetNotLocalPlayer();
controller.unetView.ClearClientOwner();
}
PlayerController player = new PlayerController(playerGameObject, playerControllerId);
conn.SetPlayerController(player);
identity.SetConnectionToClient(conn, player.playerControllerId);
if (LogFilter.logDev)
{
Debug.Log("NetworkServer ReplacePlayer setup local");
}
if (!this.SetupLocalPlayerForConnection(conn, identity, player))
{
if (LogFilter.logDebug)
{
Debug.Log(string.Concat(new object[] { "Replacing playerGameObject object netId: ", playerGameObject.GetComponent<NetworkIdentity>().netId, " asset ID ", playerGameObject.GetComponent<NetworkIdentity>().assetId }));
}
FinishPlayerForConnection(conn, identity, playerGameObject);
if (identity.localPlayerAuthority)
{
identity.SetClientOwner(conn);
}
}
return true;
}
示例2: InternalAddPlayerForConnection
internal bool InternalAddPlayerForConnection(NetworkConnection conn, GameObject playerGameObject, short playerControllerId)
{
NetworkIdentity view;
if (!NetworkServer.GetNetworkIdentity(playerGameObject, out view))
{
if (LogFilter.logError)
Debug.Log((object) ("AddPlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + (object) playerGameObject));
return false;
}
if (!this.CheckPlayerControllerIdForConnection(conn, playerControllerId))
return false;
PlayerController playerController1 = (PlayerController) null;
GameObject gameObject = (GameObject) null;
if (conn.GetPlayerController(playerControllerId, out playerController1))
gameObject = playerController1.gameObject;
if ((UnityEngine.Object) gameObject != (UnityEngine.Object) null)
{
if (LogFilter.logError)
Debug.Log((object) ("AddPlayer: player object already exists for playerControllerId of " + (object) playerControllerId));
return false;
}
PlayerController playerController2 = new PlayerController(playerGameObject, playerControllerId);
conn.SetPlayerController(playerController2);
view.m_PlayerId = playerController2.playerControllerId;
view.SetConnectionToClient(conn);
NetworkServer.SetClientReady(conn);
if (this.SetupLocalPlayerForConnection(conn, view, playerController2))
return true;
if (LogFilter.logDebug)
{
object[] objArray = new object[4];
int index1 = 0;
string str1 = "Adding new playerGameObject object netId: ";
objArray[index1] = (object) str1;
int index2 = 1;
// ISSUE: variable of a boxed type
__Boxed<NetworkInstanceId> local1 = (ValueType) playerGameObject.GetComponent<NetworkIdentity>().netId;
objArray[index2] = (object) local1;
int index3 = 2;
string str2 = " asset ID ";
objArray[index3] = (object) str2;
int index4 = 3;
// ISSUE: variable of a boxed type
__Boxed<NetworkHash128> local2 = (ValueType) playerGameObject.GetComponent<NetworkIdentity>().assetId;
objArray[index4] = (object) local2;
Debug.Log((object) string.Concat(objArray));
}
this.FinishPlayerForConnection(conn, view, playerGameObject);
return true;
}
示例3: InternalAddPlayerForConnection
internal bool InternalAddPlayerForConnection(NetworkConnection conn, GameObject playerGameObject, short playerControllerId)
{
NetworkIdentity identity;
if (!GetNetworkIdentity(playerGameObject, out identity))
{
if (LogFilter.logError)
{
Debug.Log("AddPlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to " + playerGameObject);
}
return false;
}
if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
{
return false;
}
PlayerController playerController = null;
GameObject gameObject = null;
if (conn.GetPlayerController(playerControllerId, out playerController))
{
gameObject = playerController.gameObject;
}
if (gameObject != null)
{
if (LogFilter.logError)
{
Debug.Log("AddPlayer: player object already exists for playerControllerId of " + playerControllerId);
}
return false;
}
PlayerController player = new PlayerController(playerGameObject, playerControllerId);
conn.SetPlayerController(player);
identity.SetConnectionToClient(conn, player.playerControllerId);
SetClientReady(conn);
if (!this.SetupLocalPlayerForConnection(conn, identity, player))
{
if (LogFilter.logDebug)
{
Debug.Log(string.Concat(new object[] { "Adding new playerGameObject object netId: ", playerGameObject.GetComponent<NetworkIdentity>().netId, " asset ID ", playerGameObject.GetComponent<NetworkIdentity>().assetId }));
}
FinishPlayerForConnection(conn, identity, playerGameObject);
if (identity.localPlayerAuthority)
{
identity.SetClientOwner(conn);
}
}
return true;
}