GameLogic
How do I use Game Logic
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
10 | if (PhotonNetwork.player.ID != GameLogic.playerWhoIsIt) | 1 |
37 | bool shoutMarco = GameLogic.playerWhoIsIt == PhotonNetwork.player.ID; | 2 |
File name: ClickDetector.cs
Copy
7 void Update()
8 {
9 // if this player is not "it", the player can't tag anyone, so don't do anything on collision
10 if (PhotonNetwork.player.ID != GameLogic.playerWhoIsIt)
11 {
12 return;
13 }
14
15 if (Input.GetButton("Fire1"))
16 {
17 GameObject goPointedAt = RaycastObject(Input.mousePosition);
18
19 if (goPointedAt != null && goPointedAt != this.gameObject && goPointedAt.name.Equals("monsterprefab(Clone)", StringComparison.OrdinalIgnoreCase))
20 {
21 PhotonView rootView = goPointedAt.transform.root.GetComponent
22 GameLogic.TagPlayer(rootView.owner.ID);
23 }
24 }
25 }
File name: RandomMatchmaker.cs
Copy
31 void OnGUI()
32 {
33 GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
34
35 if (PhotonNetwork.connectionStateDetailed == PeerState.Joined)
36 {
37 bool shoutMarco = GameLogic.playerWhoIsIt == PhotonNetwork.player.ID;
38
39 if (shoutMarco && GUILayout.Button("Marco!"))
40 {
41 myPhotonView.RPC("Marco", PhotonTargets.All);
42 }
43 if (!shoutMarco && GUILayout.Button("Polo!"))
44 {
45 myPhotonView.RPC("Polo", PhotonTargets.All);
46 }
47 }
48 }
Download file with original file name:GameLogic
GameLogic 102 lượt xem
Gõ tìm kiếm nhanh...