本文整理汇总了C#中PhotonPlayer.SetCustomProperties方法的典型用法代码示例。如果您正苦于以下问题:C# PhotonPlayer.SetCustomProperties方法的具体用法?C# PhotonPlayer.SetCustomProperties怎么用?C# PhotonPlayer.SetCustomProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhotonPlayer
的用法示例。
在下文中一共展示了PhotonPlayer.SetCustomProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetCustomProperties
// sets and syncs custom properties on a network player (including masterClient)
private void SetCustomProperties(PhotonPlayer player, int car, int position) {
ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() { { "spawn", position }, {"car", car} };
player.SetCustomProperties(customProperties);
}
示例2: GetShot
public void GetShot(float damage, PhotonPlayer enemy){
//Take Damage and check for death
health -= damage;
//Play a random Impact Sounds
audio2.clip = fleshImpactSounds [Random.Range (0, 6)];
audio2.Play ();
Debug.Log ("<color=green>Got Shot with </color>" + damage + " damage. Is alive: " + alive + " PhotonView is" + photonView.isMine);
//Once dead
if(health <=0 && alive){
alive = false;
Debug.Log ("<color=blue>Checking Health</color>" + health + " Photon State " + photonView.isMine + " Player Name " + PhotonNetwork.player.name);
if (photonView.isMine) {
//Only owner can remove themselves
Debug.Log ("<color=red>Death</color>");
if(SendNetworkMessage != null){
if(damage < 100f)
SendNetworkMessage(enemy.name + " owned " + PhotonNetwork.player.name + ".");
if(damage == 100f)
SendNetworkMessage(enemy.name + " headshot " + PhotonNetwork.player.name + "!");
}
//Subscribe to the event so that when a player dies 3 sec later respawn
if(RespawnMe != null)
RespawnMe(3f);
//Create deaths equal to stored hashtable deaths, increment, Set
int totalDeaths = (int)PhotonNetwork.player.customProperties["D"];
totalDeaths ++;
ExitGames.Client.Photon.Hashtable setPlayerDeaths = new ExitGames.Client.Photon.Hashtable() {{"D", totalDeaths}};
PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
//Increment Kill Count for the enemy player
if(!(enemy.name == "DroneAI")){
int totalKIlls = (int)enemy.customProperties["K"];
totalKIlls ++;
ExitGames.Client.Photon.Hashtable setPlayerKills = new ExitGames.Client.Photon.Hashtable() {{"K", totalKIlls}};
Debug.Log ("<color=red>KillCounter Called at </color>" + totalKIlls);
enemy.SetCustomProperties(setPlayerKills);
//If we reach the kill limit by checking rooms custom property and if this is enabled
if (totalKIlls == (int)(PhotonNetwork.room.customProperties["KL"]) && (int)(PhotonNetwork.room.customProperties["TKL"]) == 1)
{
//Display Win Screen
NM.DisplayWinPrompt(enemy.name);
}
//Write Kills and Deaths to File On Death
//System.IO.File.AppendAllText (@"C:\Users\Public\PlayerStats.txt", "\n" + "KDR on Death: " + ((int)(PhotonNetwork.player.customProperties["K"])).ToString() + ":" + totalDeaths.ToString());
//Write amount of ammo picked up so far until death.
//System.IO.File.AppendAllText(@"C:\Users\Public\PlayerStats.txt", "\n" + "Total Amount of ammmo picked up so far: " + pickedUpAmmo.ToString());
}
//Spawn ammo on death
PhotonNetwork.Instantiate("Ammo_AK47",transform.position - new Vector3 (0,0.9f,0), Quaternion.Euler(1.5f,149f,95f),0);
//Finally destroy the game Object.
PhotonNetwork.Destroy(gameObject);
}
}
//Play Hit Effect Animation for player getting hit. Without isMine would play for everyone.
if (photonView.isMine) {
injuryAnim.SetBool ("Hit", true);
StartCoroutine( WaitForAnimation (1.2f));
}
}