private static void AddCommonSpaceSideFurnishing(CommonSpace room, string[,,] grid)
    {
        var population = room.inhabitants.Count;
        var size       = Mathf.Sqrt(DesignedBuilding.monsterRoomSizes[room.inhabitants[0].generalType]);
        int bedType    = ActiveCastleLivingQuartersGen.GetBedType(room);

        if (bedType == 1)
        {
            population /= 2;
        }
        bool fancy = (bedType >= 6);

        population /= 2;
        Dictionary <string, GameObject> furniture;
        Dictionary <string, float>      furnitureProbs;

        if (fancy)
        {
            furniture      = prefabs["castle"]["commonSpaceSideFurnitureFancy"];
            furnitureProbs = prefabProbability["castle"]["commonSpaceSideFurnitureFancy"];
        }
        else
        {
            furniture      = prefabs["castle"]["commonSpaceSideFurniture"];
            furnitureProbs = prefabProbability["castle"]["commonSpaceSideFurniture"];
        }
        var potentialSpots = LevelGenRoomUtils.GetPotentialSideDressingSpots(room, grid);

        foreach (var spot in potentialSpots)
        {
            var roll = Random.Range(0, 100);
            if (roll < 100 * population / (float)potentialSpots.Count)
            {
                var xFudge        = Random.Range(-0.05f, 0.05f);
                var yFudge        = Random.Range(-0.05f, 0.05f);
                var rotationFudge = Random.Range(-2.5f, 2.5f);
                var wallRotation  = LevelGenGridUtils.GetWallRotation((int)spot.x, (int)spot.y, room.floor, grid);
                var xAdjust       = LevelGenGridUtils.GetXSideDressingAdjustment((int)spot.x, (int)spot.y, room.floor, grid);
                var yAdjust       = LevelGenGridUtils.GetYSideDressingAdjustment((int)spot.x, (int)spot.y, room.floor, grid);
                var obj           = LevelGenInstantiationUtils.InstantiateBlockObject(furniture, furnitureProbs, xAdjust + xFudge + spot.x, yAdjust + yFudge + spot.y);
                room.dressingLocations.Add(spot);
                obj.transform.localScale = new Vector3(size, size, size);
                obj.transform.Rotate(0, rotationFudge + wallRotation, 0);
            }
        }
    }
Exemplo n.º 2
0
 public static void AddDressing(Room room, DesignedBuilding layout)
 {
     if (room is LivingQuarters)
     {
         ActiveCastleLivingQuartersGen.AddDressing((LivingQuarters)room, layout.grid);
     }
     if (room is CommonSpace)
     {
         ActiveCastleCommonSpaceGen.AddDressing((CommonSpace)room, layout.grid);
     }
     if (room is LivingQuarters || room is CommonSpace || room is BossRoom)
     {
         AddRoomLight(room);
     }
     AddTorches(room, layout.grid);
     room.dressingLocations.Clear();
 }
    private static void AddCommonSpaceTables(CommonSpace room)
    {
        var population = room.inhabitants.Count;
        var size       = Mathf.Sqrt(DesignedBuilding.monsterRoomSizes[room.inhabitants[0].generalType]);
        int bedType    = ActiveCastleLivingQuartersGen.GetBedType(room);

        if (bedType == 1)
        {
            population /= 2;
        }
        population /= 2;
        bool fancy = (bedType >= 6);
        Dictionary <string, GameObject> tables;
        Dictionary <string, float>      tableProbs;

        if (!fancy)
        {
            tables     = prefabs["castle"]["tables"];
            tableProbs = prefabProbability["castle"]["tables"];
        }
        else
        {
            tables     = prefabs["castle"]["tablesFancy"];
            tableProbs = prefabProbability["castle"]["tablesFancy"];
        }
        int tablesX = (int)Mathf.Sqrt(population);

        if (tablesX == 0)
        {
            tablesX = 1;
        }
        int   tablesY       = population / tablesX;
        int   tableRotation = Random.Range(0, 4);
        float tableRoll     = Random.Range(0f, 1f);

        for (int x = 0; x < tablesX; x++)
        {
            for (int y = 0; y < tablesY; y++)
            {
                var xFudge = Random.Range(-0.05f, 0.05f);
                var yFudge = Random.Range(-0.05f, 0.05f);
                var obj    = LevelGenInstantiationUtils.InstantiateBlockObjectFixed(tableRoll, tables, tableProbs, xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (tablesX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (tablesY + 1)));
                obj.transform.localScale = new Vector3(size, size, size);
                var rotationFudge = Random.Range(-5f, 5f);
                obj.transform.Rotate(0, (90 * tableRotation) + rotationFudge, 0);
                AddChairsToTable(xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (tablesX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (tablesY + 1)), size, fancy, obj, 90 * tableRotation);
                int clutterRoll = Random.Range(0, 4);
                if (clutterRoll > 1)
                {
                    var clutterX = xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (tablesX + 1));
                    var clutterY = yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (tablesY + 1));
                    clutterX += Random.Range(-0.05f, 0.05f) * size;
                    clutterY += Random.Range(-0.05f, 0.05f) * size;
                    var clutter      = prefabs["castle"]["tableClutter"];
                    var clutterProbs = prefabProbability["castle"]["tableClutter"];
                    var obj2         = LevelGenInstantiationUtils.InstantiateBlockObject(clutter, clutterProbs, clutterX, clutterY);
                    obj2.transform.position = new Vector3(obj2.transform.position.x, obj.GetComponentInChildren <Renderer>().bounds.size.y, obj2.transform.position.z);
                    obj2.transform.Rotate(0, Random.Range(0, 360), 0);
                }
            }
        }
    }