예제 #1
0
        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());
        }
예제 #2
0
파일: Room.cs 프로젝트: DMIRICA/Othello
        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());
        }
예제 #3
0
파일: Room.cs 프로젝트: DMIRICA/Othello
        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());
        }
예제 #4
0
        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.";
        }
예제 #5
0
        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());
        }
예제 #6
0
 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 = "";
     }
 }
예제 #7
0
 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());
     }
 }
예제 #8
0
 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();
     }
 }
예제 #9
0
파일: Room.cs 프로젝트: DMIRICA/Othello
        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());
            }
        }
예제 #10
0
파일: Room.cs 프로젝트: DMIRICA/Othello
        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());
            }
        }
예제 #11
0
        public void backToLobby()
        {
            MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.BackToLobby(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username);

            Singleton.Instance.Connection.SendPacket(packet.getData());
        }