当前位置: 首页>>代码示例>>C#>>正文


C# NetworkConnection类代码示例

本文整理汇总了C#中NetworkConnection的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection类的具体用法?C# NetworkConnection怎么用?C# NetworkConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkConnection类属于命名空间,在下文中一共展示了NetworkConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnServerAddPlayer

 public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
 {
     int index = Random.Range(0, spawnPoints.Length);
     GameObject player = (GameObject)Instantiate(playerPrefab, spawnPoints[index], Quaternion.identity/*spawnPoints[index].rotation*/);
     player.GetComponent<Move>().myColor = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
     NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
 }
开发者ID:BaptisteMarechaux,项目名称:Blow-Game-2016,代码行数:7,代码来源:NetworkManagerCustom.cs

示例2: OnServerAddPlayer

    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        GameObject player = (GameObject)Instantiate(playerPrefab, Vector3.up*15, Quaternion.identity);
        ClientHub bus = player.GetComponent<ClientHub>();

        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    }
开发者ID:beardhero,项目名称:HEX,代码行数:7,代码来源:UNetInterface.cs

示例3: OnServerAddPlayer

 /*public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader)
 {
     Debug.Log('on server add player');
     OnServerAddPlayer(conn, playerControllerId, extraMessageReader);
 }*/
 public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
 {
     Debug.Log ("Adding a player to game");
     var startingLocation = GetStartPosition ();
     var player = (GameObject)GameObject.Instantiate(playerPrefab, startingLocation.position, Quaternion.identity);
     NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
 }
开发者ID:nicholaswagner,项目名称:ggj2016,代码行数:12,代码来源:MyNetworkManager.cs

示例4: OnConnectFailed

 public override void OnConnectFailed(NetworkConnection connection)
 {
     if (this.ConnectionFailedCallback != null)
     {
         this.ConnectionFailedCallback(connection);
     }
 }
开发者ID:thelegend6420,项目名称:holograms-240,代码行数:7,代码来源:NetworkConnectionAdapter.cs

示例5: OnMessageReceived

 public override void OnMessageReceived(NetworkConnection connection, NetworkInMessage message)
 {
     if (this.MessageReceivedCallback != null)
     {
         this.MessageReceivedCallback(connection, message);
     }
 }
开发者ID:thelegend6420,项目名称:holograms-240,代码行数:7,代码来源:NetworkConnectionAdapter.cs

示例6: OnClientDisconnect

	override public void OnClientDisconnect (NetworkConnection conn)
	{
		base.OnClientDisconnect (conn);
		print ("CLIENT: disconnected from " + conn.address);
		conn.UnregisterHandler (MsgCode);
		netDiscovery.shouldConnect = true;
	}
开发者ID:nickskull,项目名称:HofmannTriptych,代码行数:7,代码来源:MessagesNetworkManager.cs

示例7: OnServerRemovePlayer

 // called when a player is removed for a client
 public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player)
 {
     if (player.gameObject != null)
     {
         NetworkServer.Destroy(player.gameObject);
     }
 }
开发者ID:kodeklubben-tromso,项目名称:unity,代码行数:8,代码来源:TankNetworkManager.cs

示例8: NetworkInstantiateFromPool

    public Transform NetworkInstantiateFromPool(Transform prefab, Vector3 pos, Quaternion rot, NetworkConnection authority = null)
    {
        int index = PrefabIndex (prefab);
        if (index < 0) {
            Debug.LogError ("Prefab " + prefab.name + " is not in poolable set");
            return null;
        }
        Transform inst = InstantiateInternal (index, prefab.gameObject.tag, prefab.gameObject.layer, pos, rot);
        if (NetworkServer.active) {
            if (inst.GetComponent<NetworkIdentity>() == null) {
                Debug.LogError ("pooler Trying to instantiate a prefab " + prefab.gameObject.name + " without id", prefab);
            }

            SendRemoteInstanceToClients (PrefabIndex(prefab), prefab.gameObject.tag, prefab.gameObject.layer, pos, rot);
            if (authority == null) {
                Debug.Log ("Spawning " + prefab.gameObject.name + " without client authority " + authority);
                NetworkServer.Spawn(inst.gameObject);
            } else {
                Debug.Log ("Spawning " + prefab.gameObject.name + " with client authority " + authority);
                NetworkServer.SpawnWithClientAuthority (inst.gameObject, authority);
            }
        } else if (NetworkClient.active) {
            localInstances.Add (inst);
            // callbacks.Add (func);
            SendRemoteInstanceToServer (index, prefab.gameObject.tag, prefab.gameObject.layer, pos, rot);
        }
        return inst;
    }
开发者ID:tosos,项目名称:Geewhiz,代码行数:28,代码来源:Pooler.cs

