本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: OnConnectFailed
public override void OnConnectFailed(NetworkConnection connection)
{
if (this.ConnectionFailedCallback != null)
{
this.ConnectionFailedCallback(connection);
}
}
示例5: OnMessageReceived
public override void OnMessageReceived(NetworkConnection connection, NetworkInMessage message)
{
if (this.MessageReceivedCallback != null)
{
this.MessageReceivedCallback(connection, message);
}
}
示例6: OnClientDisconnect
override public void OnClientDisconnect (NetworkConnection conn)
{
base.OnClientDisconnect (conn);
print ("CLIENT: disconnected from " + conn.address);
conn.UnregisterHandler (MsgCode);
netDiscovery.shouldConnect = true;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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;
}
示例11: OnLobbyClientConnect
/*
* Client Callbacks
*/
public override void OnLobbyClientConnect(NetworkConnection conn)
{
connectingCanvas.Hide();
//charCreation = GameObject.Find("CharacterCreation");
//charCreation.SetActive(false);
}
示例12: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
//base.OnServerAddPlayer(conn, playerControllerId);
this.conn = conn;
this.playerId = playerControllerId;
canvasName.SetActive(true);
}
示例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);
}
示例14: dumbEquals
bool dumbEquals (NetworkConnection dumb){
if (checkingEquality == null) {
return false;
} else {
return dumb.Equals (checkingEquality);
}
}
示例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());
}