C# Class NetworkDirector, PaperCowboys

Inheritance: MonoBehaviour
显示文件 Open project: Gamieon/PaperCowboys Class Usage Examples

Private Properties

Property Type Description
RPCOnMasterClientSwitched void
RPCOnMasterClientSwitched void
RPCOnNetworkPlayerConnected void
RPCOnNetworkPlayerConnected void
RPCOnNetworkPlayerDisconnected void
RPCOnNetworkPlayerDisconnected void
RPCSetPlayerCustomFloat void
RPCSetPlayerCustomFloat void
RPCSetPlayerCustomInt void
RPCSetPlayerCustomInt void
RPCSetPlayerCustomString void
RPCSetPlayerCustomString void
RPCValidationFinished void

Public Methods

Method Description
Awake ( ) : void
BroadcastCustomProperty ( RPCMode target, NetworkPlayer owner, string key, object data ) : void

Called by a client or a server to broadcast their custom property to all other players

BroadcastCustomProperty ( uLink target, uLink owner, string key, object data ) : void

Called by a client or a server to broadcast their custom property to all other players

ClearHostList ( ) : void

Clear the host list which was received by MasterServer.PollHostList.

Connect ( string IP, int remotePort ) : NetworkConnectionError

Connect the specified IP and remotePort.

Connect ( string IP, int remotePort ) : uLink.NetworkConnectionError

Connect the specified IP and remotePort.

Destroy ( GameObject go ) : void

Destroy the specified game object.

Disconnect ( ) : void

Disconnects from the server.

GetCustomPlayerProperty ( NetworkPlayer player, string key ) : object

Called by a server or a client to get a custom player property.

GetCustomPlayerProperty ( uLink player, string key ) : object

Called by a server or a client to get a custom player property.

InitializeServer ( string gameName, int connections, int listenPort ) : void

Initializes the server.

Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject

Instantiates a game object and invokes a RPCNetworkInstantiate call if there are any additional arguments to send them to the object.

Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : void

Instantiates a game object

InstantiateClientObject ( uLink owner, string prefabName, Vector3 position, Quaternion rotation, int group ) : void

Instantiates a game object

InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject

Instantiate a scene-owned prefab over the network. For Unity native networking purposes, this is a fancy way of telling the server to instantiate the object

Only the master client can Instantiate scene objects.

InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group ) : void

Instantiate a "scene-owned" prefab over the network. The idea is that it would persist even if the master client left the game. Because we are an authoritative client-server model, however, this function is pretty much the same as Instantiate except it absolutely must be called by the server. (The Photon networking model had a standalone server that designated players as "masters" to be an authority on things).

Only the master client can Instantiate scene objects.

OnConnectedToServer ( ) : void

Called on the client when you have successfully connected to a server.

OnDisconnectedFromServer ( NetworkDisconnection info ) : void

Called on the client when the connection was lost or you disconnected from the server.

OnFailedToConnect ( NetworkConnectionError error ) : void

Called on the client when a connection attempt fails for some reason.

OnPlayerConnected ( NetworkPlayer player ) : void

Called on the server whenever a new player has successfully connected.

OnPlayerDisconnected ( NetworkPlayer player ) : void

Called on the server whenever a player is disconnected from the server.

OnServerInitialized ( ) : void

Called on the server whenever a Network.InitializeServer was invoked and has completed.

PollHostList ( ) : HostData[]

Check for the latest host list received by using MasterServer.RequestHostList.

PollHostList ( ) : uLink.HostData[]

Check for the latest host list received by using MasterServer.RequestHostList.

RequestHostList ( ) : void

Request a host list from the master server.

SetPlayerCustomProperties ( Hashtable ht ) : void

Called by a server or a client to set several custom properties for your own player

SetPlayerCustomProperties ( Hashtable ht, bool broadcast ) : void

Called by a server or a client to set several custom properties for your own player

SetPlayerCustomProperty ( NetworkPlayer player, string key, object data ) : void

Called by a server or a client to set the custom property for a player in the game.

SetPlayerCustomProperty ( uLink player, string key, object data ) : void

Called by a server or a client to set the custom property for a player in the game.

uLink_OnConnectedToServer ( ) : void

Called on the client when you have successfully connected to a server.

uLink_OnDisconnectedFromServer ( uLink info ) : void

Called on the client when the connection was lost or you disconnected from the server.

uLink_OnFailedToConnect ( uLink error ) : void

Called on the client when a connection attempt fails for some reason.

uLink_OnHandoverTimeout ( uLink player ) : void

Called on the server whenever a player fails to connect to the server in a timely manner

