public void generateDungeon(float difficulty) { Debug.Log(difficulty); int floors = DifficultyToFloors(difficulty); dungeonFloors.Clear(); activeFloor = 0; float floorDifficulty = (difficulty / floors) * 2; Debug.Log(floorDifficulty); for (int i = 0; i < floors; i++) { TileBase[,] floorWallTiles = digger.MakeDungeonFloor( DungeonPresets.difficultyToDungeonParams(floorDifficulty)); List <Rect> floorRoomRects = digger.rooms.ToList(); List <Rect> floorCorridorRects = digger.corridors.ToList(); List <Room> rooms = RoomBuilder.BuildRooms( floorDifficulty, floorWallTiles, floorRoomRects, floorCorridorRects); DungeonFloor dungeonFloor = new DungeonFloor( floorWallTiles, floorRoomRects, floorCorridorRects, rooms); dungeonFloors.Add(dungeonFloor); } }
public Vector3 GoBackToFirstFloor() { currentFloor.gameObject.SetActive(false); currentFloor = floors[0]; currentFloorIdx = 0; currentFloor.gameObject.SetActive(true); return(currentFloor.entrance.transform.position); }
public void SetExit(DungeonFloor pFloor, byte pX, byte pY, short pArea, Door pExitPosition, params Door[] pDoors) { pFloor.SetExit(pX, pY, pArea, pExitPosition); foreach (var door in pDoors) { pFloor.Exit.AddDoor(door); } }
public PathFinder(DungeonFloor currMap) { this.currMap = currMap; queue = new List <Coord>(); from = new Dir[100][]; for (int i = 0; i < 100; i++) { from[i] = new Dir[100]; } }
public void DrawMap(DungeonFloor floor) { foreach (var mapRoom in MapTransf.GetComponentsInChildren <MapRoom>()) { mapRoom.DisableAll(); } foreach (var room in floor.Rooms) { int roomIndex = CoordToIndex(room.Coordinate); var mapRoom = MapTransf.GetChild(roomIndex).GetComponent <MapRoom>(); DrawMapRoom(mapRoom, room); } }
public DungeonFloor GenerateFloor() { var level = Level + 1; var floor = new DungeonFloor(level); Floors.Add(floor); var numRooms = Rand.NextGaussian(RoomsMean, RoomsStd); Debug.Log($"Generating Floor {level} with {numRooms} rooms."); return(floor.GenerateFloor(numRooms)); }
public void DrawFloor() { DungeonFloor dungeonFloor = GameManager.Instance.dungeonController.GetActiveDungeonFloor(); RenderTiles(wallTilemap, dungeonFloor.wallTiles, Vector2Int.zero, true); foreach (Room room in dungeonFloor.rooms) { DrawRoom(room); } if (currentFloor + 2 == GameManager.Instance.dungeonController.dungeonFloors.Count) { PlaceFinalExit(dungeonFloor.rooms[dungeonFloor.rooms.Count - 1]); } else { PlaceExit(dungeonFloor.rooms[dungeonFloor.rooms.Count - 1]); } }
public void addDungeon() { // level 1 DungeonFloor df_1 = new DungeonFloor (); df_1.level = 1; df_1.goodItem = new List<string>(){ "Elixir of Minor Rejuvenation", "Unguent of Minor Invigoration", "Trusty Sword", "Wooden Shield", "Emblem of Power", "Emblem of Endurance", "Staff of Blasting", "Staff of Healing, Monk's Robes", "Page's Armor", "Short Bow"}; df_1.badItem = new List<string>(); df_1.goodClass = -1; // 1 - wizard, 2 - warrior, 3 - ranger df_1.badClass = -1; df_1.monsters = new List<string>() { "Kocowardly", "Crimson Slime", "Azure Slime"}; df_1.boss = "Werefrog"; df_1.levelPoints = 500; df_1.bossPoints = 250; this.GetComponent<Dungeon> ().floors.Add (df_1); // level 2 DungeonFloor df_2 = new DungeonFloor (); df_2.level = 2; df_2.goodItem = new List<string>(){ "Elixir of Minor Rejuvenation", "Unguent of Minor Invigoration", "Trusty Sword", "Wooden Shield", "Emblem of Power", "Emblem of Endurance", "Staff of Blasting", "Staff of Healing, Monk's Robes", "Page's Armor", "Short Bow"}; df_2.badItem = new List<string>(); df_2.goodClass = -1; // 1 - wizard, 2 - warrior, 3 - ranger df_2.badClass = -1; df_2.monsters = new List<string>() { "Kocowardly", "Crimson Slime", "Azure Slime"}; df_2.boss = "Weregoose"; df_2.levelPoints = 600; df_2.bossPoints = 300; this.GetComponent<Dungeon> ().floors.Add (df_2); }
public Vector3 GoToNextFloor() { currentFloor.gameObject.SetActive(false); var nextFloor = ++currentFloorIdx; if (nextFloor < floors.Count) { currentFloor = floors[nextFloor]; currentFloor.gameObject.SetActive(true); } else { currentFloor = DungeonFloorFactory.InstantitateFloor(nextFloor); floors.Add(currentFloor); } return(currentFloor.entrance.transform.position); }
// Use this for initialization void Start() { dungeonFloor = DungeonGenerator.CreateFloor(64, 64, new Dungeon()); RLBaseTile start = null; foreach (RLBaseTile t in dungeonFloor.Tiles) { if (t != null) { if (start == null && !t.GetTileType().BlocksMovement) { start = t; } TileRenderer.BindTile(t); } } _actor = new SimpleActor(StatBlock.CreateInstance(baseStats, 3, 7, 9)) { BasicMoveSkill = move, fieldOfView = new BresenhamFOV(), OnVisibilityChanged = (tile, visible) => { if (visible) { tile.SetCurrentlyVisibleToPlayer(true); tile.SetEverSeenByPlayer(true); } else { tile.SetCurrentlyVisibleToPlayer(false); } } }; StatBlockDisplay.BindStatBlock(_actor.GetStats()); start.SetActor(_actor); RLActorController actorController = Instantiate(ActorPrefab, transform); actorController.effectRenderer = effectRenderer; actorController.BindActor(_actor); InventoryDisplay.BindInventory(_actor); virtualCam.Follow = actorController.transform; }
public override void Build() { DungeonFloor floor = AddFloor(4266547036, 1227, 10361); SetEntrance(floor, 0, 4, 0x0005, Door.SouthExit, Door.East); var firstRoom = AddRoom(floor, 0, 1, 0x0003, Puzzle.SpawnChest, Door.North, Door.South); AddSpawnGroup(firstRoom, DungeonKey.None, Spawn(50002, 2)); AddSpawnGroup(firstRoom, DungeonKey.Room, Spawn(30001, 2)); AddRoom(floor, 1, 1, 0x0007, Puzzle.None, Door.South, Door.EastLocked); var secondRoom = AddRoom(floor, 2, 1, 0x000B, Puzzle.SpawnChest, Door.West, Door.East); AddSpawnGroup(secondRoom, DungeonKey.Boss, Spawn(50003, 1)); AddRoom(floor, 3, 1, 0x000C, Puzzle.None, Door.East); SetBossroom(floor, 3, 2, 0x000D); }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public DungeonMapFloor(DungeonFloor dungeonFloor) { this.dungeonFloor = dungeonFloor; this.floorNumber = dungeonFloor.FloorNumber; this.isDiscovered = dungeonFloor.IsDiscovered; this.size = new Point2I(8, 8); // Create rooms. rooms = new DungeonMapRoom[size.X, size.Y]; isBossFloor = false; if (dungeonFloor.Level != null) { for (int x = 0; x < size.X; x++) { for (int y = 0; y < size.Y; y++) { Point2I loc = new Point2I(x, y); if (dungeonFloor.Level.ContainsRoom(loc)) { Room room = dungeonFloor.Level.GetRoomAt(loc); if (!room.IsHiddenFromMap) { rooms[x, y] = DungeonMapRoom.Create(room, this); if (rooms[x, y] != null && rooms[x, y].IsBossRoom) { isBossFloor = true; } } } else { rooms[x, y] = null; } } } } }
public static void Draw(this DungeonFloor floor, LibDungeon.Objects.Actor player, Size out_zone, Graphics g) { // Ограничиваем выводимые спрайты размером контрола // По центру располагается игрок int borderX = out_zone.Width / 2 - 32, borderY = out_zone.Height / 2 - 32; // Рисование пола for (int i = 0; i < floor.Width; i++) { for (int j = 0; j < floor.Height; j++) { int screenX = (i - player.X) * 32, screenY = (j - player.Y) * 32; if (Math.Abs(screenX) >= borderX || Math.Abs(screenY) >= borderY) { continue; } screenX += borderX; screenY += borderY; var tile = floor.Tiles[i, j]; if (tile.Visible) { Rectangle zone = new Rectangle(0, 0, 32, 32); switch (tile) { case Floor tfloor: zone.X = 32 * 2; break; case Wall twall: zone.X = 32 * 5; break; case Door tdoor: zone.X = 32 * (tdoor.IsOpen ? 1 : 0); break; case Ladder tladder: zone.X = 32 * (tladder.Direction == Ladder.LadderDirection.Down ? 3 : 4); break; /*default: * brush = Brushes.Pink; * break;*/ } g.DrawImage(sprites, screenX, screenY, zone, GraphicsUnit.Pixel); //g.DrawImage(sprites, i*32, j*32, zone, GraphicsUnit.Pixel); } else if (tile.Visited && !(tile is Wall)) { g.FillRectangle(Brushes.DarkBlue, screenX, screenY, 32, 32); } } } foreach (var item in floor.FloorItems) { int screenX = (item.X - player.X) * 32, screenY = (item.Y - player.Y) * 32; if (floor.Tiles[item.X, item.Y].Visible && (Math.Abs(screenX) < borderX && Math.Abs(screenY) < borderY)) { g.FillEllipse(Brushes.DarkRed, screenX + borderX, screenY + borderY, 32, 32); } } foreach (var actor in floor.FloorActors) { int screenX = (actor.X - player.X) * 32, screenY = (actor.Y - player.Y) * 32; if (floor.Tiles[actor.X, actor.Y].Visible && (Math.Abs(screenX) < borderX && Math.Abs(screenY) < borderY)) { g.FillRectangle((actor.Health > 0) ? Brushes.Green : Brushes.Red, screenX + borderX, screenY + borderY, 32, 32); } } g.DrawRectangle(Pens.White, borderX, borderY, 32, 32); }
public DungeonRoom AddRoom(DungeonFloor pFloor, byte pX, byte pY, short pArea, Puzzle pPuzzle, params Door[] pDoors) { return(new DungeonRoom(pFloor, pX, pY, pArea, pPuzzle, pDoors)); }
public void SetBossroom(DungeonFloor pFloor, byte pX, byte pY, short pArea) { pFloor.SetBossroom(pX, pY, pArea); }
private bool _PlayerMove(PlayerCommand command) { // Исходя из команды, выполнить то или иное действие. // Если команда пройдёт успешно, то исчерпать запасы стамины и гонять Think, пока она не восстановится // Перемещение: if ((int)command < (int)PlayerCommand.Wait) { int x = PlayerPawn.X, y = PlayerPawn.Y; switch (command) { case PlayerCommand.Move0: x++; break; case PlayerCommand.Move45: x++; y--; break; case PlayerCommand.Move90: y--; break; case PlayerCommand.Move135: x--; y--; break; case PlayerCommand.Move180: x--; break; case PlayerCommand.Move225: x--; y++; break; case PlayerCommand.Move270: y++; break; case PlayerCommand.Move315: x++; y++; break; } return(_PlayerMove(x, y)); } if (command == PlayerCommand.Wait) { // Во время отдыха игрок должен быстрее регенерировать здоровье // и медленнее становиться голоднее PlayerPawn.Thoughts = ThoughtTypeEnum.Stand; return(true); } // Лестница if (command == PlayerCommand.LadderDown || command == PlayerCommand.LadderUp) { if (!(CurrentFloor.Tiles[PlayerPawn.X, PlayerPawn.Y] is Ladder)) { return(false); } Ladder ourpos = CurrentFloor.Tiles[PlayerPawn.X, PlayerPawn.Y] as Ladder; int nextlevel = currentLevel + ((ourpos.Direction == Ladder.LadderDirection.Up) ? -1 : 1); if (nextlevel < 0) { return(false); } // Если следующий уровень ещё не сгенерирован, то сгенерировать и связать текущую лестницу со случайной if (nextlevel > floors.Count - 1)// Уравнял счетчик с индексами { ourpos.LadderId = random.Next(1, Int32.MaxValue); var newfloor = new DungeonFloor( Spawner.Random.Next(currentLevel + 2 * 10, 81), Spawner.Random.Next(currentLevel + 2 * 10, 81) ); floors.Add(newfloor); newfloor.FloorActors.AddLast(PlayerPawn); int lx = 0; int ly = 0; for (int i = 0; i < newfloor.Width; i++) { for (int j = 0; j < newfloor.Height; j++) { if (newfloor.Tiles[i, j] is Ladder && (newfloor.Tiles[i, j] as Ladder).Direction == Ladder.LadderDirection.Up) { lx = i; ly = j; PlayerPawn.ChangePos(lx, ly); } } } (newfloor.Tiles[lx, ly] as Ladder).LadderId = ourpos.LadderId; SendClientMessage(null, $"Вы {(nextlevel > CurrentLevel ? "спускаетесь" : "поднимаетесь")} на уровень {nextlevel+1}"); } // Если он уже существует, то попытаться найти свободную лестницу, если не выйдет, то скинуть в случ. // позицию. else { //Этаж на который переходим var floor = floors[nextlevel]; if (ourpos.LadderId == 0) { int lx = 0; int ly = 0; //Задаем id для новой лестницы ourpos.LadderId = random.Next(1, Int32.MaxValue); for (int i = 0; i < floor.Width; i++) { for (int j = 0; j < floor.Height; j++) { //Если 2 лестницы не связаны, то ищем свободную if (floor.Tiles[i, j] is Ladder && (floor.Tiles[i, j] as Ladder).LadderId == 0 && (floor.Tiles[i, j] as Ladder).Direction != ourpos.Direction) { lx = i; ly = j; PlayerPawn.ChangePos(lx, ly); } } } (floor.Tiles[lx, ly] as Ladder).LadderId = ourpos.LadderId; } else { for (int i = 0; i < floor.Width; i++) { for (int j = 0; j < floor.Height; j++) { //Если 2 лестницы связаны то перемещаемся по ним if (floor.Tiles[i, j] is Ladder && (floor.Tiles[i, j] as Ladder).LadderId == ourpos.LadderId) { PlayerPawn.ChangePos(i, j); } } } } SendClientMessage(null, $"Вы возвращаетесь на уровень {nextlevel}"); } currentLevel = nextlevel; return(true); } // Поднятие предмета if (command == PlayerCommand.PickupItem) { var item = CurrentFloor.FloorItems.FirstOrDefault(x => x.X == PlayerPawn.X && x.Y == PlayerPawn.Y); if (item == null) { return(false); } CurrentFloor.FloorItems.Remove(item); /*if (item.RemoveOnPickup) * item.Use(PlayerPawn); * else*/ PlayerPawn.AddItem(item); return(true); } // Открытие / закрытие дверей if (command == PlayerCommand.OpenDoor || command == PlayerCommand.CloseDoor) { for (int i = PlayerPawn.X - 1; i <= PlayerPawn.X + 1; i++) { for (int j = PlayerPawn.Y - 1; j <= PlayerPawn.Y + 1; j++) { if (CurrentFloor.Tiles[i, j] is Door) { (CurrentFloor.Tiles[i, j] as Door).IsOpen = (command == PlayerCommand.OpenDoor) ? true : false; return(true); } } } return(false); } if (command == PlayerCommand.EquipItem || command == PlayerCommand.RemoveItem) { return(true); } return(false); }