public void SurrenderCommand() { SurrenderPanel.SetActive(false); MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.Surrender(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); }
private void SendColorAndHisTurn(User x) { string s = x.Player.IsHisTurn.ToString() + '|' + x.Player.DiskColor; MessageRoomPacket Message = new MessageRoomPacket(GameProtocol.StartGamePacketID(), ID, s); Othello.Server.SendPacket(x.Socket, Message.getData()); }
private void SendPlayerTurn(User x) { string s = x.Player.IsHisTurn.ToString(); MessageRoomPacket Message = new MessageRoomPacket(GameProtocol.PlayerTurnPacket(), ID, s); Othello.Server.SendPacket(x.Socket, Message.getData()); }
public void PlayAgain() { MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.PlayAgain(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); PlayAgainButton.enabled = false; PlayAgainButton.GetComponent <Image>().color = Color.red; GameOverPopUpText.text = "Waiting a response from your opponent."; }
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()); }
public void SendChatMessage() { if (InputField.text != "") { string s = Singleton.Instance.Me.Username + ": " + SingletonGame.Instance.MessageTyped + '\n'; ChatBox.text += s; s = Singleton.Instance.Me.Username + ": " + SingletonGame.Instance.MessageTyped + '\n'; MessageRoomPacket MessageToSend = new MessageRoomPacket(GameProtocol.RoomChatMessagePacketID(), Singleton.Instance.RoomID, s); Singleton.Instance.Connection.SendPacket(MessageToSend.getData()); InputField.text = ""; } }
public void Click() { if (AbleToClick()) { CellColor = SingletonGame.Instance.DiskColor; PlayFlipAnimation(); GameBoard.RemoveDrawMoves(); SingletonGame.Instance.LegalMoves.Clear(); string ClickMessage = Convert.ToString(this.row - 1) + ':' + Convert.ToString(this.column - 1) + '|' + SingletonGame.Instance.DiskColor.ToString(); MessageRoomPacket TurnPacket = new MessageRoomPacket(GameProtocol.TurnMovePacket(), Singleton.Instance.RoomID, ClickMessage); Singleton.Instance.Connection.SendPacket(TurnPacket.getData()); } }
void OnApplicationQuit() { if (GameOverPanel.activeSelf) { MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.QuitAfterGameOver(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); Singleton.Instance.Connection.CloseSocket(); } else { MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.QuitWhileInGame(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); Singleton.Instance.Connection.CloseSocket(); } }
public void SendAllowedMoves() { if (FirstUser.Player.IsHisTurn) { List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(FirstUser.Player.DiskColor); string tempString = ""; int count = 1; foreach (BoardPosition aux in tempList) { if (count == tempList.Count) { tempString += aux.Row.ToString() + ':' + aux.Column; continue; } tempString += aux.Row.ToString() + ':' + aux.Column + '|'; count++; } MessageRoomPacket Packet = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString); Othello.Server.SendPacket(FirstUser.Socket, Packet.getData()); } else if (SecondUser.Player.IsHisTurn) { List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(SecondUser.Player.DiskColor); string tempString = ""; int count = 1; foreach (BoardPosition aux in tempList) { if (count == tempList.Count) { tempString += aux.Row.ToString() + ':' + aux.Column; continue; } tempString += aux.Row.ToString() + ':' + aux.Column + '|'; count++; } MessageRoomPacket Packet = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString); Othello.Server.SendPacket(SecondUser.Socket, Packet.getData()); } }
private void SendLegalMoves(User x) { if (x.Player.IsHisTurn) { List <BoardPosition> tempList = Gameboard.GetAllLegalMoves(x.Player.DiskColor); string tempString = ""; int count = 1; foreach (BoardPosition aux in tempList) { if (count == tempList.Count) { tempString += aux.Row.ToString() + ':' + aux.Column + '!' + Gameboard.GetNumberOfChanges(aux.Row, aux.Column, x.Player.DiskColor); continue; } tempString += aux.Row.ToString() + ':' + aux.Column + '!' + Gameboard.GetNumberOfChanges(aux.Row, aux.Column, x.Player.DiskColor) + '|'; count++; } MessageRoomPacket movesPacket = new MessageRoomPacket(GameProtocol.BoardMoves(), ID, tempString); //DelayPacket(100); Othello.Server.SendPacket(x.Socket, movesPacket.getData()); } }
public void backToLobby() { MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.BackToLobby(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username); Singleton.Instance.Connection.SendPacket(packet.getData()); }