uLink_OnPlayerApproval ( uLink approval ) : void

Called on the server when approving a new player to join the game

uLink_OnPlayerConnected ( uLink player ) : void

Called on the server whenever a new player has successfully connected.

uLink_OnPlayerDisconnected ( uLink player ) : void

Called on the server whenever a player is disconnected from the server.

uLink_OnServerInitialized ( ) : void

Called on the server whenever a Network.InitializeServer was invoked and has completed.

uLink_OnServerUninitialized ( ) : void

Called on the server whenever a Disconnect was invoked and has completed.

Private Methods

Method Description
RPCOnMasterClientSwitched ( NetworkPlayer player ) : void
RPCOnMasterClientSwitched ( uLink player ) : void
RPCOnNetworkPlayerConnected ( NetworkPlayer player ) : void
RPCOnNetworkPlayerConnected ( uLink player ) : void
RPCOnNetworkPlayerDisconnected ( NetworkPlayer player ) : void
RPCOnNetworkPlayerDisconnected ( uLink player ) : void
RPCSetPlayerCustomFloat ( NetworkPlayer player, string key, float data ) : void
RPCSetPlayerCustomFloat ( uLink player, string key, float data ) : void
RPCSetPlayerCustomInt ( NetworkPlayer player, string key, int data ) : void
RPCSetPlayerCustomInt ( uLink player, string key, int data ) : void
RPCSetPlayerCustomString ( NetworkPlayer player, string key, string data ) : void
RPCSetPlayerCustomString ( uLink player, string key, string data ) : void
RPCValidationFinished ( ) : void

Method Details

Awake() public method

public Awake ( ) : void
return void

BroadcastCustomProperty() public method

Called by a client or a server to broadcast their custom property to all other players
public BroadcastCustomProperty ( RPCMode target, NetworkPlayer owner, string key, object data ) : void
target RPCMode
owner NetworkPlayer
key string /// Key. ///
data object /// Data. ///
return void

BroadcastCustomProperty() public method

Called by a client or a server to broadcast their custom property to all other players
public BroadcastCustomProperty ( uLink target, uLink owner, string key, object data ) : void
target uLink
owner uLink
key string /// Key. ///
data object /// Data. ///
return void

ClearHostList() public static method

Clear the host list which was received by MasterServer.PollHostList.
public static ClearHostList ( ) : void
return void

Connect() public static method

Connect the specified IP and remotePort.
public static Connect ( string IP, int remotePort ) : NetworkConnectionError
IP string /// IP address. ///
remotePort int /// Connect to the specified host (ip or domain name) and server port. ///
return NetworkConnectionError

Connect() public static method

Connect the specified IP and remotePort.
public static Connect ( string IP, int remotePort ) : uLink.NetworkConnectionError
IP string /// IP address. ///
remotePort int /// Connect to the specified host (ip or domain name) and server port. ///
return uLink.NetworkConnectionError

Destroy() public static method

Destroy the specified game object.
public static Destroy ( GameObject go ) : void
go GameObject /// The game object ///
return void

Disconnect() public static method

Disconnects from the server.
public static Disconnect ( ) : void
return void

GetCustomPlayerProperty() public static method

Called by a server or a client to get a custom player property.
public static GetCustomPlayerProperty ( NetworkPlayer player, string key ) : object
player NetworkPlayer /// Player. ///
key string /// Key. ///
return object

GetCustomPlayerProperty() public static method

Called by a server or a client to get a custom player property.
public static GetCustomPlayerProperty ( uLink player, string key ) : object
player uLink /// Player. ///
key string /// Key. ///
return object

InitializeServer() public static method

Initializes the server.
public static InitializeServer ( string gameName, int connections, int listenPort ) : void
gameName string
connections int /// Connections. ///
listenPort int /// Listen port. ///
return void

Instantiate() public static method

Instantiates a game object and invokes a RPCNetworkInstantiate call if there are any additional arguments to send them to the object.
public static Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this view.
return GameObject

Instantiate() public method

Instantiates a game object
public Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : void
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this view.
return void

InstantiateClientObject() public method

Instantiates a game object
public InstantiateClientObject ( uLink owner, string prefabName, Vector3 position, Quaternion rotation, int group ) : void
owner uLink The owning client
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this view.
return void

InstantiateSceneObject() public static method

Instantiate a scene-owned prefab over the network. For Unity native networking purposes, this is a fancy way of telling the server to instantiate the object
Only the master client can Instantiate scene objects.
public static InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this view.
return GameObject

InstantiateSceneObject() public method

