Ejemplo n.º 1
0
    private void GenerateBorderPipes()
    {
        //Sides
        float     precompTotal = WeightedChoice.PrecompTotal(borderChances);
        Furniture prefab;

        //Horizontal sides and corners
        for (int xPos = x; xPos < x + width; xPos++)
        {
            prefab = RandomBorderItem(precompTotal);
            Vector2 position = new Vector3(xPos, y);
            if (prefab != null)
            {
                Rect rect = new Rect(position.x, position.y, borderPipeBreadth, borderPipeBreadth);
                AttemptFurnitureInstantiation(prefab, rect);
            }
            prefab   = RandomBorderItem(precompTotal);
            position = new Vector3(xPos, y + height - 1);
            if (prefab != null)
            {
                Rect rect = new Rect(position.x, position.y, borderPipeBreadth, borderPipeBreadth);
                AttemptFurnitureInstantiation(prefab, rect);
            }
        }
        //Vertical sides
        for (int yPos = y + 1; yPos < y + height - 1; yPos++)
        {
            prefab = RandomBorderItem(precompTotal);
            Vector2 position = new Vector3(x, yPos);
            if (prefab != null)
            {
                Rect rect = new Rect(position.x, position.y, borderPipeBreadth, borderPipeBreadth);
                AttemptFurnitureInstantiation(prefab, rect);
            }
            prefab   = RandomBorderItem(precompTotal);
            position = new Vector3(x + width - 1, yPos);
            if (prefab != null)
            {
                Rect rect = new Rect(position.x, position.y, borderPipeBreadth, borderPipeBreadth);
                AttemptFurnitureInstantiation(prefab, rect);
            }
        }
    }
Ejemplo n.º 2
0
    public override void GenerateFurniture()
    {
        GenerateLightSwitch();
        float precompTotal = WeightedChoice.PrecompTotal(furnitureChances);

        if (orientation == Orientation.Horizontal)
        {
            for (int xPos = x + 1; xPos < x + width - 1;)
            {
                Furniture prefab;
                if (xPos < x + width - 2)
                {
                    prefab = RandomFurniture(precompTotal);
                }
                else
                {
                    prefab = tileset.smallWineShelf;
                }
                int furnitureBreadth;
                if (prefab == tileset.largeWineShelf)
                {
                    furnitureBreadth = 2;
                }
                else
                {
                    furnitureBreadth = 1;
                }

                InstantiateFurniture(prefab, new Vector2(xPos, y));
                xPos += furnitureBreadth;
            }
            for (int xPos = x + 1; xPos < x + width - 1;)
            {
                Furniture prefab;
                if (xPos < x + width - 2)
                {
                    prefab = RandomFurniture(precompTotal);
                }
                else
                {
                    prefab = tileset.smallWineShelf;
                }
                int furnitureBreadth;
                if (prefab == tileset.largeWineShelf)
                {
                    furnitureBreadth = 2;
                }
                else
                {
                    furnitureBreadth = 1;
                }

                InstantiateFurniture(prefab, new Vector2(xPos, y + height - furnitureBreadth));
                xPos += furnitureBreadth;
            }
        }
        else          //Orientation.Vertical
        {
            for (int yPos = y + 1; yPos < y + height - 1;)
            {
                Furniture prefab;
                if (yPos < y + height - 2)
                {
                    prefab = RandomFurniture(precompTotal);
                }
                else
                {
                    prefab = tileset.smallWineShelf;
                }
                int furnitureBreadth;
                if (prefab == tileset.largeWineShelf)
                {
                    furnitureBreadth = 2;
                }
                else
                {
                    furnitureBreadth = 1;
                }

                InstantiateFurniture(prefab, new Vector2(x, yPos));
                yPos += furnitureBreadth;
            }
            for (int yPos = y + 1; yPos < y + height - 1;)
            {
                Furniture prefab;
                if (yPos < y + height - 2)
                {
                    prefab = RandomFurniture(precompTotal);
                }
                else
                {
                    prefab = tileset.smallWineShelf;
                }
                int furnitureBreadth;
                if (prefab == tileset.largeWineShelf)
                {
                    furnitureBreadth = 2;
                }
                else
                {
                    furnitureBreadth = 1;
                }

                InstantiateFurniture(prefab, new Vector2(x + width - furnitureBreadth, yPos));
                yPos += furnitureBreadth;
            }
        }
    }
Ejemplo n.º 3
0
    public void GeneratePantryFurniture()
    {
        //Corners
        float     precompTotal = WeightedChoice.PrecompTotal(pantryCornerChances);
        Furniture prefab       = RandomPantryItem(precompTotal);

        if (prefab != null)
        {
            InstantiateFurniture(prefab, new Vector2(pX, pY));
        }
        prefab = RandomPantryItem(precompTotal);
        if (prefab != null)
        {
            InstantiateFurniture(prefab, new Vector2(pX + pWidth - 1, pY));
        }
        prefab = RandomPantryItem(precompTotal);
        if (prefab != null)
        {
            InstantiateFurniture(prefab, new Vector2(pX, pY + pHeight - 1));
        }
        prefab = RandomPantryItem(precompTotal);
        if (prefab != null)
        {
            InstantiateFurniture(prefab, new Vector2(pX + pWidth - 1, pY + pHeight - 1));
        }

        //Sides
        precompTotal = WeightedChoice.PrecompTotal(pantryChances);
        //Horizontal sides
        for (int xPos = pX + 1; xPos < pX + pWidth - 1; xPos++)
        {
            prefab = RandomPantryItem(precompTotal);
            Vector2 position = new Vector3(xPos, pY);
            if (prefab != null && position != pantryDoorPosition)
            {
                InstantiateFurniture(prefab, position);
            }
            prefab   = RandomPantryItem(precompTotal);
            position = new Vector3(xPos, pY + pHeight - 1);
            if (prefab != null && position != pantryDoorPosition)
            {
                InstantiateFurniture(prefab, position);
            }
        }
        //Vertical sides
        for (int yPos = pY + 1; yPos < pY + pHeight - 1; yPos++)
        {
            prefab = RandomPantryItem(precompTotal);
            Vector2 position = new Vector3(pX, yPos);
            if (prefab != null && position != pantryDoorPosition)
            {
                InstantiateFurniture(prefab, position);
            }
            prefab   = RandomPantryItem(precompTotal);
            position = new Vector3(pX + pWidth - 1, yPos);
            if (prefab != null && position != pantryDoorPosition)
            {
                InstantiateFurniture(prefab, position);
            }
        }
    }