SendBoardChange
How do I use Send Board Change
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
130 | public void SendBoardChange(Seed seed, int row, int col) | 1 |
204 | NetworkService.SendBoardChange(player, row, col); | 2 |
File name: NetworkAdapter.cs
Copy
130 public void SendBoardChange(Seed seed, int row, int col)
131 {
132 if (PhotonNetwork.room != null && PhotonNetwork.room.playerCount == 2)
133 {
134 photonView.RPC("OnRemoteBoardChange", PhotonTargets.OthersBuffered, (int)seed, row, col);
135 }
136 }
File name: Game.cs
Copy
169 private void OnBoardChange(Seed player, int row, int col)
170 {
171 Seed nextPlayer = Seed.Empty;
172
173 if (board.HasWon(player))
174 {
175 switch (player)
176 {
177 case Seed.Cross:
178 CurrentState = GameState.CrossWin;
179 Player1.Score++;
180 break;
181 case Seed.Nought:
182 CurrentState = GameState.NoughtWin;
183 Player2.Score++;
184 break;
185 }
186
187 OnGameResultSignal.Dispatch(this);
188 }
189 else if (board.IsDraw())
190 {
191 CurrentState = GameState.Draw;
192 OnGameResultSignal.Dispatch(this);
193 }
194 else
195 {
196 nextPlayer = player == Seed.Cross ? Seed.Nought : Seed.Cross;
197 }
198
199 board.SetPlayer(nextPlayer);
200
201 if (NetworkService.IsConnected && player == Player1.Type)
202 {
203 board.SetPlayer(Seed.Empty);
204 NetworkService.SendBoardChange(player, row, col);
205 }
206 }
SendBoardChange 125 lượt xem
Gõ tìm kiếm nhanh...