PlayerScoreProp
How do I use Player Score Prop
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PunPlayerScores.cs
Copy
15 public static void SetScore(this PhotonPlayer player, int newScore)
16 {
17 Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable
18 score[PunPlayerScores.PlayerScoreProp] = newScore;
19
20 player.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap.
21 }
File name: PunPlayerScores.cs
Copy
23 public static void AddScore(this PhotonPlayer player, int scoreToAddToCurrent)
24 {
25 int current = player.GetScore();
26 current = current + scoreToAddToCurrent;
27
28 Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable
29 score[PunPlayerScores.PlayerScoreProp] = current;
30
31 player.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap.
32 }
File name: PunPlayerScores.cs
Copy
34 public static int GetScore(this PhotonPlayer player)
35 {
36 object teamId;
37 if (player.customProperties.TryGetValue(PunPlayerScores.PlayerScoreProp, out teamId))
38 {
39 return (int)teamId;
40 }
41
42 return 0;
43 }
PlayerScoreProp 106 lượt xem
Gõ tìm kiếm nhanh...