OpponentName
How do I use Opponent Name
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
18 | string OpponentName { get; } | 1 |
52 | Player2.Name = NetworkService.OpponentName; | 2 |
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 }
OpponentName 139 lượt xem
Gõ tìm kiếm nhanh...