Instantiate a "scene-owned" prefab over the network. The idea is that it would persist even if the master client left the game. Because we are an authoritative client-server model, however, this function is pretty much the same as Instantiate except it absolutely must be called by the server. (The Photon networking model had a standalone server that designated players as "masters" to be an authority on things).
Only the master client can Instantiate scene objects.
public InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group ) : void
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this view.
return void

OnConnectedToServer() public method

Called on the client when you have successfully connected to a server.
public OnConnectedToServer ( ) : void
return void

OnDisconnectedFromServer() public method

Called on the client when the connection was lost or you disconnected from the server.
public OnDisconnectedFromServer ( NetworkDisconnection info ) : void
info NetworkDisconnection /// Info. ///
return void

OnFailedToConnect() public method

Called on the client when a connection attempt fails for some reason.
public OnFailedToConnect ( NetworkConnectionError error ) : void
error NetworkConnectionError /// Error. ///
return void

OnPlayerConnected() public method

Called on the server whenever a new player has successfully connected.
public OnPlayerConnected ( NetworkPlayer player ) : void
player NetworkPlayer /// Player. ///
return void

OnPlayerDisconnected() public method

Called on the server whenever a player is disconnected from the server.
public OnPlayerDisconnected ( NetworkPlayer player ) : void
player NetworkPlayer /// Player. ///
return void

OnServerInitialized() public method

Called on the server whenever a Network.InitializeServer was invoked and has completed.
public OnServerInitialized ( ) : void
return void

PollHostList() public static method

Check for the latest host list received by using MasterServer.RequestHostList.
public static PollHostList ( ) : HostData[]
return HostData[]

PollHostList() public static method

Check for the latest host list received by using MasterServer.RequestHostList.
public static PollHostList ( ) : uLink.HostData[]
return uLink.HostData[]

RequestHostList() public static method

Request a host list from the master server.
public static RequestHostList ( ) : void
return void

SetPlayerCustomProperties() public static method

Called by a server or a client to set several custom properties for your own player
public static SetPlayerCustomProperties ( Hashtable ht ) : void
ht Hashtable /// A hashtable of properties to change ///
return void

SetPlayerCustomProperties() public static method

Called by a server or a client to set several custom properties for your own player
public static SetPlayerCustomProperties ( Hashtable ht, bool broadcast ) : void
ht Hashtable /// A hashtable of properties to change ///
broadcast bool /// True if we should broadcast the properties to all players ///
return void

SetPlayerCustomProperty() public static method

Called by a server or a client to set the custom property for a player in the game.
public static SetPlayerCustomProperty ( NetworkPlayer player, string key, object data ) : void
player NetworkPlayer /// The player who owns the proerty. ///
key string /// Key. ///
data object /// Data. ///
return void

SetPlayerCustomProperty() public static method

Called by a server or a client to set the custom property for a player in the game.
public static SetPlayerCustomProperty ( uLink player, string key, object data ) : void
player uLink /// The player who owns the proerty. ///
key string /// Key. ///
data object /// Data. ///
return void

uLink_OnConnectedToServer() public method

Called on the client when you have successfully connected to a server.
public uLink_OnConnectedToServer ( ) : void
return void

uLink_OnDisconnectedFromServer() public method

Called on the client when the connection was lost or you disconnected from the server.
public uLink_OnDisconnectedFromServer ( uLink info ) : void
info uLink /// Info. ///
return void

uLink_OnFailedToConnect() public method

Called on the client when a connection attempt fails for some reason.
public uLink_OnFailedToConnect ( uLink error ) : void
error uLink /// Error. ///
return void

uLink_OnHandoverTimeout() public method

Called on the server whenever a player fails to connect to the server in a timely manner
public uLink_OnHandoverTimeout ( uLink player ) : void
player uLink /// Player. ///
return void

uLink_OnPlayerApproval() public method

Called on the server when approving a new player to join the game
public uLink_OnPlayerApproval ( uLink approval ) : void
approval uLink /// Approval. ///
return void

uLink_OnPlayerConnected() public method

Called on the server whenever a new player has successfully connected.
public uLink_OnPlayerConnected ( uLink player ) : void
player uLink /// Player. ///
return void

uLink_OnPlayerDisconnected() public method

Called on the server whenever a player is disconnected from the server.
public uLink_OnPlayerDisconnected ( uLink player ) : void
player uLink /// Player. ///
return void

uLink_OnServerInitialized() public method

Called on the server whenever a Network.InitializeServer was invoked and has completed.
public uLink_OnServerInitialized ( ) : void
return void

uLink_OnServerUninitialized() public method

Called on the server whenever a Disconnect was invoked and has completed.
public uLink_OnServerUninitialized ( ) : void
return void