IsDraw









How do I use Is Draw
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Board.cs Copy
53         public bool IsDraw()
54         {
55             for (int row = 0; row < ROWS; row++)
56             {
57                 for (int col = 0; col < COLS; col++)
58                 {
59                     if (cells[row, col].Content == Seed.Empty)
60                     {
61                         return false;
62                     }
63                 }
64             }
65
66             return true;
67         }
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         }

IsDraw 160 lượt xem

Gõ tìm kiếm nhanh...