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); } } }
public void InitRoom(string _name, RoomBed bed) { if (roomBeds.Count == 0) { mName = _name; bed.room = this; roomBeds.Add(bed); } }
// 105 public void SendRoomMes(OperationRequest operation) { RoomBed bed = GetComponent <RoomBed>(); if (bed != null) { bed.SendRoomResponse(operation); } }
public bool IsMaster(RoomBed bed) { if (roomBeds.Count < 1) { return(false); } return(roomBeds[0] == bed); }
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); } } }
// 103 public void ExitRoom() { RoomBed bed = GetComponent <RoomBed>(); if (bed.room != null) { bed.room.ExitRoom(bed); } RemoveComponent <RoomBed>(); }
// 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); }
// 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); }
// 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); } }
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); }