本文整理汇总了C#中UnityEngine.NetworkPlayer类的典型用法代码示例。如果您正苦于以下问题:C# NetworkPlayer类的具体用法?C# NetworkPlayer怎么用?C# NetworkPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkPlayer类属于UnityEngine命名空间,在下文中一共展示了NetworkPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkJobAvailable
public bool checkJobAvailable(string typeString, int carNumber, NetworkPlayer networkPlayer)
{
if (carNumber < 0 || carNumber >= Game.Cars.Count)
{
return false;
}
Car car = Game.Cars[carNumber];
if (car == null)
{
return false;
}
Player player = (typeString == "Throttler" ? car.Throttler : car.Driver);
if (player.NetworkPlayer != default(NetworkPlayer))
{
return false;
}
if (typeString == "Throttler")
{
car.Throttler.NetworkPlayer = networkPlayer;
}
else
{
car.Driver.NetworkPlayer = networkPlayer;
}
return true;
}
示例2: GenerateToken
public static string GenerateToken(string identifier, string password_or_token, NetworkPlayer? np = null)
{
PurpleAccount userData = get_database_user (identifier);
if(userData == null)
return string.Empty;
return GenerateToken (userData, password_or_token, np);
}
示例3: client_validate_username_handler
// HANDLER /////////////////////////
// ACCOUNT /////////////////////////
public static void client_validate_username_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Username validation received: #" + np.ToString());
_PMBasic.Data basicData = PurpleSerializer.StringToObjectConverter<_PMBasic.Data> (dataObject);
basicData.validate = AccountHelper.IsUniqueUsername (basicData.data);
PurpleNetwork.ToPlayer (np, "server_validate_username_result", basicData);
}
示例4: ServerPlaceBlock
public void ServerPlaceBlock( NetworkPlayer sender, int x, int y, int z, int chunkx, int chunky, int chunkz, int data )
{
if (EnableDebugLog) Debug.Log ("UniblocksServer: Received PlaceBlock from player " + sender.ToString());
// You can check whether the change sent by the client is valid here
// if (true) {
DistributeChange (sender, x,y,z, chunkx, chunky,chunkz, data, false);
// }
}
示例5: SwitchServer
public static void SwitchServer(NetworkPlayer np, string hostname, string password, int port, string token)
{
_PMServer.SwitchMessage switchObject = new _PMServer.SwitchMessage ();
switchObject.Hostname = hostname;
switchObject.Password = password;
switchObject.Port = port;
switchObject.SwitchToken = token;
PurpleNetwork.ToPlayer (np, "server_switch", switchObject);
}
示例6: remove_account_handler
// DESTROY /////////////////////////
public static void remove_account_handler(object ob, NetworkPlayer np)
{
PurpleNetwork.RemoveListener("client_validate_username", client_validate_username_handler);
PurpleNetwork.RemoveListener("client_register", client_register_handler);
PurpleNetwork.RemoveListener("client_disable", client_disable_handler);
PurpleNetwork.RemoveListener("client_create_character", client_create_character_handler);
PurpleNetwork.DisconnectedFromPurpleServer -= remove_account_handler;
}
示例7: SendVoxelData
public void SendVoxelData( NetworkPlayer player, int chunkx, int chunky, int chunkz )
{
// >> You can check whether the request for voxel data is valid here <<
// if (true) {
Chunk chunk = ChunkManager.SpawnChunk (chunkx,chunky,chunkz).GetComponent<Chunk>(); // get the chunk (spawn it if it's not spawned already)
chunk.Lifetime = 0f; // refresh the chunk's lifetime
string data = ChunkDataFiles.CompressData (chunk); // get data from the chunk and compress it
byte[] dataBytes = GetBytes (data); // convert to byte array (sending strings over RPC doesn't work too well)
GetComponent<NetworkView>().RPC ("ReceiveVoxelData", player, chunkx, chunky, chunkz, dataBytes); // send compressed data to the player who requested it
// }
}
示例8: client_authenticate_switch_handler
public static void client_authenticate_switch_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Authentication Switch received: #" + np.ToString());
if(np.ToString() == Constants.SERVER_ID_STRING && Network.isServer) return;
_PMClient.Authentication authObject = PurpleSerializer.StringToObjectConverter<_PMClient.Authentication> (dataObject);
bool validationResult = false;
string newToken = string.Empty;
// TODO...
}
示例9: client_disable_handler
//TODO: test
public static void client_disable_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Authentication received: #" + np.ToString());
_PMClient.Authentication authObject = PurpleSerializer.StringToObjectConverter<_PMClient.Authentication> (dataObject);
_PMBasic.Boolean returnData = new _PMBasic.Boolean ();
returnData.value = AccountHelper.Disable (authObject.ClientName, authObject.ClientPassword, np);
AccountHelper.AddLog(get_network_player_reference(np).UserName,
"client_disable_handler " + authObject.ClientName + " - " + returnData.value.ToString());
PurpleNetwork.ToPlayer (np, "server_disable_result", returnData);
}
示例10: DestroyBlockMultiplayer
// multiplayer
public static void DestroyBlockMultiplayer( VoxelInfo voxelInfo, NetworkPlayer sender )
{
// received from server, don't use directly
GameObject voxelObject = Instantiate ( Engine.GetVoxelGameObject (voxelInfo.GetVoxel()) ) as GameObject;
VoxelEvents events = voxelObject.GetComponent<VoxelEvents>();
if (events != null) {
events.OnBlockDestroy(voxelInfo);
events.OnBlockDestroyMultiplayer(voxelInfo, sender);
}
voxelInfo.chunk.SetVoxel (voxelInfo.index, 0, true);
Destroy(voxelObject);
}
示例11: connected_to_server_handler
// EVENT /////////////////////////
public static void connected_to_server_handler(object ob, NetworkPlayer np)
{
// TODO - server switch
if(string.IsNullOrEmpty(PurpleClient.CurrentConfig.ServerSwitchToken))
{
Calls.Base.Authenticate (PurpleClient.CurrentConfig);
}
else
{
Calls.Base.AuthenticateSwitch (PurpleClient.CurrentConfig);
}
Calls.Base.GetVersion ();
}
示例12: client_authenticate_handler
public static void client_authenticate_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Authentication received: #" + np.ToString());
if(np.ToString() == Constants.SERVER_ID_STRING && Network.isServer) return;
_PMClient.Authentication authObject = PurpleSerializer.StringToObjectConverter<_PMClient.Authentication> (dataObject);
bool validationResult = false;
string newToken = string.Empty;
if(string.IsNullOrEmpty(authObject.ClientPassword))
{
validationResult = AccountHelper.ValidateAuthentication (authObject.ClientName, authObject.ClientToken);
if(validationResult)
newToken = AccountHelper.GenerateToken(authObject.ClientName, authObject.ClientToken, np);
}
else
{
validationResult = AccountHelper.Login (authObject.ClientName, authObject.ClientPassword, np, out newToken);
}
authObject.validate = validationResult;
authObject.timestamp = DateTime.Now;
// save 2 spaces if monitoring is allowed otherwise just one for Admin/Mod/GM
int maxAllowedConnections = PurpleServer.CurrentConfig.ServerMaxClients;
maxAllowedConnections -= (PurpleServer.CurrentConfig.ServerAllowMonitoring) ? 2 : 1;
authObject.ClientPassword = String.Empty;
authObject.ClientToken = String.Empty;
authObject.ClientAuthenticated = false;
if(validationResult && PurpleServer.UserList.Count <= maxAllowedConnections)
{
authObject.ClientToken = newToken;
authObject.ClientAuthenticated = true;
}
else if(validationResult)
{
PurpleNetworkUser playerReference = get_network_player_reference(np);
if (playerReference.UserType != UserTypes.User)
{
authObject.ClientToken = newToken;
authObject.ClientAuthenticated = true;
}
}
AccountHelper.AddLog(get_network_player_reference(np).UserName, "client_authenticate_handler "
+ authObject.ClientName + " - "+ authObject.ClientAuthenticated);
PurpleDebug.Log("Authentication result: " + authObject.ClientName + ": " + authObject.ClientAuthenticated);
PurpleNetwork.ToPlayer(np, "server_authenticate_result", authObject);
}
示例13: ChangeBlockMultiplayer
public static void ChangeBlockMultiplayer( VoxelInfo voxelInfo, ushort data, NetworkPlayer sender )
{
// received from server, don't use directly
voxelInfo.chunk.SetVoxel (voxelInfo.index, data, true);
GameObject voxelObject = Instantiate ( Engine.GetVoxelGameObject (data) ) as GameObject;
VoxelEvents events = voxelObject.GetComponent<VoxelEvents>();
if (events != null) {
events.OnBlockChange(voxelInfo);
events.OnBlockChangeMultiplayer(voxelInfo, sender);
}
Destroy (voxelObject);
}
示例14: PurpleNetworkUser
public PurpleNetworkUser(NetworkPlayer player)
{
UserReference = player;
UserGUID = new Guid ();
UserID = -1;
UserType = UserTypes.User;
UserAuthenticated = false;
UserConnectedTime = DateTime.Now;
UserName = String.Empty;
UserPassword = String.Empty;
UserToken = String.Empty;
UserTokenCreated = DateTime.MinValue;
}
示例15: ReceiveChangeBlock
public void ReceiveChangeBlock( NetworkPlayer sender, int x, int y, int z, int chunkx, int chunky, int chunkz, int data )
{
// receives a change sent by other client or server
GameObject chunkObject = ChunkManager.GetChunk (chunkx,chunky,chunkz);
if (chunkObject != null) {
// convert back to VoxelInfo
Index voxelIndex = new Index (x,y,z);
VoxelInfo info = new VoxelInfo (voxelIndex, chunkObject.GetComponent<Chunk>());
// apply change
Voxel.ChangeBlockMultiplayer (info, (ushort)data, sender);
}
}