Beispiel #1
0
 public void ExitRoom(RoomBed bed)
 {
     if (roomBeds.Count > 0)
     {
         bool havself = false;
         for (int i = 0; i < roomBeds.Count; i++)
         {
             if (roomBeds[i] == bed)
             {
                 havself = true;
                 break;
             }
         }
         if (havself)
         {
             if (roomBeds[0] == bed && roomBeds.Count > 1)
             {
                 roomBeds[1].master.AddComponent(bed.master.PopComponent <RoomContainer>());
             }
             else if (roomBeds.Count == 1)
             {
                 bed.master.RemoveComponent <RoomContainer>();
             }
             roomBeds.Remove(bed);
         }
     }
 }
Beispiel #2
0
 public void InitRoom(string _name, RoomBed bed)
 {
     if (roomBeds.Count == 0)
     {
         mName    = _name;
         bed.room = this;
         roomBeds.Add(bed);
     }
 }
Beispiel #3
0
        // 105
        public void SendRoomMes(OperationRequest operation)
        {
            RoomBed bed = GetComponent <RoomBed>();

            if (bed != null)
            {
                bed.SendRoomResponse(operation);
            }
        }
Beispiel #4
0
        public bool IsMaster(RoomBed bed)
        {
            if (roomBeds.Count < 1)
            {
                return(false);
            }

            return(roomBeds[0] == bed);
        }
Beispiel #5
0
 public void SendRoomResponse(RoomBed bed, OperationRequest operation)
 {
     for (int i = 0; i < roomBeds.Count; i++)
     {
         if (roomBeds[i] != null && roomBeds[i] != bed)
         {
             roomBeds[i].master.SendOperationResponse(operation);
         }
     }
 }
Beispiel #6
0
        // 103
        public void ExitRoom()
        {
            RoomBed bed = GetComponent <RoomBed>();

            if (bed.room != null)
            {
                bed.room.ExitRoom(bed);
            }
            RemoveComponent <RoomBed>();
        }
Beispiel #7
0
 // 102
 public bool JoinRoom(string roomN)
 {
     if (RoomSystem.RS.roomMarks.ContainsKey(roomN))
     {
         RoomContainer room = RoomSystem.RS.roomMarks[roomN];
         RoomBed       bed  = AddComponent <RoomBed>();
         bed.master = this;
         return(room.JoinRoom(bed));
     }
     return(false);
 }
Beispiel #8
0
        // 106
        public string RoomStatus(string roomN)
        {
            StringBuilder sb  = new StringBuilder();
            RoomBed       bed = GetComponent <RoomBed>();

            if (bed != null && bed.room != null)
            {
                return(bed.room.StatusInfo());
            }
            return(String.Empty);
        }
Beispiel #9
0
        // 101
        public bool CreateRoom(string roomN)
        {
            if (!RoomSystem.RS.roomMarks.ContainsKey(roomN))
            {
                RoomBed bed = AddComponent <RoomBed>();
                bed.master = this;

                RoomContainer room = AddComponent <RoomContainer>();
                room.InitRoom(roomN, bed);

                RoomSystem.RS.roomMarks.Add(roomN, room);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #10
0
 public bool JoinRoom(RoomBed bed)
 {
     if (roomBeds.Count > 0)
     {
         bool havself = false;
         for (int i = 0; i < roomBeds.Count; i++)
         {
             if (roomBeds[i] == bed)
             {
                 havself = true;
                 break;
             }
         }
         if (!havself)
         {
             bed.room = this;
             roomBeds.Add(bed);
             return(true);
         }
     }
     return(false);
 }