Ejemplo n.º 1
0
 public void backToLobby()
 {
     if (CurrentRoom.FirstUser != null && CurrentRoom.FirstUser.Username == Message)
     {
         User   currentUser   = Singleton.Singleton.Instance.GetUserLoogedByUsername(Message);
         String PacketMessage = "";
         foreach (User u in Singleton.Singleton.Instance.ListOfUsersLogged)
         {
             if (u.Username == Message)
             {
                 continue;
             }
             if (CurrentRoom.SecondUser != null && u.Username == CurrentRoom.SecondUser.Username)
             {
                 MessagePacket mp = new MessagePacket(GameProtocol.BackToLobby(), Message);
                 Othello.Server.SendPacket(u.Socket, mp.getData());
             }
             PacketMessage += u.Username + ":" + u.IsChallenged + ":" + u.InGame + "|";
             MessagePacket messagePacket = new MessagePacket(GameProtocol.ChangeUserToOnline(), Message);
             Othello.Server.SendPacket(u.Socket, messagePacket.getData());
         }
         MessagePacket packet = new MessagePacket(GameProtocol.LoadMainSceneFromGame(), PacketMessage);
         Othello.Server.SendPacket(currentUser.Socket, packet.getData());
         currentUser.InGame    = false;
         CurrentRoom.FirstUser = null;
         if (CurrentRoom.SecondUser == null)
         {
             Singleton.Singleton.Instance.ListOfRooms.Remove(CurrentRoom);
         }
     }
     else
     {
         User   currentUser   = Singleton.Singleton.Instance.GetUserLoogedByUsername(Message);
         String PacketMessage = "";
         foreach (User u in Singleton.Singleton.Instance.ListOfUsersLogged)
         {
             if (u.Username == Message)
             {
                 continue;
             }
             if (CurrentRoom.FirstUser != null && u.Username == CurrentRoom.FirstUser.Username)
             {
                 MessagePacket mp = new MessagePacket(GameProtocol.BackToLobby(), Message);
                 Othello.Server.SendPacket(u.Socket, mp.getData());
             }
             PacketMessage += u.Username + ":" + u.IsChallenged + ":" + u.InGame + "|";
             MessagePacket messagePacket = new MessagePacket(GameProtocol.ChangeUserToOnline(), Message);
             Othello.Server.SendPacket(u.Socket, messagePacket.getData());
         }
         MessagePacket packet = new MessagePacket(GameProtocol.LoadMainSceneFromGame(), PacketMessage);
         Othello.Server.SendPacket(currentUser.Socket, packet.getData());
         currentUser.InGame     = false;
         CurrentRoom.SecondUser = null;
         if (CurrentRoom.FirstUser == null)
         {
             Singleton.Singleton.Instance.ListOfRooms.Remove(CurrentRoom);
         }
     }
 }
Ejemplo n.º 2
0
        public void backToLobby()
        {
            MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.BackToLobby(), Singleton.Instance.RoomID, Singleton.Instance.Me.Username);

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