AskForPickupItemSpawnTimes
How do I use Ask For Pickup Item Spawn Times
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
32 | this.Invoke("AskForPickupItemSpawnTimes", 2.0f); | 1 |
37 | public void AskForPickupItemSpawnTimes() | 2 |
File name: PickupItemSyncer.cs
Copy
24 public void OnJoinedRoom()
25 {
26 Debug.Log("Joined Room. isMasterClient: " + PhotonNetwork.isMasterClient + " id: " + PhotonNetwork.player.ID);
27 // this client joined the room. let's see if there are players and if someone has to inform us about pickups
28 this.IsWaitingForPickupInit = !PhotonNetwork.isMasterClient;
29
30 if (PhotonNetwork.playerList.Length >= 2)
31 {
32 this.Invoke("AskForPickupItemSpawnTimes", 2.0f);
33 }
34 }
File name: PickupItemSyncer.cs
Copy
37 public void AskForPickupItemSpawnTimes()
38 {
39 if (this.IsWaitingForPickupInit)
40 {
41 if (PhotonNetwork.playerList.Length < 2)
42 {
43 Debug.Log("Cant ask anyone else for PickupItem spawn times.");
44 this.IsWaitingForPickupInit = false;
45 return;
46 }
47
48
49 // find a another player (than the master, who likely is gone) to ask for the PickupItem spawn times
50 PhotonPlayer nextPlayer = PhotonNetwork.masterClient.GetNext();
51 if (nextPlayer == null || nextPlayer.Equals(PhotonNetwork.player))
52 {
53 nextPlayer = PhotonNetwork.player.GetNext();
54 //Debug.Log("This player is the Master's next. Asking this client's 'next' player: " + ((nextPlayer != null) ? nextPlayer.ToStringFull() : ""));
55 }
56
57 if (nextPlayer != null && !nextPlayer.Equals(PhotonNetwork.player))
58 {
59 this.photonView.RPC("RequestForPickupTimes", nextPlayer);
60
61 // you could restart this invoke and try to find another player after 4 seconds. but after a while it doesnt make a difference anymore
62 //this.Invoke("AskForPickupItemSpawnTimes", 2.0f);
63 }
64 else
65 {
66 Debug.Log("No player left to ask");
67 this.IsWaitingForPickupInit = false;
68 }
69 }
70 }
AskForPickupItemSpawnTimes 114 lượt xem
Gõ tìm kiếm nhanh...