本文整理汇总了C#中NetworkPlayer类的典型用法代码示例。如果您正苦于以下问题:C# NetworkPlayer类的具体用法?C# NetworkPlayer怎么用?C# NetworkPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkPlayer类属于命名空间,在下文中一共展示了NetworkPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例5: deletePlayer
public void deletePlayer(NetworkPlayer player)
{
GameObject go = (GameObject) players[player];
Network.RemoveRPCs(go.networkView.viewID);
Network.Destroy(go);
players.Remove(player);
}
示例6: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
collided = true;
if (other.isTrigger == false){
colliderNetworkPlayer = ((CurrentPlayer)other.GetComponent(typeof(CurrentPlayer))).owner;
}
}
示例7: OnPlayerConnected
void OnPlayerConnected(NetworkPlayer player)
{
if (Network.isServer)
{
}
}
示例8: CreatePlayerShip
public static void CreatePlayerShip(NetworkPlayer target, Player player, int objectID)
{
if (StopSend())
return;
Channel.networkView.RPC("CreatePlayerShipRPC", target, player.ID, objectID);
}
示例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;
}
示例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);
}
}
示例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 );
}
示例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));
}
}
示例13: OnPlayerConnected
void OnPlayerConnected (NetworkPlayer player)
{
networkPlayers[playersConnected++] = player;
if (playersConnected >= players) {
InitGame();
}
}
示例14: ClientAddPlayerToList
void ClientAddPlayerToList(string playerName, NetworkPlayer view)
{
MPPlayer team = new MPPlayer();
team.teamName = playerName;
team.playerNetwork = view;
playersList.Add(team);
}
示例15: OnPlayerDisconnected
void OnPlayerDisconnected( NetworkPlayer player )
{
// Removing player if Network is disconnected
Debug.Log("Server destroying player");
Network.RemoveRPCs(player, 0);
Network.DestroyPlayerObjects(player);
}