private void PreLoadFTData() { var hotelId = UserContext.CurrentUser.HotelId; if (!_ft_isLoaded) { _ft_isLoaded = true; _ft_rooms = RoomBll.GetListBy(hotelId); _ft_roomregs = RoomRegBll.GetListByHotelId(hotelId); _ft_members = MemberBll.GetList(hotelId); _ft_membersType = MemberTypeBll.GetList(hotelId); _ft_RoomRegGuestInfoCN = RoomRegGuestInfoCNBll.GetListByHotelId(hotelId); _ft_RoomRegGuestInfoEN = RoomRegGuestInfoENBll.GetListByHotelId(hotelId); _ft_MaterialLease = MaterialLeaseBll.GetListByHotel(hotelId); _ft_RoomType = RoomTypeBll.GetListByHotelId(hotelId); _ft_RoomYdRecord = RoomYdRecordBll.GetListByHotel(hotelId); _ft_GlobalFeeSet = GlobalFeeSetBll.GetByHotelId(hotelId); _ft_MaintainRoom = MaintainRoomBll.GetListByHotelId(hotelId); _ft_RoomSelfuse = RoomSelfBll.GetListByHotelId(hotelId); _ft_RoomYD = RoomYdBll.GetListByHotel(hotelId); _ft_RoomSet = RoomSetBll.GetBy(hotelId); if (_ft_RoomSet == null) { _ft_RoomSet = RoomSetBll.GetBy(0); } } }
/// <summary> /// Loads a roomset, takes note of all enemies in room /// and gives them loot based on loot tables /// </summary> protected virtual void LoadRoomSet(RoomSet room_set) { if (room_set == null) { return; } if (loaded_room_set != null) { Destroy(loaded_room_set.gameObject); } loaded_room_set = room_set; enemies = new Dictionary <Enemy, Vector3>(); Vector3 offset = new Vector3(1, 1) + (new Vector3(Room.Section.width, Room.Section.height) / 2f); loaded_room_set.transform.SetParent(transform); loaded_room_set.transform.position = transform.position; foreach (Enemy e in loaded_room_set.GetEnemies()) { enemies.Add(e, e.transform.position); e.SetHome(this); e.AddDropOnDeath(LootTablesSingleton.instance.monster_loot.GetPilePickups(RNGSingleton.instance.loot_rng)); } }
void LoadRoomOptions() { EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); room_to_load = (Room)EditorGUILayout.ObjectField(room_to_load, typeof(Room), false); if (room_to_load == null) { EditorGUI.BeginDisabledGroup(true); } if (GUILayout.Button("Load Room", GUILayout.MaxWidth(160))) { room_editor.CopyRoom(room_to_load); room_name = room_to_load.name; room_edited_since_save = false; room_to_load = null; } if (room_to_load == null) { EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); room_set_to_load = (RoomSet)EditorGUILayout.ObjectField(room_set_to_load, typeof(RoomSet), false); if (room_set_to_load == null) { EditorGUI.BeginDisabledGroup(true); } if (GUILayout.Button("Load RoomSet", GUILayout.MaxWidth(160))) { room_editor.CopyRoomSet(room_set_to_load); room_set_name = room_set_to_load.name; room_set_to_load = null; ReloadRoomSet(); } if (room_set_to_load == null) { EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); }
// GET: RoomSet public ActionResult Index() { var hotelId = UserContext.CurrentUser.HotelId; var model = RoomSetBll.GetBy(hotelId); if (model == null) { model = new RoomSet() { HotelId = hotelId } } ; return(View(model)); }
public JsonResult Edit(RoomSet model) { var apiResult = new APIResult(); try { RoomSetBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public void CopyRoomSet(RoomSet to_copy) { ClearRoomSet(); Transform copy_from_transform = to_copy.transform.Find("Enemies"); Transform copy_to_transform = edited_room_set.transform.Find("Enemies"); CopyAllChildren(copy_from_transform, copy_to_transform); foreach (Enemy e in copy_to_transform.GetComponentsInChildren <Enemy>()) { AddEnemy(e); } copy_from_transform = to_copy.transform.Find("Props"); copy_to_transform = edited_room_set.transform.Find("Props"); CopyAllChildren(copy_from_transform, copy_to_transform); copy_from_transform = to_copy.transform.Find("Doors"); copy_to_transform = edited_room_set.transform.Find("Doors"); CopyAllChildren(copy_from_transform, copy_to_transform); }
private IEnumerator Start() { mDungeonGenerator = new RandomDungeonGenerator(); TextAsset roomSetData = Resources.Load <TextAsset>("RoomSets/" + CurrentDungeonFloorData().roomSet); mRoomset = new RoomSet(); mRoomset.LoadFromTextAsset(roomSetData); mDungeon = mDungeonGenerator.GenerateDungeon(mRoomset, DungeonGenerationData()); mKillableMap = GetComponent <KillableMap>(); mKillableMap.SetupWithDungeon(mDungeon); mCollisionMap = GetComponent <CollisionMap>(); mCollisionMap.SetupWithSize(mDungeon.width, mDungeon.height); GenerateEnvironmentFromDungeon(mDungeon); PlaceAvatar(); // Provide some time after the avatar is generated for any of its setup (ie: quirk setup) // to impact dungeon generation yield return(null); // Special handling for the 'difficulty boost' effect DifficultyBoost db = GameObject.FindObjectOfType <DifficultyBoost>(); if (db != null) { db.ApplyQuirks(); yield return(null); } yield return(null); if (!IsPresetRoom()) { PlaceDeadEndInterests(); } PlaceTraps(); PlaceEnemies(); if (!IsPresetRoom()) { PlaceHearts(); PlaceExit(); QuirkSpecificSpawns(); } if (Game.instance.currentDungeonFloor == 5) { Game.instance.soundManager.PlayRandomMusicInCategory("BossMusic"); } else if (Game.instance.quirkRegistry.IsQuirkActive <GothQuirk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("GothMusic"); } else if (Game.instance.quirkRegistry.IsQuirkActive <OldTimeyQuirk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("OldTimey"); } else if (Game.instance.quirkRegistry.IsQuirkActive <Cowfolk>()) { Game.instance.soundManager.PlayRandomMusicInCategory("Cowboy"); } else { Game.instance.soundManager.PlayRandomMusicInCategory("DungeonMusic"); } Game.instance.playerData.MarkDirty(); yield break; }
GameObject pickRoom(RoomSet CurrentSet, int nx, int ny, Direction dir) { List <int> valid = new List <int>(); List <PlaceRoomInfo> surroundingRooms = new List <PlaceRoomInfo>(); Room oldRoom; if (dir == Direction.North) { oldRoom = grid [nx, ny - 1]; } else if (dir == Direction.South) { oldRoom = grid [nx, ny + 1]; } else if (dir == Direction.East) { oldRoom = grid [nx - 1, ny]; } else if (dir == Direction.West) { oldRoom = grid [nx + 1, ny]; } else { oldRoom = grid [nx, ny + 1]; } for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { if (nx + x >= 0 && nx + x < mx && ny + y >= 0 && ny + y < my && !(y == x) && (y == 0 || x == 0)) { if (grid[nx + x, ny + y].chosen) { surroundingRooms.Add(new PlaceRoomInfo(grid[nx + x, ny + y], getDirection(x, y))); } } } } //Debug.Log ("Started room pick " + (CurrentSet.Special.ToArray().Length + CurrentSet.Basic.ToArray().Length)); List <GameObject> chosen; bool Special = false, V_Special = true; if (CurrentSet.Special.ToArray().Length > 0) { chosen = CurrentSet.Special; Special = true; } else { chosen = CurrentSet.Basic; } do { if (!V_Special) { chosen = CurrentSet.Basic; Special = false; } for (int i = 0; i < chosen.ToArray().Length; i++) { bool V_FLAG = true; RoomManager m = chosen [i].GetComponent <RoomManager> (); bool[] c = m.canWalk(); LeaveType[] b = m.getWalk(); int dnum = getOppDirNum(getDirNum((dir))); if (b [dnum] == LeaveType.Block) { V_FLAG = false; } if (nx <= 0) { if (c [getDirNum(Direction.West)]) { V_FLAG = false; } } else if (nx >= mx - 1) { if (c [getDirNum(Direction.East)]) { V_FLAG = false; } } if (ny <= 0) { if (c [getDirNum(Direction.South)]) { V_FLAG = false; } } else if (ny >= my - 1) { if (c [getDirNum(Direction.North)]) { V_FLAG = false; } } if (oldRoom.chosen) { if (oldRoom.manager.doorNumber() == 1 && m.doorNumber() == 1) { V_FLAG = false; } } foreach (PlaceRoomInfo cr in surroundingRooms) { //Debug.Log ("Room exit type " + cr.getRoomsExitType() + "/" + cr.dir + "/" + b[getDirNum(cr.dir)]); if ((cr.getRoomsExitType() == LeaveType.Block && b [getDirNum(cr.dir)] != LeaveType.Block) || (cr.getRoomsExitType() != LeaveType.Block && b [getDirNum(cr.dir)] == LeaveType.Block)) { V_FLAG = false; } } if (V_FLAG) { valid.Add(i); } } if (Special && (valid.ToArray().Length == 0)) { V_Special = false; } } while (!V_Special && Special); int size = valid.ToArray().Length; if (size > 0) { int ni = Random.Range(0, size); GameObject nr = chosen [valid [ni]]; if (Special) { CurrentSet.Special.Remove(nr); } return(nr); } return(basic); }
/// <summary> /// Find the connected components of all unvisited /// nodes and connnect them using shortest length paths /// </summary> static void ConnectAllRoads(ref Tile[,] tiles) { uint maxTileGroupID = 0; // HORIZONTAL pass grid[0, 0].groupID = 1; // Min possible group id is 1 for (int z = 0; z < rowSize; z++) { for (int x = 0; x < colSize; x++) { Tile current = grid[z, x]; if (current.type == TileType.ROAD) { uint gid = grid.FindNearestGroupID(current.index); if (gid == 0) { maxTileGroupID++; current.groupID = maxTileGroupID; } else { current.groupID = gid; } } } } int[,] equivalenceClass = new int[maxTileGroupID + 1, maxTileGroupID + 1]; // VERTICAL Pass for (int x = 0; x < colSize; x++) { for (int z = 0; z < rowSize; z++) { Tile current = grid[z, x]; if (current.type == TileType.ROAD) { // Find all neighbouring tile gids(of same tiletypes) and mark them // Find the min of all marked Index lIndex = new Index(z, x - 1); if (grid.IsValidIndex(lIndex)) { Tile left = grid[lIndex]; if (current.type == left.type) { if (current.groupID != left.groupID) { equivalenceClass[current.groupID, left.groupID] = 1; equivalenceClass[left.groupID, current.groupID] = 1; } } } } } } // Recursion using stack for finding unique ids and their equivalents bool[] isChecked = new bool[maxTileGroupID + 1]; Dictionary <uint, List <uint> > uniqueIDs = new Dictionary <uint, List <uint> >(); uint[] matchedIDs = new uint[maxTileGroupID + 1]; for (uint id1 = 1; id1 < maxTileGroupID + 1; id1++) { if (!isChecked[id1]) { uniqueIDs.Add(id1, new List <uint>()); isChecked[id1] = true; uint rootID = id1; Stack <uint> children = new Stack <uint>(); for (uint id2 = 1; id2 < maxTileGroupID + 1; id2++) { if (rootID != id2 && equivalenceClass[rootID, id2] == 1) { uniqueIDs[rootID].Add(id2); children.Push(id2); } } while (children.Count > 0) { uint id2 = children.Pop(); if (!isChecked[id2]) { isChecked[id2] = true; for (uint id3 = 1; id3 < maxTileGroupID + 1; id3++) { if (id2 != id3 && rootID != id3 && equivalenceClass[id2, id3] == 1) { uniqueIDs[rootID].Add(id3); children.Push(id3); } } } } } } foreach (uint id in uniqueIDs.Keys) { foreach (uint id2 in uniqueIDs[id]) { matchedIDs[id2] = id; } } for (int i = 0; i < matchedIDs.Length; i++) { if (matchedIDs[i] == 0) { matchedIDs[i] = (uint)i; } } // CHANGE the groupIDs of tiles to UNIQUE group ids only for (int x = 0; x < colSize; x++) { for (int z = 0; z < rowSize; z++) { Tile current = grid[z, x]; if (current.groupID != 0) { current.groupID = matchedIDs[current.groupID]; } } } // Drop some tiles to road to CONNECT ALL THE ROADS TOGETHER RoomSet roomset = new RoomSet(); foreach (Tile t in grid) { if (t.groupID != 0) { roomset.AddTile(t, t.groupID); } } // Create connections among the rooms until there is only one room left int countCache = roomset.rooms.Count; while (roomset.rooms.Count > 1) { countCache = roomset.rooms.Count; // Dictionary to store the pair of rooms to be connected Dictionary <uint, List <uint> > connectSequence = new Dictionary <uint, List <uint> >(); // For each room find out the nearest room and add to the above list foreach (uint gid in roomset.rooms.Keys) { Room room = roomset.rooms[gid]; Room bestRoom = null; float bestDist = float.MaxValue; Vector3 center1 = room.GetCenter(); foreach (uint nextId in roomset.rooms.Keys) { // Find out distances from each room and store the minimum if (gid != nextId) { Room otherRoom = roomset.rooms[nextId]; Vector3 center2 = otherRoom.GetCenter(); float dist = Vector3.Distance(center1, center2); if (dist < bestDist) { bestRoom = otherRoom; bestDist = dist; } } } bool room_exists = connectSequence.ContainsKey(room.tileGroupID); bool bestRoom_exists = connectSequence.ContainsKey(bestRoom.tileGroupID); // Next piece of code makes sure that there is no repeated connection // request e.g. (1,3) and (3,1) if (!room_exists) { if (!bestRoom_exists) { // Add index for room connectSequence.Add(room.tileGroupID, new List <uint>()); connectSequence[room.tileGroupID].Add(bestRoom.tileGroupID); } else { // check for existing connections o/w add if (!connectSequence[bestRoom.tileGroupID].Contains(room.tileGroupID)) { connectSequence[bestRoom.tileGroupID].Add(room.tileGroupID); } } } else { // Add to rooms index in the list if already not there connectSequence[room.tileGroupID].Add(bestRoom.tileGroupID); } } roomset.ApplyConnections(connectSequence, ref grid); if (countCache <= roomset.rooms.Count) { // FURTHER MERGE FAIL break; } } // Mark the road tiles for (int z = 0; z < rowSize; z++) { for (int x = 0; x < colSize; x++) { Tile node = grid[z, x]; if (node.type == TileType.ROAD) { tiles[z, x].type = TileType.ROAD; } } } //TODO: Set direction of the tiles //TODO: Remove unnecessary tiles #region ROADTYPE_CODE /*for (int z = 0; z < rowSize; z++) * { * for (int x = 0; x < colSize; x++) * { * Tile tile0 = grid[z, x]; * if(tile0.type != TileType.ROAD) * { * continue; * } * List<Index> roadNeighbours = new List<Index>(); * foreach(Index i in tile0.neighbourList) * { * if(grid[i].type == TileType.ROAD) * { * roadNeighbours.Add(i); * } * } * int len = roadNeighbours.Count; * Tile tile1, tile2; * switch (len) * { * case 4: * tile0.roadType = RoadType.CrissCross; * break; * case 3: * tile0.roadType = RoadType.CrissCross; * break; * case 2: * // 2 neighbours * tile1 = grid[roadNeighbours[0].row, roadNeighbours[0].col]; * tile2 = grid[roadNeighbours[1].row, roadNeighbours[1].col]; * if (tile1.x == tile2.x) * { * tile0.roadType = RoadType.Vertical; * } * else if (tile1.z == tile2.z) * { * tile0.roadType = RoadType.Horizontal; * } * else * { * int xDiff = tile1.x - tile2.x; * int zDiff = tile1.z - tile2.z; * int k = tile1.x - tile0.x; * if (xDiff == 1) * { * if (zDiff == 1) * tile0.roadType = (k == 0) ? RoadType.Turn_LU : RoadType.Turn_RD; * else * tile0.roadType = (k == 0) ? RoadType.Turn_LD : RoadType.Turn_RU; * } * else if (xDiff == -1) * { * if (zDiff == 1) * tile0.roadType = (k == 0) ? RoadType.Turn_RU : RoadType.Turn_LD; * else * tile0.roadType = (k == 0) ? RoadType.Turn_RD : RoadType.Turn_LU; * } * } * break; * case 1: * tile1 = grid[roadNeighbours[0].row, roadNeighbours[0].col]; * if (tile0.z == tile1.z) * { * tile0.roadType = RoadType.Horizontal; * } * else * { * tile0.roadType = RoadType.Vertical; * } * break; * } * * tiles[tile0.z, tile0.x].roadType = tile0.roadType; * } * }*/ #endregion }