當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。