• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NetworkPlayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NetworkPlayer的典型用法代码示例。如果您正苦于以下问题:C# NetworkPlayer类的具体用法?C# NetworkPlayer怎么用?C# NetworkPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkPlayer类属于命名空间,在下文中一共展示了NetworkPlayer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnPlayerDisconnected

	//Server function
	void OnPlayerDisconnected(NetworkPlayer player)
	{
		addGameChatMessage("Player disconnected from: " + player.ipAddress + ":" + player.port);
		
		//Remove player from the server list
		playerList.Remove(GetPlayerNode(player));
	}
开发者ID:mlakhal,项目名称:CollaborativeAugmentedRealityEnvironment,代码行数:8,代码来源:GUILogTransform_scripts_.cs


示例2: PlayerSwap

    void PlayerSwap(int newMode, NetworkPlayer player)
    {
        // find the player
        foreach (PlayerInfo p in nvs.players)
        {
            if (p.player==player) {
                p.currentMode = newMode;
                if (p.currentMode==0) {			// if they're now in a buggy
                    // set them in buggy
                    p.characterGameObject.transform.parent = p.cartGameObject.transform;
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,0);
                    p.characterGameObject.transform.rotation = p.cartGameObject.transform.rotation;
                    // unlock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.None;
                    // change animation
                    p.characterGameObject.transform.FindChild("lil_patrick").animation.Play("driveIdle",PlayMode.StopAll);

                } else if (p.currentMode==1) {	// if they're now at golf ball
                    // set them at golf ball
                    p.characterGameObject.transform.parent = p.ballGameObject.transform;
                    p.ballGameObject.transform.rotation = Quaternion.identity;		// reset rotation to make it nice
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,-2);
                    p.characterGameObject.transform.rotation = Quaternion.identity;
                    // lock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
                    // change animation
                    p.characterGameObject.transform.FindChild("lil_patrick").animation.Play("golfIdle",PlayMode.StopAll);
                }

                // reset keyboard buffer
                p.h = 0f;
                p.v = 0f;
            }
        }
    }
开发者ID:RestingCoder,项目名称:bad-golf-community-edition,代码行数:35,代码来源:controlServer.cs


示例3: DisconnectPlayer

    void DisconnectPlayer(NetworkPlayer player)
    {
        if(Network.isClient)
        {
            Debug.Log("Player Disconnected: " + player.ToString());
        }

        // now we have to do the reverse lookup from
        // the NetworkPlayer --> GameObject
        // this is easy with the Hashtable

        if(players.ContainsKey(player))
        {
            // we check to see if the gameobject exists
            // or not first just as a safety measure
            // trying to destory a gameObject that
            // doesn't exist causes a runtime error

            if((GameObject)players[player]) {
                Destroy((GameObject)players[player]);
            }

            // we also have to remove the Hashtable entry

            players.Remove(player);
        }
    }
开发者ID:Game-Group,项目名称:dog-fighter,代码行数:27,代码来源:networkController.cs


示例4: OnPlayerDisconnected

    void OnPlayerDisconnected(NetworkPlayer player)
    {
        //Debug.Log("Clean up after player " + player);

        foreach(CurrentPlayer script in playerScripts){
            if(player == script.owner){//We found the players object
                Network.RemoveRPCs(script.gameObject.networkView.viewID);//remove the bufferd SetPlayer call
                Network.Destroy(script.gameObject.networkView.viewID);//Destroying the GO will destroy everything
                playerList.Remove(script.owner);
                playerScripts.Remove(script);//Remove this player from the list

                break;
            }
        }

        //Remove the buffered RPC call for instantiate for this player.
        int playerNumber = int.Parse(player+"");
        Network.RemoveRPCs(player , 1);
        //Debug.Log(playerNumber);

        // The next destroys will not destroy anything since the players never
        // instantiated anything nor buffered RPCs
        //Network.RemoveRPCs(player);
        Network.DestroyPlayerObjects(player);
    }
开发者ID:xinlut1990,项目名称:LunarLander,代码行数:25,代码来源:Players.cs


示例5: deletePlayer

 public void deletePlayer(NetworkPlayer player)
 {
     GameObject go = (GameObject) players[player];
     Network.RemoveRPCs(go.networkView.viewID);
     Network.Destroy(go);
     players.Remove(player);
 }
开发者ID:Gerb11,项目名称:Unity,代码行数:7,代码来源:ServerPlayerManager.cs


