示例#1
0
文件: Room.cs 项目: jabbo/Jabbo
 internal void loadBots(int amount)
 {
     string sendText = "";
     int users = countUsers();
     for (int i = 0; i < amount; i++)
     {
         if (users++ < max_users)
         {
             int botID = ++botAmount;
             RoomBot roomBot = new RoomBot(this, botID, 0);
             this._Bots.Add(botID, roomBot);
             if (!roomBot.startDoor)
             {
                 _sqUnit[roomBot._MyX, roomBot._MyY] = true;
             }
             AddAvatarPacket avatars = new AddAvatarPacket();
             avatars.I = roomBot._MyAvatarID;
             avatars.U = roomBot._MyName;
             avatars.M = roomBot._MyMission;
             avatars.C = roomBot._MyFigure;
             avatars.B = "7";
             avatars.D = "";
             avatars.Brb = 0;
             avatars.S = roomBot._Sit;
             avatars.X = roomBot._MyX;
             avatars.Y = roomBot._MyY;
             avatars.H = roomBot._MyZ;
             avatars.F = false;
             avatars.R = false;
             string stringavatars = JsonConvert.SerializeObject(avatars);
             sendText += "056" + stringavatars + "#";
         }
     }
     foreach (ConnectedUser usr in _Users.Values)
     {
         usr.sendData(sendText);
     }
 }
示例#2
0
文件: Room.cs 项目: jabbo/Jabbo
        public void addUser(ConnectedUser User)
        {
            removeUser(User); // just a check

            int users = countUsers();
            if (users < max_users)
            {
                User._Room_X = door_x;
                User._Room_Y = door_y;
                User._Room_Z = 0;
                User._Room_Dir = door_dir * 2;
                User._Room_X_Target = door_x;
                User._Room_Y_Target = door_y;
                User._Drink = "";
                User._Brb = 0;
                User._Room_Sit = "";

                if (RoomOwner == User._UserID || RankManager.containsRight(User._Rank, "always_rights"))
                {
                    User._HasRights = true;
                }
                else
                {
                    if (MySQL.runRead("SELECT userid FROM room_rights WHERE roomid = '" + RoomID + "' AND userid = '" + User._UserID + "'", null) == 0)
                    {
                        User._HasRights = false;
                    }
                    else
                    {
                        User._HasRights = true;
                    }
                }

                loadRoomPacket(User);

                foreach (ConnectedUser usr in _Users.Values)
                {
                    AddAvatarPacket avatars = new AddAvatarPacket();

                    avatars.I = User._UserID;
                    avatars.U = User._Username;
                    avatars.M = User._Mission;
                    avatars.C = User._Figure;
                    avatars.B = User._Badge;
                    avatars.D = User._Drink;
                    avatars.Brb = User._Brb;
                    avatars.S = User._Room_Sit;
                    avatars.X = User._Room_X;
                    avatars.Y = User._Room_Y;
                    avatars.H = User._Room_Dir;
                    avatars.F = User._HasRights;

                    string stringavatars = JsonConvert.SerializeObject(avatars);

                    usr.sendData("056" + stringavatars + "#");
                }

                _Users.Add(User._UserID, User);

                sendRoomData(User);
            }
            else
            {
                // room is full
                sendData("061#");
            }
        }
示例#3
0
文件: Room.cs 项目: jabbo/Jabbo
        public void sendRoomData2(ConnectedUser User)
        {
            string sendText = "";
            foreach (ConnectedUser usr in _Users.Values)
            {
                AddAvatarPacket avatars = new AddAvatarPacket();

                avatars.I = usr._UserID;
                avatars.U = usr._Username;
                avatars.M = usr._Mission;
                avatars.C = usr._Figure;
                avatars.B = usr._Badge;
                avatars.D = usr._Drink;
                avatars.Brb = usr._Brb;
                avatars.S = usr._Room_Sit;
                avatars.X = usr._Room_X;
                avatars.Y = usr._Room_Y;
                avatars.H = usr._Room_Dir;
                avatars.F = false;
                avatars.R = usr._HasRights;

                string stringavatars = JsonConvert.SerializeObject(avatars);

                sendText += "056" + stringavatars + "#";
            }

            foreach (RoomBot bot in _Bots.Values)
            {
                // TODO: make it have a better id and different id
                AddAvatarPacket avatars = new AddAvatarPacket();

                avatars.I = bot._MyAvatarID;
                avatars.U = bot._MyName;
                avatars.M = bot._MyMission;
                avatars.C = bot._MyFigure;
                avatars.B = "7"; // bot badge
                avatars.D = "";
                avatars.Brb = 0;
                avatars.S = bot._Sit;
                avatars.X = bot._MyX;
                avatars.Y = bot._MyY;
                avatars.H = bot._MyZ;
                avatars.F = false;
                avatars.R = false;

                string stringavatars = JsonConvert.SerializeObject(avatars);

                sendText += "056" + stringavatars + "#";
            }
            sendText += "044" + "#";
            User.sendData(sendText);
        }