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


C# UnityEngine.NetworkPlayer类代码示例

本文整理汇总了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;
        }
开发者ID:KvanNes,项目名称:Contextproject-Group5,代码行数:29,代码来源:Server.cs

示例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);
 }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:7,代码来源:AccountHelper.cs

示例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);
 }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:9,代码来源:PurpleNetworkAccountHandler.cs

示例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);
     // }
 }
开发者ID:fancybit,项目名称:VoxelPrototype,代码行数:8,代码来源:UniblocksServer.cs

示例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);
 }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:9,代码来源:PurpleNetworkBaseCalls.cs

示例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;
        }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:11,代码来源:PurpleNetworkAccountHandler.cs

示例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
     // }
 }
开发者ID:fancybit,项目名称:VoxelPrototype,代码行数:11,代码来源:UniblocksServer.cs

示例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...
        }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:11,代码来源:PurpleNetworkBaseHandler.cs

示例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);
        }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:12,代码来源:PurpleNetworkAccountHandler.cs

示例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);
        }
开发者ID:fancybit,项目名称:VoxelPrototype,代码行数:14,代码来源:Voxel.cs

示例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 ();
 }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:14,代码来源:PurpleNetworkBaseHandler.cs

示例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);
        }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:51,代码来源:PurpleNetworkBaseHandler.cs

示例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);
        }
开发者ID:fancybit,项目名称:VoxelPrototype,代码行数:14,代码来源:Voxel.cs

示例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;
        }
开发者ID:dannisliang,项目名称:PurpleScripts,代码行数:15,代码来源:PurpleNetworkUser.cs

示例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);
            }
        }
开发者ID:RRJuuhachi,项目名称:Tree-of-Life,代码行数:15,代码来源:UniblocksClient.cs


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