示例6: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     collided = true;
     if (other.isTrigger ==  false){
         colliderNetworkPlayer = ((CurrentPlayer)other.GetComponent(typeof(CurrentPlayer))).owner;
     }
 }
开发者ID:xinlut1990,项目名称:LunarLander,代码行数:7,代码来源:Collidable.cs


示例7: OnPlayerConnected

    void OnPlayerConnected(NetworkPlayer player)
    {
        if (Network.isServer)
        {

        }
    }
开发者ID:hellwilliam,项目名称:DonkeyKongRemake,代码行数:7,代码来源:CharacterSelection.cs


示例8: CreatePlayerShip

    public static void CreatePlayerShip(NetworkPlayer target, Player player, int objectID)
    {
        if (StopSend())
            return;

        Channel.networkView.RPC("CreatePlayerShipRPC", target, player.ID, objectID);
    }
开发者ID:Game-Group,项目名称:dog-fighter,代码行数:7,代码来源:PlayerShipRPC.cs


示例9: GetMyTeamHP

 public float[] GetMyTeamHP(NetworkPlayer me, out int team)
 {
     //if(team == 0) {
     for(int i=0; i<m_teamOnePlayers.Count; i++) {
         //Debug.Log ("Running through team");
         if(m_teamOnePlayers[i] == me) {
             team = 0;
             float[] temp = m_teamOneHealth.ToArray();
             temp[0] = m_teamOneHealth[i];
             temp[i] = m_teamOneHealth[0];
             return temp;
         }
     }
     //}
     //if(team == 1) {
     for(int i=0; i<m_teamTwoPlayers.Count; i++) {
         if(m_teamTwoPlayers[i] == me) {
             team = 1;
             float[] temp = m_teamTwoHealth.ToArray();
             temp[0] = m_teamTwoHealth[i];
             temp[i] = m_teamTwoHealth[0];
             return temp;
         }
     }
     //}
     team = -1;
     return null;
 }
开发者ID:shawnmiller,项目名称:Capstone,代码行数:28,代码来源:PlayerValues.cs


示例10: OnPlayerConnected

	//Need to send level data to new players
	void OnPlayerConnected(NetworkPlayer player)
	{
		if(IsHost)
		{
			Debug.Log ("New player connected\n");

			//Find and get the current chunk
			GameObject Chunk = GameObject.Find ("Chunk(Clone)");
			byte[,,] map = Chunk.GetComponent<Chunk>().map;

			string ChunkData = "";
			for ( int x = 0; x < 16; x++ )
			{
				for ( int z = 0; z < 16; z++ )
				{
					ChunkData = ChunkData + map[x,0,z];
					ChunkData = ChunkData + map[x,1,z];
				}
			}

			//Send current chunk data to other players
			Debug.Log ("Sending chunk data across the network\n");
			//Sends to all clients that are connected to the server
			networkView.RPC("ChunkData", RPCMode.OthersBuffered, ChunkData);
		}
	}
开发者ID:Panamax,项目名称:UncleCraft,代码行数:27,代码来源:HostScript.cs


示例11: CreateNewPlayerOnServer

    private void CreateNewPlayerOnServer( NetworkPlayer id )
    {
        GameObject newPlayer = Network.Instantiate( playerPrefab, Vector3.zero, Quaternion.identity, 0 ) as GameObject;
        newPlayer.GetComponent<PlayerClientBehaviour>().SetPlayerID( id );

        gameControllerBahviour.Manager.AddNewPlayer( newPlayer );
    }
开发者ID:Jacko161,项目名称:Unity-Project-v2,代码行数:7,代码来源:TestNetworkBehaviour.cs


示例12: setScope

 public static void setScope(Bounds pBounds, Transform pParent,NetworkPlayer pPlayer)
 {
     foreach (Transform lTransform in pParent)
     {
         lTransform.networkView.SetScope(pPlayer,pBounds.Contains(lTransform.position));
     }
 }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:7,代码来源:BoundNetworkScope.cs


示例13: OnPlayerConnected

	void OnPlayerConnected (NetworkPlayer player)
	{
		networkPlayers[playersConnected++] = player;
		if (playersConnected >= players) {
			InitGame();
		}
	}
开发者ID:Jrlats,项目名称:MiniMOBA,代码行数:7,代码来源:GameManager.cs


