本文整理汇总了C#中UnityEngine.Networking.NetworkConnection类的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection类的具体用法?C# NetworkConnection怎么用?C# NetworkConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkConnection类属于UnityEngine.Networking命名空间,在下文中一共展示了NetworkConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:ConnectionArray.cs
示例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);
}
}
开发者ID:xenouk,项目名称:Arena,代码行数:35,代码来源:LobbyManager.cs
示例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);
}
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:27,代码来源:NetworkIdentity.cs
示例4: AddLocal
public int AddLocal(NetworkConnection conn)
{
this.m_LocalConnections.Add(conn);
int num = -this.m_LocalConnections.Count;
conn.connectionId = num;
return num;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:ConnectionArray.cs
示例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);
}
开发者ID:kyousuke916,项目名称:Keep-Alive,代码行数:8,代码来源:LobbyManager.cs
示例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;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:28,代码来源:ChannelPacket.cs
示例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);
}
开发者ID:kyousuke916,项目名称:Keep-Alive,代码行数:8,代码来源:LobbyManager.cs
示例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();
}
开发者ID:osangar88,项目名称:GameFramework,代码行数:8,代码来源:NetworkManagerCallbacks.cs
示例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();
}
开发者ID:kyousuke916,项目名称:Keep-Alive,代码行数:10,代码来源:LobbyManager.cs
示例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;
}
开发者ID:Kitabalef,项目名称:Unet-Decompiles,代码行数:12,代码来源:NetworkProximityChecker.cs
示例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);
}
开发者ID:cpvrlab,项目名称:VirtualTable,代码行数:21,代码来源:VTNetworkManager.cs
示例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;
}
开发者ID:randomize,项目名称:VimConfig,代码行数:11,代码来源:NetworkLobbyManager.cs
示例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);
}
}
开发者ID:sdd4163,项目名称:HideSeekLobby,代码行数:12,代码来源:LobbyManager.cs
示例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);
}
开发者ID:twenty-seven,项目名称:Test3D,代码行数:13,代码来源:NetworkManagerScript.cs
示例16: OnServerAddPlayer
/// <summary>
/// Called on the server when a new client connects and is requesting to be spawned as a player object.
/// </summary>
/// <param name="conn"></param>
/// <param name="playerControllerId"></param>
/// <param name="netMsg"></param>
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader netMsg)
{
//base.OnServerAddPlayer(conn, playerControllerId, netMsg);
var msg = netMsg.ReadMessage<AddPlayerMessage>();
Debug.Log("Adding player... " + msg.name + " " + playerPrefabs[msg.playerPrefabIndex].name);
GameObject player = (GameObject)Instantiate(playerPrefabs[msg.playerPrefabIndex], Vector3.zero, Quaternion.identity);
var gamePlayer = player.GetComponent<GamePlayer>();
gamePlayer.displayName = msg.name;
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
}
开发者ID:cpvrlab,项目名称:VirtualTable,代码行数:19,代码来源:VTNetworkManager.cs
示例17: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
GameObject player = (GameObject)Instantiate(playerPrefab);
player.AppendTo(playersContainer);
player.transform.position = startPositions[0].position;
startPositions.RemoveAt(0);
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
PlayerController controller = player.GetComponent<PlayerController>();
controller.Init();
}
开发者ID:Mouserr,项目名称:TankSimulator,代码行数:13,代码来源:TankNetworkManager.cs
示例18: InvokeHandler
internal bool InvokeHandler(short msgType, NetworkConnection conn, NetworkReader reader, int channelId)
{
if (this.m_MsgHandlers.ContainsKey(msgType))
{
this.m_MessageInfo.msgType = msgType;
this.m_MessageInfo.conn = conn;
this.m_MessageInfo.reader = reader;
this.m_MessageInfo.channelId = channelId;
NetworkMessageDelegate networkMessageDelegate = this.m_MsgHandlers[msgType];
networkMessageDelegate(this.m_MessageInfo);
return true;
}
return false;
}
开发者ID:Kitabalef,项目名称:Unet-Decompiles,代码行数:14,代码来源:NetworkMessageHandlers.cs
示例19: ChannelBuffer
public ChannelBuffer(NetworkConnection conn, int bufferSize, byte cid, bool isReliable)
{
this.m_Connection = conn;
this.m_MaxPacketSize = bufferSize - 100;
this.m_CurrentPacket = new ChannelPacket(this.m_MaxPacketSize, isReliable);
this.m_ChannelId = cid;
this.m_MaxPendingPacketCount = 16;
this.m_IsReliable = isReliable;
if (!isReliable)
return;
this.m_PendingPackets = new Queue<ChannelPacket>();
if (ChannelBuffer.s_FreePackets != null)
return;
ChannelBuffer.s_FreePackets = new List<ChannelPacket>();
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:15,代码来源:ChannelBuffer.cs
示例20: OnServerDisconnect
public static void OnServerDisconnect(NetworkConnection conn)
{
var id = conn.connectionId;
if (!proxies.ContainsKey(id))
{
Debug.LogWarning("Proxy destruction requested for client " + id + " but proxy wasn't registered");
return;
}
var proxy = proxies[id];
NetworkServer.Destroy(proxy);
proxies.Remove(id);
}
开发者ID:pia-keio,项目名称:Ad-hoc_microphone_client,代码行数:15,代码来源:VoiceChatNetworkProxy.cs
注:本文中的UnityEngine.Networking.NetworkConnection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论