public void playerReady() { if (CurrentRoom != null) { if (CurrentRoom.FirstUser != null && CurrentRoom.FirstUser.Username == Message) { CurrentRoom.FirstUser.Player.ReadyToStart = true; if (!CurrentRoom.SecondUser.Player.ReadyToStart) { BasicPacket p = new BasicPacket(GameProtocol.PlayerReady()); Othello.Server.SendPacket(CurrentRoom.SecondUser.Socket, p.getData()); } } else if (CurrentRoom.SecondUser != null && CurrentRoom.SecondUser.Username == Message) { CurrentRoom.SecondUser.Player.ReadyToStart = true; if (!CurrentRoom.FirstUser.Player.ReadyToStart) { BasicPacket p = new BasicPacket(GameProtocol.PlayerReady()); Othello.Server.SendPacket(CurrentRoom.FirstUser.Socket, p.getData()); } } if (CurrentRoom.areBothPlayersReady()) { CurrentRoom.startGame(); CurrentRoom.FirstUser.Player.ReadyToStart = false; CurrentRoom.SecondUser.Player.ReadyToStart = false; } } }
public void ReadyButtonAction() { ReadyButton.GetComponent <Image>().color = Color.red; ReadyButton.enabled = false; MyReadyText.text = "You are ready! Waiting your opponent!"; MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.PlayerReady(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); }