示例14: ClientAddPlayerToList

 void ClientAddPlayerToList(string playerName, NetworkPlayer view)
 {
     MPPlayer team = new MPPlayer();
     team.teamName = playerName;
     team.playerNetwork = view;
     playersList.Add(team);
 }
开发者ID:SLIPD,项目名称:PC,代码行数:7,代码来源:MultiplayerManager.cs


示例15: OnPlayerDisconnected

 void OnPlayerDisconnected( NetworkPlayer player  )
 {
     // Removing player if Network is disconnected
      Debug.Log("Server destroying player");
      Network.RemoveRPCs(player, 0);
      Network.DestroyPlayerObjects(player);
 }
开发者ID:chrisall76,项目名称:OGAM_January,代码行数:7,代码来源:Instantiate.cs


示例16: NetworkServerSpawn

    public GameObject NetworkServerSpawn(NetworkPlayer owner, Vector3 direction)
    {
        Vector3 position = transform.position + direction + new Vector3(0,0.5f,0);

        // instantiate a local copy of the object
        GameObject clone = (GameObject)GameObject.Instantiate(projectilePrefab, position, Quaternion.identity);

        clone.rigidbody.AddForce(direction * force, ForceMode.Impulse);

        if (clone.collider)
        {
            Collider parentCollider = transform.parent.parent.collider;
            Physics.IgnoreCollision(parentCollider, clone.collider);
        }

        clone.networkView.viewID = Network.AllocateViewID();

        // plant a component on the prefab to send us callbacks
        // we need to know when this object is destroyed
        NetworkOwnedPrefab handle = clone.AddComponent<NetworkOwnedPrefab>();
        handle.owner = this;

        living.Add(clone);

        networkView.RPC("NetworkClientSpawn", RPCMode.OthersBuffered, owner, clone.networkView.viewID, position);

        // call the builtin OnNetworkInstantiate
        clone.SendMessage("OnNetworkInstantiate", new NetworkMessageInfo());

        return clone;
    }
开发者ID:silantzis,项目名称:blockotron,代码行数:31,代码来源:NetworkProjectileTool.cs


示例17: RequestUpdatePlayer

 private void RequestUpdatePlayer(NetworkPlayer player)
 {
     C2Request request;
     request = new C2Request(C2MessageType.Request_UpdateAlive);
     request.putData("NetworkPlayer" , player);
     this.SendRequest(request);
 }
开发者ID:xinlut1990,项目名称:LunarLander,代码行数:7,代码来源:CrashLogic.cs


示例18: AddPlayerBack

    void AddPlayerBack(NetworkPlayer nPlayer)
    {
        //the players to be added are recorded in a list so that no player is missed
        nPlayerList.Add(nPlayer);

        addPlayerAgain = true;
    }
开发者ID:CharlesVI,项目名称:UnityFPS,代码行数:7,代码来源:PlayerDatabase.cs


示例19: OnPlayerDisconnected

 void OnPlayerDisconnected(NetworkPlayer player)
 {
     Debug.Log("Server destroying player");
     enabled = false;
     Network.RemoveRPCs(player, 0);
     Network.DestroyPlayerObjects(player);
 }
开发者ID:Spaiki,项目名称:spaceships,代码行数:7,代码来源:SpawnPrefab.cs


示例20: PlayerSwap

    void PlayerSwap(int newMode, NetworkPlayer player)
    {
        // find the player
        foreach (PlayerInfo p in nvs.players)
        {
            if (p.player==player) {
                p.currentMode = newMode;
                if (p.currentMode==0) {			// if they're now in a buggy
                    // set them in buggy
                    p.characterGameObject.transform.parent = p.cartGameObject.transform;
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,0);
                    p.characterGameObject.transform.rotation = p.cartGameObject.transform.rotation;
                    // unlock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.None;

                } else if (p.currentMode==1) {	// if they're now at golf ball
                    // set them at golf ball
                    p.characterGameObject.transform.parent = p.ballGameObject.transform;
                    p.ballGameObject.transform.rotation = Quaternion.identity;		// reset rotation to make it nice
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,-2);
                    p.characterGameObject.transform.rotation = Quaternion.identity;
                    // lock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
                }

                // reset keyboard buffer
                p.KBState = 0;
            }
        }
    }
开发者ID:ChubBBoy,项目名称:bad-golf-community-edition,代码行数:30,代码来源:controlClient.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetworkReachability类代码示例发布时间:2022-05-24
下一篇:
C# NetworkMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap