本文整理汇总了C#中UnityEngine.Networking.NetworkConnection类的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection类的具体用法?C# NetworkConnection怎么用?C# NetworkConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkConnection类属于UnityEngine.Networking命名空间,在下文中一共展示了NetworkConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public int Add(int connId, NetworkConnection conn)
{
if (connId < 0)
{
if (LogFilter.logWarn)
{
Debug.LogWarning("ConnectionArray Add bad id " + connId);
}
return -1;
}
if ((connId < this.m_Connections.Count) && (this.m_Connections[connId] != null))
{
if (LogFilter.logWarn)
{
Debug.LogWarning("ConnectionArray Add dupe at " + connId);
}
return -1;
}
while (connId > (this.m_Connections.Count - 1))
{
this.m_Connections.Add(null);
}
this.m_Connections[connId] = conn;
return connId;
}
示例2: OnLobbyClientSceneChanged
public override void OnLobbyClientSceneChanged(NetworkConnection conn) {
if (!conn.playerControllers [0].unetView.isLocalPlayer)
return;
if (SceneManager.GetActiveScene ().name == lobbyScene) {
if (topPanel.isInGame) {
ChangeTo (lobbyPanel);
if (isMatchmaking) {
if (conn.playerControllers [0].unetView.isServer) {
backDelegate = StopHostToMenu;
} else {
backDelegate = QuitLobbyToMenu;
}
} else {
if (conn.playerControllers [0].unetView.isClient) {
backDelegate = StopHostToMenu;
} else {
backDelegate = QuitLobbyToMenu;
}
}
} else {
ChangeTo (mainMenuPanel);
}
topPanel.ToggleVisibility (true);
topPanel.isInGame = false;
} else {
ChangeTo (null);
Destroy (GameObject.Find ("MainMenuUI(Clone)"));
backDelegate = StopGameClbk;
topPanel.isInGame = true;
topPanel.ToggleVisibility (false);
}
}
示例3: AddObserver
internal void AddObserver(NetworkConnection conn)
{
if (this.m_Observers == null)
{
if (LogFilter.logError)
{
Debug.LogError("AddObserver for " + base.gameObject + " observer list is null");
}
}
else if (this.m_ObserverConnections.Contains(conn.connectionId))
{
if (LogFilter.logDebug)
{
Debug.Log(string.Concat(new object[] { "Duplicate observer ", conn.address, " added for ", base.gameObject }));
}
}
else
{
if (LogFilter.logDev)
{
Debug.Log(string.Concat(new object[] { "Added observer ", conn.address, " added for ", base.gameObject }));
}
this.m_Observers.Add(conn);
this.m_ObserverConnections.Add(conn.connectionId);
conn.AddToVisList(this);
}
}
示例4: AddLocal
public int AddLocal(NetworkConnection conn)
{
this.m_LocalConnections.Add(conn);
int num = -this.m_LocalConnections.Count;
conn.connectionId = num;
return num;
}
示例5: OnLobbyClientSceneChanged
/// <summary>This is called on the client when the client is finished loading a new networked scene</summary>
public override void OnLobbyClientSceneChanged(NetworkConnection conn)
{
Log("OnLobbyClientSceneChanged:{0}", conn);
if (OnUNetSceneChanged != null)
OnUNetSceneChanged(conn);
}
示例6: SendToTransport
public bool SendToTransport(NetworkConnection conn, int channelId)
{
byte num;
bool flag = true;
if (!conn.TransportSend(this.m_Buffer, (ushort) this.m_Position, channelId, out num) && (!this.m_IsReliable || (num != 4)))
{
if (LogFilter.logError)
{
Debug.LogError(string.Concat(new object[] { "Failed to send internal buffer channel:", channelId, " bytesToSend:", this.m_Position }));
}
flag = false;
}
if (num != 0)
{
if (this.m_IsReliable && (num == 4))
{
NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 30, "msg", 1);
return false;
}
if (LogFilter.logError)
{
Debug.LogError(string.Concat(new object[] { "Send Error: ", (NetworkError) num, " channel:", channelId, " bytesToSend:", this.m_Position }));
}
flag = false;
}
this.m_Position = 0;
return flag;
}
示例7: OnClientError
/// <summary>Called on clients when a network error occurs.</summary>
public override void OnClientError(NetworkConnection conn, int errorCode)
{
Log("OnClientError");
//ChangeTo(mainMenuPanel);
//infoPanel.Display("Cient error : " + (errorCode == 6 ? "timeout" : errorCode.ToString()), "Close", null);
}
示例8: OnServerDisconnect
public override void OnServerDisconnect(NetworkConnection conn)
{
MyDebug.LogF("NetworkManagerCallbacks,OnServerDisconnect: {0})", conn.address);
base.OnServerDisconnect(conn);
if (NetworkPlayManager.Instance.OnServerDisconnect != null)
NetworkPlayManager.Instance.OnServerDisconnect();
}
示例9: OnClientConnect
/// <summary>Called on the client when connected to a server</summary>
public override void OnClientConnect(NetworkConnection conn)
{
Log("OnClientConnect:{0}", conn);
base.OnClientConnect(conn);
if (OnUNetClientConnect != null)
OnUNetClientConnect();
}
示例10: OnLobbyClientConnect
public override void OnLobbyClientConnect(NetworkConnection conn)
{
base.OnLobbyClientConnect(conn);
Type serverType = typeof(NetworkServer);
FieldInfo info = serverType.GetField("maxPacketSize",
BindingFlags.NonPublic | BindingFlags.Static);
ushort maxPackets = 1500;
info.SetValue(null, maxPackets);
}
开发者ID:cristi16,项目名称:Artefacts---Collaborative-evolution-of-three-dimensional-objects,代码行数:9,代码来源:LobbyManager.cs
示例11: OnCheckObserver
// NetBehaviour override
public override bool OnCheckObserver(NetworkConnection newObserver)
{
if (this.forceHidden)
{
return false;
}
PlayerController playerController = newObserver.playerControllers[0];
Vector3 position = playerController.unetView.get_gameObject().get_transform().get_position();
return (position - base.get_transform().get_position()).get_magnitude() < (float)this.visRange;
}
示例12: OnClientSceneChanged
/// <summary>
/// Called on the client when ever the scene changes.
///
/// todo: Don't handle player spawning in here. We currently do it here because we want to spawn
/// a player object as soon as we change to the online scene. However further down the road we
/// will have more than just one scene and will eventually run into problems where this function
/// is called for every scene. Which we don't want potentially. Rather we will not be unloading
/// spawned player objects on scene changes.
/// </summary>
/// <param name="conn"></param>
public override void OnClientSceneChanged(NetworkConnection conn)
{
base.OnClientSceneChanged(conn);
Debug.Log("OnClientSceneChanged");
// spawn our player
var msg = new AddPlayerMessage();
msg.playerPrefabIndex = networkPrefabIndex;
msg.name = localPlayerName;
ClientScene.AddPlayer(conn, 0, msg);
}
示例13: CheckConnectionIsReadyToBegin
private static bool CheckConnectionIsReadyToBegin(NetworkConnection conn)
{
foreach (PlayerController controller in conn.playerControllers)
{
if (controller.IsValid && !controller.gameObject.GetComponent<NetworkLobbyPlayer>().readyToBegin)
{
return false;
}
}
return true;
}
示例14: OnClientConnect
public override void OnClientConnect(NetworkConnection conn)
{
base.OnClientConnect (conn);
infoPanel.gameObject.SetActive (false);
if (!NetworkServer.active) {//only for pure client (not self hosting client)
ChangeTo (lobbyPanel);
backDelegate = StopClientClbk;
SetServerInfo ("Client", networkAddress);
}
}
示例15: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
GameObject player;
Debug.Log ("Adding Player");
// Ensure that client always spawns on client side, host always spawns on server side
player = (GameObject)GameObject.Instantiate(playerPrefab, manager.GetStartPosition().transform.position, Quaternion.identity);
player.transform.SetParent(imageTarget);
//GameObject.Find ("Notification").GetComponent<Text> ().text = "A new Player joined the game.";
//GameObject.Find ("NPanel").SetActive (true);
//StartCoroutine (HideNotification ());
NetworkServer.AddPlayerForConnection (conn, player, playerControllerId);
}