void CreateTile(int x, int y, Tile.Tile_Type type, GameObject column) { Tile new_tile = Instantiate(Resources.Load <Tile>("Prefabs/Flatland")); new_tile.SetCoordinates(x, y); new_tile.transform.position = new Vector3(x * 4, -0.5F, y * 4); new_tile.transform.parent = column.transform; new_tile.name = "Tile " + (x + 1).ToString() + "x" + (y + 1).ToString(); }
public Room(int srH, int srW, int srX, int srY, Room_Type rType, Tile.Tile_Type fType, bool doors, bool columns) { roomHeight = srH; roomWidth = srW; startXPos = srX; startYPos = srY; has_doors = doors; doors_always_locked = false; c_room_type = rType; if (c_room_type == Room_Type.GenericCircular) calculate_circular_matrix(roomWidth); c_floor_type = fType; rGen = new Random(); c_column_type = Column_Pattern.None; allow_random_spawns = true; if (columns) { //These are always present List<Column_Pattern> col_patterns = new List<Column_Pattern> { Column_Pattern.Four_Corners, Column_Pattern.Center_Pillar }; //If the room is big enough, we add a couple more. if (roomHeight >= 7) col_patterns.Add(Column_Pattern.Vertical_Rows); if (roomWidth >= 7) col_patterns.Add(Column_Pattern.Horizontal_Rows); //Then we pick a random one. c_column_type = col_patterns[rGen.Next(col_patterns.Count)]; } room_tiles = new List<string>(); hallway_anchors = new List<gridCoordinate>(); doodad_list = new List<KeyValuePair<Doodad.Doodad_Type, gridCoordinate>>(); monster_list = new List<KeyValuePair<string, gridCoordinate>>(); monster_family_list = new List<KeyValuePair<string, gridCoordinate>>(); bonus_gold = 0; hallway_anchors.Add(new gridCoordinate(roomWidth / 2, roomHeight / 2)); boss_spawn_coordinates = new List<gridCoordinate>(); }
public Room(int srH, int srW, int srX, int srY, Room_Type rType, Tile.Tile_Type fType, bool doors) { roomHeight = srH; roomWidth = srW; startXPos = srX; startYPos = srY; has_doors = doors; c_room_type = rType; if (c_room_type == Room_Type.GenericCircular) { calculate_circular_matrix(roomWidth); } c_floor_type = fType; rGen = new Random(); room_tiles = new List <string>(); doodad_list = new List <KeyValuePair <Doodad.Doodad_Type, gridCoordinate> >(); monster_list = new List <KeyValuePair <string, gridCoordinate> >(); gold_list = new List <KeyValuePair <Goldpile, gridCoordinate> >(); }
public Room(RoomDC base_room, SpawnTable sTable) { roomHeight = base_room.RoomHeight; roomWidth = base_room.RoomWidth; startXPos = 0; startYPos = 0; has_doors = false; rGen = new Random(); //Necropolis only. corpses_in_corner = false; corners_that_have_corpses = 0; //More general purpose stuff c_room_type = Room_Type.Generic; c_floor_type = Tile.Tile_Type.StoneFloor; room_tiles = base_room.Room_Matrix; doodad_list = new List <KeyValuePair <Doodad.Doodad_Type, gridCoordinate> >(); monster_list = new List <KeyValuePair <string, gridCoordinate> >(); gold_list = new List <KeyValuePair <Goldpile, gridCoordinate> >(); switch (base_room.RoomType) { case "Gorehound Kennels": c_room_type = Room.Room_Type.GHound_Kennel; break; case "Library": c_room_type = Room.Room_Type.Library; break; case "Darkroom": c_room_type = Room.Room_Type.DarkRoom; break; case "Corpse Storage": c_room_type = Room.Room_Type.CorpseStorage; break; case "Sewer": c_room_type = Room.Room_Type.SewerRoom; break; case "Rubble Room": c_room_type = Room.Room_Type.Destroyed; break; case "Knight Armory": c_room_type = Room.Room_Type.KnightArmory; break; case "Sewer Shaft": c_room_type = Room.Room_Type.SewerShaft; break; case "Jail": c_room_type = Room.Room_Type.Jail; break; case "Mine Shaft": c_room_type = Room.Room_Type.MineShaft; break; } //Now to add the appropriate list of monsters & doodads //Doodads first. for (int i = 0; i < base_room.Room_Doodads.Count; i++) { Doodad.Doodad_Type c_doodad_type = 0; //Altar by default - not a problem. switch (base_room.Room_Doodads[i]) { case "Altar": c_doodad_type = Doodad.Doodad_Type.Altar; break; case "ArmorSuit": c_doodad_type = Doodad.Doodad_Type.ArmorSuit; break; case "BloodSplatter": c_doodad_type = Doodad.Doodad_Type.Blood_Splatter; break; case "Cage": c_doodad_type = Doodad.Doodad_Type.Cage; break; case "CorpsePile": c_doodad_type = Doodad.Doodad_Type.CorpsePile; break; case "DestroyedArmorSuit": c_doodad_type = Doodad.Doodad_Type.Destroyed_ArmorSuit; break; case "Bookshelf": c_doodad_type = Doodad.Doodad_Type.Bookshelf; break; case "DestroyedBookshelf": c_doodad_type = Doodad.Doodad_Type.Destroyed_Bookshelf; break; } gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Doodad_Coordinates[i]); c_grid_coord.x += startXPos; c_grid_coord.y += startYPos; int doodad_chance = 0; Int32.TryParse(base_room.Room_Doodad_Chances[i], out doodad_chance); if (rGen.Next(100) < doodad_chance) { doodad_list.Add(new KeyValuePair <Doodad.Doodad_Type, gridCoordinate>(c_doodad_type, c_grid_coord)); } } //Then monsters. for (int i = 0; i < base_room.Room_Monsters.Count; i++) { if (sTable.monster_in_table(base_room.Room_Monsters[i])) { int monster_chance = 0; Int32.TryParse(base_room.Room_Monster_Chances[i], out monster_chance); gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Monster_Coordinates[i]); if (rGen.Next(100) < monster_chance) { monster_list.Add(new KeyValuePair <string, gridCoordinate>(base_room.Room_Monsters[i], c_grid_coord)); } } } }
public Room(RoomDC base_room, Spawn_Table_Manager sManager) { roomHeight = base_room.RoomHeight; roomWidth = base_room.RoomWidth; gridCoordinate room_coord = grid_c_from_matrix_c(base_room.Coordinate); startXPos = room_coord.x; startYPos = room_coord.y; has_doors = base_room.RoomDoors; doors_always_locked = base_room.DoorsLocked; rGen = new Random(); allow_random_spawns = base_room.AllowRandomSpawn; //Necropolis only. corpses_in_corner = false; corners_that_have_corpses = 0; //More general purpose stuff c_room_type = Room_Type.Generic; c_floor_type = Tile.Tile_Type.StoneFloor; c_column_type = Column_Pattern.None; room_tiles = base_room.Room_Matrix; hallway_anchors = new List<gridCoordinate>(); boss_spawn_coordinates = new List<gridCoordinate>(); doodad_list = new List<KeyValuePair<Doodad.Doodad_Type, gridCoordinate>>(); monster_list = new List<KeyValuePair<string, gridCoordinate>>(); monster_family_list = new List<KeyValuePair<string, gridCoordinate>>(); bonus_gold = base_room.RoomGold; allow_overlap = base_room.AllowOverlap; switch (base_room.RoomType) { case "Specific": c_room_type = Room_Type.Specific; break; case "Gorehound Kennels": c_room_type = Room.Room_Type.GHound_Kennel; break; case "Library": c_room_type = Room.Room_Type.Library; break; case "Darkroom": c_room_type = Room.Room_Type.DarkRoom; break; case "Corpse Storage": c_room_type = Room.Room_Type.CorpseStorage; break; case "Sewer": c_room_type = Room.Room_Type.SewerRoom; break; case "Rubble Room": c_room_type = Room.Room_Type.Destroyed; break; case "Knight Armory": c_room_type = Room.Room_Type.KnightArmory; break; case "Sewer Shaft": c_room_type = Room.Room_Type.SewerShaft; break; case "Jail": c_room_type = Room.Room_Type.Jail; break; case "Mine Shaft": c_room_type = Room.Room_Type.MineShaft; break; } //Add hallway anchors List<string> raw_anchors = base_room.Room_Hallway_Anchors; if (raw_anchors.Count == 0) hallway_anchors.Add(new gridCoordinate(roomWidth / 2, roomHeight / 2)); else for (int i = 0; i < raw_anchors.Count; i++) if(raw_anchors[i].Length > 0) //prevent from passing "" hallway_anchors.Add(grid_c_from_matrix_c(raw_anchors[i])); //Now to add the appropriate list of monsters & doodads //Doodads first. for (int i = 0; i < base_room.Room_Doodads.Count; i++) { Doodad.Doodad_Type c_doodad_type = 0; //Altar by default - not a problem. switch (base_room.Room_Doodads[i]) { case "Altar": c_doodad_type = Doodad.Doodad_Type.Altar; break; case "ArmorSuit": c_doodad_type = Doodad.Doodad_Type.ArmorSuit; break; case "BloodSplatter": c_doodad_type = Doodad.Doodad_Type.Blood_Splatter; break; case "Cage": c_doodad_type = Doodad.Doodad_Type.Cage; break; case "CorpsePile": c_doodad_type = Doodad.Doodad_Type.CorpsePile; break; case "DestroyedArmorSuit": c_doodad_type = Doodad.Doodad_Type.Destroyed_ArmorSuit; break; case "Bookshelf": c_doodad_type = Doodad.Doodad_Type.Bookshelf; break; case "DestroyedBookshelf": c_doodad_type = Doodad.Doodad_Type.Destroyed_Bookshelf; break; case "Ironbar_Door": c_doodad_type = Doodad.Doodad_Type.Iron_Door; break; case "Ironbar_Wall": c_doodad_type = Doodad.Doodad_Type.Ironbar_Wall; break; case "NadirBed": c_doodad_type = Doodad.Doodad_Type.NadirBed; break; case "NadirColumn": c_doodad_type = Doodad.Doodad_Type.NadirColumn; break; case "ArcheryTarget": c_doodad_type = Doodad.Doodad_Type.ArcheryTarget; break; case "Desk": c_doodad_type = Doodad.Doodad_Type.Desk; break; case "Hedgehog": c_doodad_type = Doodad.Doodad_Type.Hedgehog; break; case "NadirDoor": c_doodad_type = Doodad.Doodad_Type.NadirDoor; break; } gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Doodad_Coordinates[i]); int doodad_chance = 0; Int32.TryParse(base_room.Room_Doodad_Chances[i], out doodad_chance); if(rGen.Next(100) < doodad_chance) doodad_list.Add(new KeyValuePair<Doodad.Doodad_Type,gridCoordinate>(c_doodad_type, c_grid_coord)); } //Then monsters by family. for (int i = 0; i < base_room.Monster_Families.Count; i++) { int monster_family_chance = 0; Int32.TryParse(base_room.Monster_Family_Chances[i], out monster_family_chance); gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Monster_Family_Coordinates[i]); if (rGen.Next(100) < monster_family_chance) monster_family_list.Add(new KeyValuePair<string, gridCoordinate>(base_room.Monster_Families[i], c_grid_coord)); } //Then monsters by themselves. for (int i = 0; i < base_room.Room_Monsters.Count; i++) { int monster_chance = 0; Int32.TryParse(base_room.Room_Monster_Chances[i], out monster_chance); gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Monster_Coordinates[i]); if (rGen.Next(100) < monster_chance) monster_list.Add(new KeyValuePair<string, gridCoordinate>(base_room.Room_Monsters[i], c_grid_coord)); } boss_spawn_coordinates = new List<gridCoordinate>(); for (int i = 0; i < base_room.Boss_Spawn_Coordinates.Count; i++) boss_spawn_coordinates.Add(grid_c_from_matrix_c(base_room.Boss_Spawn_Coordinates[i])); }
private void render_all_features() { for (int i = 0; i < featurelayout.Count; i++) { switch (featurelayout[i].get_type()) { case NaturalFeature.Feature_Type.River: case NaturalFeature.Feature_Type.Chasm: Tile.Tile_Type[] feature_tiles = new Tile.Tile_Type[1]; if (featurelayout[i].get_type() == NaturalFeature.Feature_Type.River) { if (featurelayout[i].get_river_type() == NaturalFeature.River_Type.Normal) feature_tiles = new Tile.Tile_Type[] { Tile.Tile_Type.Deep_Water, Tile.Tile_Type.Shallow_Water, Tile.Tile_Type.Gravel }; else if (featurelayout[i].get_river_type() == NaturalFeature.River_Type.Sewage) feature_tiles = new Tile.Tile_Type[] { Tile.Tile_Type.Deep_Sewage, Tile.Tile_Type.Shallow_Sewage, Tile.Tile_Type.Natural_Stone_Floor }; } else if (featurelayout[i].get_type() == NaturalFeature.Feature_Type.Chasm) feature_tiles = new Tile.Tile_Type[] { Tile.Tile_Type.Abyss, Tile.Tile_Type.Natural_Stone_Floor }; featurelayout[i].draw_linear_feature(ref floorTiles, ref events, randGen, feature_tiles, universal_spritesheet, dungeon_specific_spritesheet, general_texture_map); break; case NaturalFeature.Feature_Type.Lake: featurelayout[i].draw_rectangular_feature(ref floorTiles, ref events, randGen, new Tile.Tile_Type[] { Tile.Tile_Type.Natural_Stone_Floor, Tile.Tile_Type.Gravel, Tile.Tile_Type.Shallow_Water, Tile.Tile_Type.Deep_Water }, universal_spritesheet, dungeon_specific_spritesheet, general_texture_map); break; } } }
public void draw_river(ref List <List <Tile> > grid, Random rGen, Tile.Tile_Type deep_water_tiltyp, Tile.Tile_Type shallows_tiltyp, Tile.Tile_Type shoreline_tiltyp, List <KeyValuePair <Tile.Tile_Type, Texture2D> > textureList) { //First determine whether it's a mostly horizontal or vertical river. //Get differences. int abs_xDif = Math.Abs(river_startCoord.x - river_endCoord.x); int abs_yDif = Math.Abs(river_startCoord.y - river_endCoord.y); int xDif = river_startCoord.x - river_endCoord.x; int yDif = river_startCoord.y - river_endCoord.y; //Get Vector points. Vector2 end_position = new Vector2(river_endCoord.x * 32, river_endCoord.y * 32); //Get pixel differences double xPixels = xDif * 32; double yPixels = yDif * 32; gridCoordinate[,] dirs = { { new gridCoordinate(1, 0), new gridCoordinate(-1, 0) }, { new gridCoordinate(0, 1), new gridCoordinate(0, -1) } }; int direct = 0; gridCoordinate.coord xy = gridCoordinate.coord.xCoord; if (abs_xDif > abs_yDif) { direct = 1; xy = gridCoordinate.coord.yCoord; } Vector2 c_position = new Vector2(river_startCoord.x * 32, river_startCoord.y * 32); double c_xvalue = c_position.X; double c_yvalue = c_position.Y; bool done = false; gridCoordinate current_position = new gridCoordinate(-1, -1); gridCoordinate previous_position = new gridCoordinate(-1, -1); while (!done) { done = is_river_finished(c_xvalue, c_yvalue); current_position = new gridCoordinate((int)(c_xvalue / 32), (int)(c_yvalue / 32)); if (!(current_position.x == previous_position.x && current_position.y == previous_position.y)) { int[] rr = { rGen.Next(deepwater_thickness + 1), rGen.Next(1, shallow_thickness + 1), rGen.Next(1, banks_thickness + 1) }; int[] rEdge = new int[3]; rEdge[0] = current_position.get_a_coord(xy) + 1 + rr[0]; rEdge[1] = rEdge[0] + rr[1]; rEdge[2] = rEdge[1] + rr[2]; grid[current_position.x][current_position.y].set_tile_type(deep_water_tiltyp, textureList); for (gridCoordinate i = new gridCoordinate(current_position); i.get_a_coord(xy) < rEdge[2]; i.combineCoords(dirs[direct, 0])) { if (i.get_a_coord(xy) >= grid.Count) { break; } if (i.get_a_coord(xy) < rEdge[0]) { grid[i.x][i.y].set_tile_type(deep_water_tiltyp, textureList); } else if (i.get_a_coord(xy) < rEdge[1]) { grid[i.x][i.y].set_tile_type(shallows_tiltyp, textureList); } else { grid[i.x][i.y].set_tile_type(shoreline_tiltyp, textureList); } } int[] lr = { rGen.Next(deepwater_thickness + 1), rGen.Next(1, shallow_thickness + 1), rGen.Next(1, banks_thickness + 1) }; int[] lEdge = new int[3]; lEdge[0] = current_position.get_a_coord(xy) - 1 - lr[0]; lEdge[1] = lEdge[0] - lr[1]; lEdge[2] = lEdge[1] - lr[2]; for (gridCoordinate i = new gridCoordinate(current_position); i.get_a_coord(xy) > lEdge[2]; i.combineCoords(dirs[direct, 1])) { if (i.get_a_coord(xy) < 0) { break; } if (i.get_a_coord(xy) > lEdge[0]) { grid[i.x][i.y].set_tile_type(deep_water_tiltyp, textureList); } else if (i.get_a_coord(xy) > lEdge[1]) { grid[i.x][i.y].set_tile_type(shallows_tiltyp, textureList); } else { grid[i.x][i.y].set_tile_type(shoreline_tiltyp, textureList); } } } Vector2 direction = end_position - c_position; direction.Normalize(); c_xvalue += direction.X; c_yvalue += direction.Y; previous_position = current_position; } }