示例9: ConnectTo

		public void ConnectTo (NetworkConnection con)
		{
			//Console.WriteLine ("Connecting to {0}", con.ConnectionName);
			
			NetworkDevice dev; 
			string specObj;
			if (con is WirelessConnection) {
				dev = DevManager.NetworkDevices.OfType<WirelessDevice> ().First ();
				specObj = (dev as WirelessDevice).APBySSID ((con as WirelessConnection).SSID).ObjectPath;
			} else if (con is WiredConnection) {
				dev = DevManager.NetworkDevices.OfType<WiredDevice> ().First ();
				specObj = "/";
			} else {
				return;
			}
			
			string serviceName;
			if (con.Owner == ConnectionOwner.System)
				serviceName = "org.freedesktop.NetworkManagerSystemSettings";
			else
				serviceName = "org.freedesktop.NetworkManagerUserSettings";
			string conStr = con.ObjectPath;
			
			DevManager.BusObject.ActivateConnection(serviceName, new ObjectPath (conStr), new ObjectPath (dev.ObjectPath), new ObjectPath (specObj));
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:25,代码来源:NetworkManager.cs

示例10: OnServerAddPlayer

 public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
 {
     Debug.LogWarning("Add Player");
     GameObject player = (GameObject)Instantiate(playerPrefab, spawnPosition/*spawnPoints[connectionNumber].position*/, Quaternion.identity);
     NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
     connectionNumber += 1;
 }
开发者ID:ClaXus,项目名称:twrts,代码行数:7,代码来源:GameManager.cs

示例11: OnLobbyClientConnect

    /*
     * Client Callbacks
    */
    public override void OnLobbyClientConnect(NetworkConnection conn)
    {
        connectingCanvas.Hide();

        //charCreation = GameObject.Find("CharacterCreation");
        //charCreation.SetActive(false);
    }
开发者ID:UCCS-GDD,项目名称:CS3350-TheCreakingGrounds,代码行数:10,代码来源:GuiLobbyManager.cs

示例12: OnServerAddPlayer

 public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
 {
     //base.OnServerAddPlayer(conn, playerControllerId);
     this.conn = conn;
     this.playerId = playerControllerId;
     canvasName.SetActive(true);
 }
开发者ID:paganini24,项目名称:UAgario,代码行数:7,代码来源:MyNetworkManager.cs

示例13: OnClientConnect

 //Called on client when connected to server
 public override void OnClientConnect(NetworkConnection conn)
 {
     base.OnClientConnect(conn);
     //HandshakeMsg msg = new HandshakeMsg();
     //msg.username = this.username;
     //conn.Send(HandshakeMsg.msgType, msg);
 }
开发者ID:sctjkc01,项目名称:Tubular,代码行数:8,代码来源:GameNetworkManager.cs

示例14: dumbEquals

	bool dumbEquals (NetworkConnection dumb){
		if (checkingEquality == null) {
			return false;
		} else {
			return dumb.Equals (checkingEquality);
		}
	}
开发者ID:Tandreyvia,项目名称:BurnedPhones,代码行数:7,代码来源:Server.cs

示例15: OnServerAddPlayer

    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        playerNumber++;
        var player = (GameObject)GameObject.Instantiate(playerPrefab, GetSpawnPosition(), Quaternion.identity); //Default implementation
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId); //Default implementation

        try { ScoreManager SM = GetComponentInChildren<ScoreManager>();
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player"))
                if (conn.clientOwnedObjects.Contains(go.GetComponent<NetworkIdentity>().netId)) {
                    go.GetComponent<EventManager>().SendScoreEvent(SM.teamOneScore, SM.teamTwoScore);
                    go.GetComponent<PlayerStats>().RpcServerInitTime(Network.time - SM.initServerTime);
                    break;
                }
        } catch { Debug.Log("No Score Manager found!"); }

        // Do the mapHandler code only when on the correct scene
        //if (onlineScene.Equals("'stinaScene_foolingaroundwithCircles")) {
        if (onlineScene.Equals("HenrikScene")) {
            mapCreator MC = GameObject.Find("mapHandler").GetComponent<mapCreator>();
            if (playerNumber == 2) {
                GetComponentInChildren<ScoreManager>().sinkTimer = (float)Network.time; // Only to be done once
                MC.SinkingSyncing(GetComponentInChildren<ScoreManager>().sinkTimer);
            }
            MC.playerConnected();
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player"))
                go.GetComponent<PlayerStats>().GenerateTerrain();
                //go.GetComponent<PlayerStats>().GenerateTerrain(GetComponentInChildren<ScoreManager>().sinkTimer);
        }
        StartCoroutine(PlayerJoined());
    }
开发者ID:PeWiNi,项目名称:MonguinsAndBeyond,代码行数:30,代码来源:MyNetworkManager.cs


注:本文中的NetworkConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。