public void Room_CreateRoom(string gameType, string roomName, UserLogicModel user, Action<RoomData> onRoomCreated)
        {
            ExtensionMethods.debugger();

            RoomData rd = new RoomData(gameType, roomName, roomName + "RoomName", roomName + "GameRoom", new List<UserLogicModel>() { user });
            manager.client.Collection("Room",
                                      (err, collection) =>
                                      {
                                          collection.Insert(rd);

                                          onRoomCreated(rd);
                                      });
        }
        public void Room_AddPlayer(RoomData room, UserLogicModel user, Action<RoomData> complete)
        {
            manager.client.Collection("Room",
                          (err, collection) =>
                          {

                              JsDictionary<string, object> query = new JsDictionary<string, object>();

                              query["$push"] = new { players = user };

                              collection.Update(new { _id = MongoDocument.GetID(room.ID) },
                                                query,
                                                (err2) =>
                                                {
                                                    if (err2 != null)
                                                        Logger.Log("Data Error: " + err2, LogLevel.Error);
                                                    room.Players.Add(user);

                                                    complete(room);
                                                });
                          });
        }
Example #3
0
        public ActiveLobbyUI(ShuffUIManager shuffUIManager, PageHandler pageHandler, RoomData room)
        {
            pageHandler.ClientSiteManager.OnGetRoomInfoReceived += GetRoomInfo;
            pageHandler.ClientChatManager.OnGetChatLines += GetChatLines;
            pageHandler.ClientChatManager.OnGetChatInfo += GetChatInfo;

            myShuffUIManager = shuffUIManager;
            myPageHandler = pageHandler;
            myRoom = room;

            UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() {
                                                                             Title = string.Format("{0} Lobby", myRoom.RoomName),
                                                                             X = 250,
                                                                             Y = 100,
                                                                             Width = 800,
                                                                             Height = 600,
                                                                             AllowClose = true,
                                                                             AllowMinimize = true,
                                                                             Visible = true
                                                                     });
            UIWindow.OnClose += () => {
                                    UIWindow.Visible = true;
                                    UIWindow.SwingAway(SwingDirection.BottomRight);
                                    pageHandler.ClientSiteManager.LeaveRoom(new LeaveRoomRequest(room));
                                    pageHandler.HomeUI.UIWindow.SwingBack();
                                };

            UIWindow.SwingAway(SwingDirection.BottomRight, true);

            myRoomPlayers = UIWindow.AddElement(new ShuffListBox(600, 200, 175, 300) {Visible = true});

            UIWindow.AddElement(new ShuffButton(600, 510, 175, 23, "Start Game!", (a) =>
            {
                pageHandler.GameManager.StartGame( );

                UIWindow.Height = 200;
            }));

            myChatBox = UIWindow.AddElement(new ChatBox(50, 50, 550, 500) {Visible = true});

            myChatText = UIWindow.AddElement(new ShuffTextbox(50, 560, 500, 30, "", "")
            {
                OnEnter = () =>
                {
                    if (myChatText.Text.Trim() == string.Empty)
                        return;

                    pageHandler.ClientChatManager.SendChatMessage(new SendChatMessageModel(myChatText.Text));
                    myChatText.Text = "";
                }
            });

            UIWindow.AddElement(new ShuffButton(560,
                                                560,
                                                50,
                                                30,
                                                "Send",
                                                (e) => {
                                                    if (myChatText.Text.Trim() == string.Empty)
                                                        return;

                                                    pageHandler.ClientChatManager.SendChatMessage(new SendChatMessageModel(myChatText.Text));
                                                    myChatText.Text = "";
                                                }));

            UIWindow.SwingBack();
            PopulateGameRoom(room);
        }
Example #4
0
 private void PopulateGameRoom(RoomData roomData)
 {
 }
 public RoomJoinResponse(RoomData room)
 {
     Room = room;
 }
 public CreateChatRoomRequest(RoomData room)
 {
     Room = room;
 }
 public GetRoomInfoResponse(RoomData room)
 {
     Room = room;
 }
 public void Room_DeleteRoom(RoomData room)
 {
     manager.client.Collection("Room", (err, collection) => { collection.Remove(new { _id = MongoDocument.GetID(room.ID) }); });
 }
        public void Room_SetChatServer(RoomData room, string chatServerIndex, Action<object> complete)
        {
            manager.client.Collection("Room",
                 (err, collection) =>
                 {

                     JsDictionary<string, object> query = new JsDictionary<string, object>();
                     query["$set"] = new {chatServer = chatServerIndex};
                     collection.Update(new { _id = MongoDocument.GetID(room.ID) },
                                       query,
                                       (err2) =>
                                       {
                                           if (err2 != null)
                                               Logger.Log("Data Error: " + err2, LogLevel.Error);
                                           room.ChatServer = chatServerIndex;

                                           complete(room);
                                       });
                 });
        }
        public void Room_RemovePlayer(RoomData room, UserLogicModel user, Action<RoomData> complete)
        {
            manager.client.Collection("Room",
                          (err, collection) =>
                          {

                              JsDictionary<string, object> query = new JsDictionary<string, object>();

                              query["$pop"] = new { players = user };

                              collection.Update(new { _id = MongoDocument.GetID(room.ID) },
                                                query,
                                                (err2) =>
                                                {
                                                    if (err2 != null)
                                                        Logger.Log("Data Error: " + err2,LogLevel.Error);
                                                    foreach (var userLogicModel in room.Players)
                                                    {
                                                        if (userLogicModel.UserName == user.UserName)
                                                        {
                                                            room.Players.Remove(userLogicModel);
                                                            break;
                                                        }
                                                    }

                                                    complete(room);
                                                });
                          });
        }
Example #11
0
 public LeaveRoomRequest(RoomData room)
 {
     Room = room;
 }
Example #12
0
        private void PopulateRoom(RoomData roomData)
        {
            myRoomPlayers.Visible = true;
            myRoomName.Visible = true;
            myRoomGameType.Visible = true;
            myJoinRoom.Visible = true;
            mySpectateRoom.Visible = true;
            myRefreshRoom.Visible = true;

            myRoomPlayers.ClearItems();
            foreach (var userModel in roomData.Players) {
                myRoomPlayers.AddItem(new ShuffListItem(userModel.UserName, userModel.UserName));
            }
            myRoomName.Text = string.Format("Room: {0}", roomData.RoomName);
            myRoomGameType.Text = string.Format("Game Type: {0}", roomData.GameType);
        }
 public JoinChatRoomRequest(RoomData room)
 {
     Room = room;
 }