private static void AddIndividualChair(float x, float y, float size, Dictionary <string, GameObject> chairs, Dictionary <string, float> chairProbs, float roll, float angle)
    {
        var xFudge         = Random.Range(-0.05f, 0.05f);
        var yFudge         = Random.Range(-0.05f, 0.05f);
        int rightChairRoll = Random.Range(0, 100);
        int facingRoll     = Random.Range(0, 100);
        var rotationFudge  = Random.Range(-10f, 10f);

        if (facingRoll >= 95)
        {
            rotationFudge = Random.Range(-180f, 180f);
        }
        else if (facingRoll >= 90)
        {
            rotationFudge += 180;
        }
        GameObject obj;

        if (rightChairRoll > 4)
        {
            obj = LevelGenInstantiationUtils.InstantiateBlockObjectFixed(roll, chairs, chairProbs, x + xFudge, y + yFudge);
        }
        else
        {
            obj = LevelGenInstantiationUtils.InstantiateBlockObject(chairs, chairProbs, x + xFudge, y + yFudge);
        }
        obj.transform.localScale = new Vector3(size, size, size);
        obj.transform.Rotate(0, angle + rotationFudge, 0);
    }
    private static void MakeAndRotateObject(string type, float x, float y, float angle)
    {
        var walls     = prefabs["castle"][type];
        var wallProbs = prefabProbability["castle"][type];
        var obj       = LevelGenInstantiationUtils.InstantiateBlockObject(walls, wallProbs, x, y);

        obj.transform.Rotate(new Vector3(0, angle, 0));
    }
    private static void MakeTorch(float x, float y, float angle)
    {
        var torches    = prefabs["castle"]["torch"];
        var torchProbs = prefabProbability["castle"]["torch"];
        var obj        = LevelGenInstantiationUtils.InstantiateBlockObject(torches, torchProbs, x, y);

        obj.transform.position = new Vector3(obj.transform.position.x, 1, obj.transform.position.z);
        obj.transform.Rotate(new Vector3(0, angle, 0));
    }
示例#4
0
    private static void AddNightstand(float x, float y, float rotation, float size)
    {
        x *= 5;
        y *= 5;
        if (rotation == 90)
        {
            x -= 0.5f * size;
            y -= 1.5f * size;
        }
        else if (rotation == 270)
        {
            x += 0.5f * size;
            y += 1.5f * size;
        }
        else if (rotation == 180)
        {
            x += 1.5f * size;
            y += 0.5f * size;
        }
        else if (rotation == 0)
        {
            x -= 1.5f * size;
            y -= 0.5f * size;
        }
        float xFudge = Random.Range(-0.25f, 0.25f);
        float yFudge = Random.Range(-0.25f, 0.25f);
        var   obj    = Instantiate(LevelGen.instance.nightstand, new Vector3(x + xFudge, 0, y + yFudge), LevelGen.instance.nightstand.transform.rotation);

        obj.transform.parent = LevelGen.instance.dungeonInstance.transform;
        LevelGen.instance.instantiatedObjects.Add(obj);
        obj.transform.localScale = new Vector3(size, size, size);
        obj.transform.Rotate(0, Random.Range(0, 360), 0);
        int clutterRoll = Random.Range(0, 4);

        if (clutterRoll > 0)
        {
            var clutterX = (x + xFudge) / 5;
            var clutterY = (y + yFudge) / 5;
            clutterX += Random.Range(-0.025f, 0.025f) * size;
            clutterY += Random.Range(-0.025f, 0.025f) * size;
            var clutter      = prefabs["castle"]["nightstandClutter"];
            var clutterProbs = prefabProbability["castle"]["nightstandClutter"];
            var obj2         = LevelGenInstantiationUtils.InstantiateBlockObject(clutter, clutterProbs, clutterX, clutterY);
            obj2.transform.position = new Vector3(obj2.transform.position.x, 0.61f * size, obj2.transform.position.z);
            obj2.transform.Rotate(0, Random.Range(0, 360), 0);
        }
    }
    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);
            }
        }
    }
示例#6
0
    private static void AddBeds(LivingQuarters room)
    {
        var population = room.inhabitants.Count;
        var size       = Mathf.Sqrt(DesignedBuilding.monsterRoomSizes[room.inhabitants[0].generalType]);
        int bedType    = GetBedType(room);

        if (bedType == 1)
        {
            population /= 2;
        }
        var beds     = prefabs["castle"]["beds" + bedType];
        var bedProbs = prefabProbability["castle"]["beds" + bedType];
        int bedsX    = (int)Mathf.Sqrt(population);

        if (bedsX == 0)
        {
            bedsX = 1;
        }
        int bedsY       = population / bedsX;
        int bedRotation = Random.Range(0, 4);

        for (int x = 0; x < bedsX; x++)
        {
            for (int y = 0; y < bedsY; y++)
            {
                var xFudge = Random.Range(-0.05f, 0.05f);
                var yFudge = Random.Range(-0.05f, 0.05f);
                var obj    = LevelGenInstantiationUtils.InstantiateBlockObject(beds, bedProbs, xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (bedsX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (bedsY + 1)));
                obj.transform.localScale = new Vector3(size, size, size);
                var rotationFudge = Random.Range(-2.5f, 2.5f);
                obj.transform.Rotate(0, (90 * bedRotation) + rotationFudge, 0);
                int nightstandRoll = Random.Range(0, 2);
                if (nightstandRoll == 0)
                {
                    AddNightstand(xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (bedsX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (bedsY + 1)), 90 * bedRotation, size);
                }
            }
        }
    }
    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);
                }
            }
        }
    }
 private static void InstantiateCastleWall(int x, int y, int floor, string block, string[,,] grid)
 {
     LevelGenInstantiationUtils.InstantiateWall("castle", x, y, floor, block, grid);
 }
 private static void InstantiateCastleBlock(int x, int y, string block)
 {
     LevelGenInstantiationUtils.InstantiateFloorBlock("castle", x, y, block);
 }