예제 #1
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;
            }
        }
예제 #2
0
        private static void populateEnvironmentObjects(__FloorPlan.__Room room, GridBoundList <IEnvironmentObject> environ, Random rand)
        {
            Color col = Color.White;

            switch (room.type)
            {
            case __FloorPlan.__Room.__RoomType.BOSS_ROOM:
                col = Color.Red;
                break;

            case __FloorPlan.__Room.__RoomType.FOYER:
                col = Color.Blue;
                break;

            case __FloorPlan.__Room.__RoomType.TREASURE_ROOM:
                col = Color.Yellow;
                break;

            case __FloorPlan.__Room.__RoomType.NOTHING_SPECIAL:
                col = Color.Gray;
                break;

            case __FloorPlan.__Room.__RoomType.MOB_ROOM:
                col = Color.Green;
                break;
                //case __FloorPlan.__Room.__RoomType.DOORWAY:
                //    environ.Add(new ColorEnvironment(Color.Magenta, true), new IntVec(room.dimensions.X, room.dimensions.Y));
                //    break;
            }

            foreach (IntVec pos in room.GetCells())
            {
                //environ.Add(new ColorEnvironment(col, false), pos);
            }



            switch (room.type)
            {
            case __FloorPlan.__Room.__RoomType.BOSS_ROOM:
                Decoration[] scratches = { new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Scratches"), new IntVec(0, 0))),
                                           new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Scratches"), new IntVec(1, 0))) };
                foreach (IntVec pos in room.GetCells())
                {
                    //Scratches on the floor
                    if (rand.NextDouble() > 0.8)
                    {
                        environ.Add(ChooseOne(rand, scratches), pos);
                    }
                }
                goto case __FloorPlan.__Room.__RoomType.MOB_ROOM;

            case __FloorPlan.__Room.__RoomType.MOB_ROOM:
                Decoration[] bloods = { new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Blood"), new IntVec(0, 0))),
                                        new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Blood"), new IntVec(1, 0))) };
                foreach (IntVec pos in room.GetCells())
                {
                    //Blood on the floor
                    if (rand.NextDouble() > 0.8)
                    {
                        environ.Add(ChooseOne(rand, bloods), pos);
                    }
                }
                break;

            case __FloorPlan.__Room.__RoomType.NOTHING_SPECIAL:
                foreach (Tuple <IntVec, Direction> pos in room.GetWalls(true))
                {
                    if (rand.NextDouble() > 0.95)
                    {
                        environ.Add(new Plant(), pos.Item1);
                    }
                }

                Decoration[] floorStuff = { new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/FloorStuff"), new IntVec(0, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/FloorStuff"), new IntVec(1, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/FloorStuff"), new IntVec(2, 0))) };
                foreach (IntVec pos in room.GetCells())
                {
                    //Random stuff on the floor
                    if (rand.NextDouble() > 0.95)
                    {
                        environ.Add(ChooseOne(rand, floorStuff), pos);
                    }
                }
                break;

            case __FloorPlan.__Room.__RoomType.FOYER:
                Decoration[] tableItems = { new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Plate"), new IntVec(0, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Plate"), new IntVec(0, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Plate"), new IntVec(1, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Plate"), new IntVec(2, 0))),
                                            new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Plate"), new IntVec(3, 0))) };
                //Table
                for (int x = 2; x < room.dimensions.Width - 2; x++)
                {
                    for (int y = 2; y < room.dimensions.Height - 2; y++)
                    {
                        room.setUnfree(room.dimensions.X + x, room.dimensions.Y + y);
                        environ.Add(new Decoration(new Sprite(Engine.Engine.GetTexture("Enviroment/Table"), new IntVec(1 - ((x == 2) ? 1 : 0) + ((x == room.dimensions.Width - 3) ? 1 : 0), 1 - ((y == 2) ? 1 : 0) + ((y == room.dimensions.Height - 3) ? 1 : 0))), true), new IntVec(room.dimensions.X + x, room.dimensions.Y + y));
                        //environ.Add(new ColorEnvironment( Color.Aqua, true ) , new IntVec( room.dimensions.X + x, room.dimensions.Y + y ) );
                        if (rand.NextDouble() > 0.85)
                        {
                            //Something on the table
                            environ.Add(ChooseOne(rand, tableItems), new IntVec(room.dimensions.X + x, room.dimensions.Y + y));
                        }
                    }
                }
                //Chairs
                for (int x = 2; x < room.dimensions.Width - 2; x++)
                {
                    environ.Add(new Chair(Direction.DOWN), new IntVec(room.dimensions.X + x, room.dimensions.Y + 1));
                    environ.Add(new Chair(Direction.UP), new IntVec(room.dimensions.X + x, room.dimensions.Y + room.dimensions.Height - 2));
                }
                for (int y = 2; y < room.dimensions.Height - 2; y++)
                {
                    environ.Add(new Chair(Direction.RIGHT), new IntVec(room.dimensions.X + 1, room.dimensions.Y + y));
                    environ.Add(new Chair(Direction.LEFT), new IntVec(room.dimensions.X + room.dimensions.Width - 2, room.dimensions.Y + y));
                }
                //environ.Add( new Plant(), room.GetCenter() );
                break;
            }
        }