static void tryAddRoom() //this tries to build a random room { int x, y; bool done = false; for (int i = 0; i < maxTries; i++) { x = 0; y = 0; while (!isWall(x, y)) { x = MyRandom.getRandomInt(1, mapWidth - 1); y = MyRandom.getRandomInt(1, mapHeight - 1); } done = digRoom(x, y); if (done) { break; } } }
static void tryAddCorridor() //this tries to build a random corridor { //in the dungeon int x, y; bool done = false; for (int i = 0; i < maxTries; i++) { x = 0; y = 0; while (!isWall(x, y)) { x = MyRandom.getRandomInt(1, mapWidth - 1); y = MyRandom.getRandomInt(1, mapHeight - 1); } done = digCorridor(x, y); if (done) { break; } } }
public void PickupDialogue() //NEED TO WORK WITH LISTS. !!! { List <Item> picked = World.getItemListAt(owner.CoordX, owner.CoordY); if (picked.Count > 0) { picked = MultipleItemSelectionMenu("pick up", picked); if (picked == null) { return; } foreach (Item i in picked) { if (TryPickUpItem(i)) { World.AllItemsOnFloor.Remove(i); Log.AddLine("You picked up the " + i.DisplayName + "."); } } } else { int randomMessageNumber = MyRandom.getRandomInt(3); switch (randomMessageNumber) { case 0: Log.AddLine("There's nothing here to pick up."); break; case 1: Log.AddLine("All that lying here is the dust."); break; case 2: Log.AddLine("Of course you can pick up the air."); break; } return; } }
void closeDoorDialogue() { Log.AddLine("Close door in which direction?"); ConsoleKeyInfo keyPressed = Console.ReadKey(true); KeyToVector.ProcessInput(keyPressed); int doorX = CoordX + KeyToVector.x, doorY = CoordY + KeyToVector.y; if (doorX == CoordX && doorY == CoordY) { int randomMessageNumber = MyRandom.getRandomInt(3); switch (randomMessageNumber) { case 0: Log.AddLine("Wow. You costumed like a door this Halloween?"); break; case 1: Log.AddLine("You have almost closed yourself, but suddenly remembered that you're not a door."); break; case 2: Log.AddLine("Okay... Try another time"); break; } return; } if (World.TryCloseDoor(doorX, doorY)) { Timing.AddActionTime(TimeCost.PeepCost(this)); Log.ReplaceLastLine("You carefully closed the door."); } else { Log.ReplaceLastLine("You tried to close this, but something went wrong..."); } }
void strangleDialogue() { Log.AddLine("Grab in which direction?"); ConsoleKeyInfo keyPressed = Console.ReadKey(true); KeyToVector.ProcessInput(keyPressed); int strangleX = CoordX + KeyToVector.x, strangleY = CoordY + KeyToVector.y; if (strangleX == CoordX && strangleY == CoordY) { int randomMessageNumber = MyRandom.getRandomInt(3); switch (randomMessageNumber) { case 0: Log.AddLine("Wanna strangle yourself huh?"); break; case 1: Log.AddLine("Suicide will not help with your mission."); break; case 2: Log.AddLine("If you wanna touch yourself, get a room, please."); break; } return; } if (World.isActorPresent(strangleX, strangleY)) { Attack.Strangle(this, World.getActorAt(strangleX, strangleY)); Timing.AddActionTime(TimeCost.StrangleCost(this)); } else { Log.AddLine("There's nobody here!"); } }
public static int[,] generateDungeon() { int roomwidth, roomheight, roomx, roomy; //fill everything with "earth" //set everything with zero lock level as well for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { map[i, j] = piece.wall; lockMap[i, j] = currentLockLevel; } } //place a room in the center of a dungeon roomwidth = MyRandom.getRandomInt(minRoomSize + 1, maxRoomSize); roomheight = MyRandom.getRandomInt(minRoomSize + 1, maxRoomSize); roomx = mapWidth / 2 - roomwidth / 2; roomy = mapHeight / 2 - roomheight / 2; if (isEmpty(roomx, roomy, roomwidth, roomheight)) { dig(roomx, roomy, roomwidth, roomheight); } //total rooms and corridors int rooms = 1; int corridors = 0; //now let's start a generation loop int iteration = 0; while (corridors < maxCorridors || rooms < maxRooms) { //do we need to increase the current lock level? //TEMPORARY SOLUTION!!111 //Hehehe... Temporary... for (int i = 0; i <= maxKeys; i++) { if (rooms > i * maxRooms / (maxKeys + 1) && i > currentLockLevel) { tryAddKeyplace(); currentLockLevel = i; } } //firstly, pick a random wall adjacent to room //or corridor or something ///!!MOVED TO ANOTHER METHOD!! //okay, it's picked. Now let's decide //will we build whether a corridor or a room if (true) { if (corridors < maxCorridors) { tryAddCorridor(); corridors++; } } if (true /*iteration % 2 == 0*/) { if (rooms < maxRooms) { tryAddRoom(); rooms++; } } //repeat... iteration++; } //now let's make walls on perimeter for (int i = 0; i < mapWidth; i++) { map[i, 0] = piece.wall; map[i, mapHeight - 1] = piece.wall; } for (int j = 0; j < mapHeight; j++) { map[0, j] = piece.wall; map[mapWidth - 1, j] = piece.wall; } //let's place an entrance stair int sx = 0, sy = 0; while (map[sx, sy] != piece.floor || lockMap[sx, sy] != 0) { sx = MyRandom.getRandomInt(mapWidth); sy = MyRandom.getRandomInt(mapHeight); } map[sx, sy] = piece.upstair; //let's add some columns addColumns(); //transform "pieces" into ints int[,] finalMap = new int[mapWidth, mapHeight]; for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { finalMap[i, j] = (int)map[i, j]; } } return(finalMap); }
public static void AddOneFromList(List <string> values) { int r = MyRandom.getRandomInt(values.Count); AddLine(values[r]); }
public static int StrangleCost(Unit acting) { return(MyRandom.getRandomInt(15, 25)); }