SendNewGameStarted
How do I use Send New Game Started
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
122 | public void SendNewGameStarted() | 1 |
58 | NetworkService.SendNewGameStarted(); | 2 |
File name: NetworkAdapter.cs
Copy
122 public void SendNewGameStarted()
123 {
124 if (PhotonNetwork.room != null && PhotonNetwork.room.playerCount == 2)
125 {
126 photonView.RPC("OnNewGameStart", PhotonTargets.OthersBuffered);
127 }
128 }
File name: Game.cs
Copy
40 public void NewGame()
41 {
42 board.gameObject.SetActive(true);
43 board.Clear();
44 board.SetPlayer(Seed.Cross);
45 CurrentState = GameState.Playing;
46
47 if (NetworkService.IsConnected)
48 {
49 if (NetworkService.IsMaster)
50 {
51 Player1.Name = NetworkService.PlayerName;
52 Player2.Name = NetworkService.OpponentName;
53
54 Player1.Type = Seed.Cross;
55 Player2.Type = Seed.Nought;
56 board.SetPlayer(Seed.Cross);
57
58 NetworkService.SendNewGameStarted();
59 }
60 else
61 {
62 Player1.Name = NetworkService.OpponentName;
63 Player2.Name = NetworkService.PlayerName;
64
65 Player1.Type = Seed.Nought;
66 Player2.Type = Seed.Cross;
67 board.SetPlayer(Seed.Empty);
68 }
69 }
70
71 OnGameStartSignal.Dispatch(this);
72 }
SendNewGameStarted 112 lượt xem
Gõ tìm kiếm nhanh...