Example #1
0
        private static void populateGameCharacters(__FloorPlan.__Room room, GridBoundList <GameCharacter> chars, Random rand, int dungeonLevel, int heroLevel)
        {
            switch (room.type)
            {
            case __FloorPlan.__Room.__RoomType.BOSS_ROOM:
                if (room.isFree(room.GetCenter()))
                {
                    chars.Add(EnemyCreator.GetRandomBoss(dungeonLevel), room.GetCenter());
                }
                break;

            case __FloorPlan.__Room.__RoomType.NOTHING_SPECIAL:
                foreach (var pos in room.GetCells())
                {
                    if (rand.NextDouble() > 0.98 && room.isFree(pos))
                    {
                        chars.Add(EnemyCreator.GetRandomEnemy(1, dungeonLevel)[0], pos);
                    }
                    //lights.Add(new ColorEnvironment(new Color(rand.Next(100,256), rand.Next(100,256), rand.Next(100,256)), false), position);
                }
                break;

            case __FloorPlan.__Room.__RoomType.MOB_ROOM:
                Enemy[] enemies = EnemyCreator.GetRandomEnemy(rand.Next(2, 6), dungeonLevel);
                int     dropped = 1;
                chars.Add(enemies[0], room.GetCenter());
                foreach (var dir in Direction.Values)
                {
                    if (dropped < enemies.Length && (room.isFree(room.GetCenter() + dir)))
                    {
                        chars.Add(enemies[dropped], room.GetCenter() + dir);
                        dropped++;
                    }
                }
                break;
            }
        }
Example #2
0
        private static IntVec findEndPoints(__FloorPlan floorPlan, GridBoundList <IInteractable> interactableEnvironment, Random rand)
        {
            int entryRoom = rand.Next(floorPlan.hallstart);

            while (floorPlan.rooms[entryRoom].type != __FloorPlan.__Room.__RoomType.FOYER && floorPlan.rooms[entryRoom].type != __FloorPlan.__Room.__RoomType.TREASURE_ROOM)
            {
                entryRoom = (entryRoom + 1) % floorPlan.hallstart;
            }
            __FloorPlan.__Room start      = floorPlan.rooms[entryRoom];
            IntVec             startPoint = start.GetCenter();

            Engine.Engine.Log(string.Format("Start point: <{0}, {1}>", startPoint.X, startPoint.Y));
            floorPlan.isFloor[startPoint.X, startPoint.Y] = false;
            floorPlan.rooms[entryRoom].type = __FloorPlan.__Room.__RoomType.EMPTY;

            int endRoom = (entryRoom + floorPlan.hallstart / 2) % floorPlan.hallstart;

            while (floorPlan.rooms[endRoom].type != __FloorPlan.__Room.__RoomType.FOYER && floorPlan.rooms[endRoom].type != __FloorPlan.__Room.__RoomType.TREASURE_ROOM)
            {
                endRoom = (endRoom + 1) % floorPlan.hallstart;
            }
            __FloorPlan.__Room end = floorPlan.rooms[endRoom];
            floorPlan.rooms[endRoom].type = __FloorPlan.__Room.__RoomType.EMPTY;
            Engine.Engine.Log(string.Format("End point: <{0}, {1}>", end.GetCenter().X, end.GetCenter().Y));
            floorPlan.isFloor[end.GetCenter().X, end.GetCenter().Y] = false;
            try
            {
                Stairs s = new Stairs();
            }
            catch (Exception e)
            {
                Console.WriteLine("");
            }
            interactableEnvironment.Add(new Stairs(), end.GetCenter());
            return(startPoint);
        }
Example #3
0
        private static void populateInteractiveEnvironmentObjects(__FloorPlan.__Room room, GridBoundList <IInteractable> interact, Random rand, int dungeonLevel, int heroLevel, Tuple <HiddenPassage, IntVec>[] previousPassage, List <IInteractable> subscribedForSwitches)
        {
            switch (room.type)
            {
            case __FloorPlan.__Room.__RoomType.DOORWAY:
                if (room.setUnfree(room.dimensions.X, room.dimensions.Y))
                {
                    interact.Add(new Door((room.floorPlan[room.dimensions.X - 1, room.dimensions.Y]) ? Direction.RIGHT: Direction.UP), new IntVec(room.dimensions.X, room.dimensions.Y));
                }
                break;

            case __FloorPlan.__Room.__RoomType.SUPAH_TREASURE_ROOM:
                if (room.setUnfree(room.GetCenter()))
                {
                    Item[] items = new Item[rand.Next(2, 8)];
                    for (int i = 0; i < items.Length; i++)
                    {
                        items[i] = Item.randomLegendary(dungeonLevel, heroLevel);
                    }
                    interact.Add(new Chest(items), room.GetCenter());
                }

                foreach (var wall in room.GetWalls(false, false))
                {
                    room.setUnfree(wall.Item1);

                    interact.RemoveAtPosition(wall.Item1);
                    Gate door = new Gate(wall.Item2);
                    interact.Add(door, wall.Item1);
                    subscribedForSwitches.Add(door);
                }
                break;

            case __FloorPlan.__Room.__RoomType.TREASURE_ROOM:
                if (room.setUnfree(room.GetCenter()))
                {
                    Item[] items = new Item[rand.Next(2, 8)];
                    for (int i = 0; i < items.Length; i++)
                    {
                        items[i] = Item.randomItem(dungeonLevel, heroLevel);
                    }
                    interact.Add(new Chest(items), room.GetCenter());
                }
                break;

            case __FloorPlan.__Room.__RoomType.NOTHING_SPECIAL:
                foreach (var wall in room.GetWalls(false))
                {
                    if (rand.NextDouble() > 0.998)
                    {
                        if (previousPassage[0] == null)
                        {
                            previousPassage[0] = Tuple.Create <HiddenPassage, IntVec>(new HiddenPassage(wall.Item2), wall.Item1);
                        }
                        else
                        {
                            interact.Add(previousPassage[0].Item1, previousPassage[0].Item2);
                            interact.Add(new HiddenPassage(previousPassage[0].Item1, wall.Item2), wall.Item1);
                            previousPassage[0] = null;
                        }
                    }
                }
                break;
            }
        }