SetPlayer









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

Featured Snippets


File name: PhotonNetwork.cs Copy
1894     public static void SetPlayerCustomProperties(Hashtable customProperties)
1895     {
1896         if (customProperties == null)
1897         {
1898             customProperties = new Hashtable();
1899             foreach (object k in player.customProperties.Keys)
1900             {
1901                 customProperties[(string)k] = null;
1902             }
1903         }
1904
1905         if (room != null && room.isLocalClientInside)
1906         {
1907             player.SetCustomProperties(customProperties);
1908         }
1909         else
1910         {
1911             player.InternalCacheProperties(customProperties);
1912         }
1913     }
File name: Board.cs Copy
22         public void Init(Action onBoardChangeAction)
23         {
24             CreateCells();
25             SetPlayer(Seed.Empty);
26             onBoardChange = onBoardChangeAction;
27         }
File name: Board.cs Copy
29         public void SetPlayer(Seed seed)
30         {
31             currentPlayer = seed;
32         }
File name: Board.cs Copy
34         public void SetCell(Seed seed, int row, int col)
35         {
36             SetPlayer(seed);
37             OnCellClick(cells[row, col]);
38         }
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         }
File name: Game.cs Copy
97         protected override void Start()
98         {
99             base.Start();
100
101             Reset();
102
103             CurrentState = GameState.MainMenu;
104
105             board.Init(OnBoardChange);
106             board.SetPlayer(Seed.Empty);
107             board.gameObject.SetActive(false);
108
109             NetworkService.OnAllPlayersConnectedSignal.AddListener(OnAllPlayersConnected);
110             NetworkService.OnDisconnectedFromMasterSignal.AddListener(OnDisconnectedFromMaster);
111             NetworkService.OnRemoteBoardChangeSignal.AddListener(OnRemoteBoardChange);
112         }
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         }

SetPlayer 165 lượt xem

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