コード例 #1
0
    //Spawns all the buildings
    public void Create()
    {
        //pull the list based upon what the function of the tile is.
        VillageBuildingList.Building[] posibleBuildings = VB.buildingList[(int)functionType - 1].buildings;

        //int temp = 11;

        List <Coord> cornerTiles  = new List <Coord>();
        List <Coord> edgeTiles    = new List <Coord>();
        List <Coord> interiorEdge = new List <Coord>();


        for (int x = 0; x < interior.GetLength(0); x++)
        {
            for (int y = 0; y < interior.GetLength(1); y++)
            {
                if (interior[x, y] == Space.corner)
                {
                    cornerTiles.Add(new Coord(x, y));
                }
                if (interior[x, y] == Space.edge)
                {
                    edgeTiles.Add(new Coord(x, y));
                }
                if (interior[x, y] == Space.insideCorner)
                {
                    interiorEdge.Add(new Coord(x, y));
                }
            }
        }


        shuffledCoords = new Queue <Coord>(Shuffle.ShuffleArray(edgeTiles.ToArray()));


        //if its a castle, try the first two buildings first
        if (functionType == Function.Castle)
        {
            for (int k = 0; k < edgeTiles.Count; k++)
            {
                Coord rnd = GetRandomCoord();

                for (int r = 0; r < 2; r++)
                {
                    //take a random building object
                    int     num  = r;
                    Vector2 size = posibleBuildings[num].objectSize;

                    if (!posibleBuildings[num].SpawnsOnEdge)
                    {
                        continue;
                    }

                    bool[] b = FreeSpace(rnd.x, rnd.y, size);

                    //if the building fits in the space
                    if (b[0])
                    {
                        GameObject h;
                        if (b[3])
                        {
                            //spawn that building in the space
                            h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                        }
                        else
                        {
                            h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                        }
                        //if (!b[3])
                        //{
                        //    h.transform.Rotate(posibleBuildings[num].rotationSide, 90f);
                        //}


                        if (animate)
                        {
                            Raise rise = h.AddComponent <Raise>();

                            rise.timeToWait = RandomNumber.Range(2f, 5f); //((x + y) / 4f) / 10f;
                            RunAnimation   += rise.StartRaise;
                        }

                        BuildingVariation v = h.transform.GetChild(0).GetComponent <BuildingVariation>();

                        if (v)
                        {
                            v.roofColor = identifier.roof;
                            v.woodColor = identifier.wood;
                            v.Customize();
                        }


                        //assign all the tiles as taken
                        for (int i = 0; i < (b[3] ? size.x : size.y); i++)
                        {
                            for (int j = 0; j < (b[3] ? size.y : size.x); j++)
                            {
                                interior[(b[1] ? rnd.x - i : rnd.x + i), (b[2] ? rnd.y - j : rnd.y + j)] = Space.taken;
                            }
                        }

                        k = edgeTiles.Count;
                        break;
                    }
                }

                if (k == edgeTiles.Count)
                {
                    break;
                }
            }
        }

        //do the corners
        shuffledCoords = new Queue <Coord>(Shuffle.ShuffleArray(cornerTiles.ToArray()));
        for (int k = 0; k < cornerTiles.Count; k++)
        {
            Coord rnd = GetRandomCoord();

            if (interior[rnd.x, rnd.y] != Space.corner)
            {
                continue;
            }

            for (int r = 0; r < 100; r++)
            {
                //take a random building object
                int     num  = /*temp % posibleBuildings.Length;*/ RandomNumber.Range(0, posibleBuildings.Length);
                Vector2 size = posibleBuildings[num].objectSize;

                if (!posibleBuildings[num].SpawnInCorner)
                {
                    continue;
                }

                bool[] b = FreeSpace(rnd.x, rnd.y, size);

                //if the building fits in the space
                if (b[0])
                {
                    GameObject h;
                    if (b[3])
                    {
                        //spawn that building in the space
                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                    }
                    else
                    {
                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                    }
                    //if (!b[3])
                    //{
                    //    h.transform.Rotate(posibleBuildings[num].rotationSide, -90f);
                    //}

                    if (animate)
                    {
                        Raise rise = h.AddComponent <Raise>();

                        rise.timeToWait = RandomNumber.Range(0f, 2f);//((x + y) / 4f) / 10f;
                        RunAnimation   += rise.StartRaise;
                    }

                    if (h.transform.childCount > 0)
                    {
                        BuildingVariation v = h.transform.GetChild(0).GetComponent <BuildingVariation>();
                        if (v)
                        {
                            v.roofColor = identifier.roof;
                            v.woodColor = identifier.wood;
                            v.Customize();
                        }
                    }


                    //assign all the tiles as taken
                    for (int i = 0; i < (b[3] ? size.x : size.y); i++)
                    {
                        for (int j = 0; j < (b[3] ? size.y : size.x); j++)
                        {
                            interior[(b[1] ? rnd.x - i : rnd.x + i), (b[2] ? rnd.y - j : rnd.y + j)] = Space.taken;
                        }
                    }
                }
            }
        }

        //spawn corrners
        //for (int x = 0; x < interior.GetLength(0); x++)
        //{
        //    for (int y = 0; y < interior.GetLength(1); y++)
        //    {
        //        if (interior[x, y] == Space.corner)
        //        {
        //            //try 100 times to get a house that fits in the space
        //            for (int r = 0; r < 100; r++)
        //            {
        //                //take a random building object
        //                int num = /*temp % posibleBuildings.Length;*/RandomNumber.Range(0, posibleBuildings.Length);
        //                Vector2 size = posibleBuildings[num].objectSize;

        //                if (!posibleBuildings[num].SpawnInCorner)
        //                    continue;

        //                bool[] b = FreeSpace(x, y, size);

        //                //if the building fits in the space
        //                if (b[0])
        //                {
        //                    GameObject h;
        //                    if (b[3])
        //                        //spawn that building in the space
        //                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                    else
        //                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                    //if (!b[3])
        //                    //{
        //                    //    h.transform.Rotate(posibleBuildings[num].rotationSide, -90f);
        //                    //}

        //                    Raise rise = h.AddComponent<Raise>();

        //                    rise.timeToWait = RandomNumber.Range(0f, 2f);//((x + y) / 4f) / 10f;
        //                    rise.StartRaise();

        //                    BuildingVariation v = h.transform.GetChild(0).GetComponent<BuildingVariation>();
        //                    if (v)
        //                    {
        //                        v.roofColor = identifier.roof;
        //                        v.woodColor = identifier.wood;
        //                        v.Customize();
        //                    }


        //                    //assign all the tiles as taken
        //                    for (int i = 0; i < (b[3] ? size.x : size.y); i++)
        //                    {
        //                        for (int j = 0; j < (b[3] ? size.y : size.x); j++)
        //                        {
        //                            interior[(b[1] ? x - i : x + i), (b[2] ? y - j : y + j)] = Space.taken;
        //                        }
        //                    }


        //                }
        //            }
        //        }
        //    }
        //}

        shuffledCoords = new Queue <Coord>(Shuffle.ShuffleArray(edgeTiles.ToArray()));
        //do the edges
        for (int k = 0; k < edgeTiles.Count; k++)
        {
            Coord rnd = GetRandomCoord();

            for (int r = 0; r < 100; r++)
            {
                //take a random building object
                int     num  = /*temp % posibleBuildings.Length;*/ RandomNumber.Range(0, posibleBuildings.Length);
                Vector2 size = posibleBuildings[num].objectSize;

                if (!posibleBuildings[num].SpawnsOnEdge)
                {
                    continue;
                }

                bool[] b = FreeSpace(rnd.x, rnd.y, size);

                //if the building fits in the space
                if (b[0])
                {
                    GameObject h;
                    if (b[3])
                    {
                        //spawn that building in the space
                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                    }
                    else
                    {
                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), (animate ? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                    }
                    //if (!b[3])
                    //{
                    //    h.transform.Rotate(posibleBuildings[num].rotationSide, 90f);
                    //}

                    if (animate)
                    {
                        Raise rise = h.AddComponent <Raise>();

                        rise.timeToWait = RandomNumber.Range(2f, 5f); //((x + y) / 4f) / 10f;
                        RunAnimation   += rise.StartRaise;
                    }

                    if (h.transform.childCount > 0)
                    {
                        BuildingVariation v = h.transform.GetChild(0).GetComponent <BuildingVariation>();

                        if (v)
                        {
                            v.roofColor = identifier.roof;
                            v.woodColor = identifier.wood;
                            v.Customize();
                        }
                    }


                    //assign all the tiles as taken
                    for (int i = 0; i < (b[3] ? size.x : size.y); i++)
                    {
                        for (int j = 0; j < (b[3] ? size.y : size.x); j++)
                        {
                            interior[(b[1] ? rnd.x - i : rnd.x + i), (b[2] ? rnd.y - j : rnd.y + j)] = Space.taken;
                        }
                    }
                }
            }
        }


        ////spawns edges
        //for (int x = 0; x < interior.GetLength(0); x++)
        //{
        //    for (int y = 0; y < interior.GetLength(1); y++)
        //    {

        //        if (interior[x, y] == Space.edge)
        //        {
        //            //try 100 times to get a house that fits in the space
        //            for (int r = 0; r < 100; r++)
        //            {
        //                //take a random building object
        //                int num = /*temp % posibleBuildings.Length;*/RandomNumber.Range(0, posibleBuildings.Length);
        //                Vector2 size = posibleBuildings[num].objectSize;

        //                if (!posibleBuildings[num].SpawnsOnEdge)
        //                    continue;

        //                bool[] b = FreeSpace(x, y, size);

        //                //if the building fits in the space
        //                if (b[0])
        //                {
        //                    GameObject h;
        //                    if (b[3])
        //                        //spawn that building in the space
        //                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                    else
        //                        h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                    //if (!b[3])
        //                    //{
        //                    //    h.transform.Rotate(posibleBuildings[num].rotationSide, 90f);
        //                    //}

        //                    Raise rise = h.AddComponent<Raise>();

        //                    rise.timeToWait = RandomNumber.Range(2f, 5f); //((x + y) / 4f) / 10f;
        //                    rise.StartRaise();

        //                    BuildingVariation v = h.transform.GetChild(0).GetComponent<BuildingVariation>();

        //                    if (v)
        //                    {
        //                        v.roofColor = identifier.roof;
        //                        v.woodColor = identifier.wood;
        //                        v.Customize();
        //                    }


        //                    //assign all the tiles as taken
        //                    for (int i = 0; i < (b[3] ? size.x : size.y); i++)
        //                    {
        //                        for (int j = 0; j < (b[3] ? size.y : size.x); j++)
        //                        {
        //                            interior[(b[1] ? x - i : x + i), (b[2] ? y - j : y + j)] = Space.taken;
        //                        }
        //                    }


        //                }
        //            }
        //        }
        //    }
        //}

        //if (globalBreeak > 20)
        //{
        //    Debug.Log("Broke", gameObject);
        //    yield break;
        //}

        //if (transform.childCount < 2 && globalBreeak < 20)
        //{
        //    globalBreeak++;
        //    Rebuild();
        //}

        //for (int k = 0; k < edgeTiles.Count; k++)
        //{
        //    Coord rnd = GetRandomCoord();

        //    if(interior[rnd.x, rnd.y] == Space.edge)
        //    {
        //        bool XRotate = false;
        //        if (rnd.x - 1 < 0 || rnd.x + 1 >= interior.GetLength(0))
        //            XRotate = true;
        //        if (!XRotate)
        //        {
        //            if (interior[rnd.x - 1, rnd.y] == Space.free || interior[rnd.x - 1, rnd.y] == Space.outside)
        //                XRotate = true;
        //            if(interior[rnd.x + 1, rnd.y] == Space.free || interior[rnd.x + 1, rnd.y] == Space.outside)
        //                XRotate = true;
        //        }
        //        Instantiate(VB.wall, new Vector3(rnd.x * 2.5f + MinX * 10f, 0, rnd.y * 2.5f + MinY * 10f), (XRotate ? Quaternion.Euler(new Vector3(0,-90,0)) : Quaternion.identity), transform);
        //    }
        //}

        if (functionType != Function.Ruin)
        {
            foreach (Coord c in interiorEdge)
            {
                if (interior[c.x, c.y] == Space.insideCorner)
                {
                    int sidesTaken = 0;
                    if (interior[c.x + 1, c.y] == Space.taken)
                    {
                        sidesTaken++;
                    }
                    if (interior[c.x - 1, c.y] == Space.taken)
                    {
                        sidesTaken++;
                    }
                    if (interior[c.x, c.y + 1] == Space.taken)
                    {
                        sidesTaken++;
                    }
                    if (interior[c.x, c.y - 1] == Space.taken)
                    {
                        sidesTaken++;
                    }

                    if (sidesTaken == 2)
                    {
                        GameObject h = Instantiate(VB.cornerWall, new Vector3(c.x * 2.5f + MinX * 10f, (animate? -25f:0), c.y * 2.5f + MinY * 10f), Quaternion.identity, transform);

                        if (animate)
                        {
                            Raise rise = h.AddComponent <Raise>();

                            rise.timeToWait = RandomNumber.Range(0f, 2f);//((x + y) / 4f) / 10f;
                            RunAnimation   += rise.StartRaise;
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
    public int CreateUnique(int bNum)
    {
        VillageBuildingList.Building[] posibleBuildings = VB.buildingList[VB.buildingList.Length - 1].buildings;
        int     num  = 0;
        Vector2 size = new Vector2(1, 1);

        if (bNum == 1 && Size > 150f)
        {
            return(0);
        }

        switch (bNum)
        {
        case 1:
            size = posibleBuildings[1].objectSize;
            num  = 1;
            break;

        case 2:
            size = posibleBuildings[2].objectSize;
            num  = 2;
            break;

        case 3:
            size = posibleBuildings[0].objectSize;
            num  = 0;
            break;
        }

        List <Coord> edges = new List <Coord>();

        for (int x = 0; x < interior.GetLength(0); x++)
        {
            for (int y = 0; y < interior.GetLength(1); y++)
            {
                if (interior[x, y] == Space.edge)
                {
                    edges.Add(new Coord(x, y));
                }
            }
        }

        int breakLoop = 0;

        shuffledCoords = new Queue <Coord>(Shuffle.ShuffleArray(edges.ToArray()));

        for (int k = 0; k < edges.Count; k++)
        {
            Coord rnd = GetRandomCoord();

            bool[] b = FreeSpace(rnd.x, rnd.y, size);

            //if the building fits in the space
            if (b[0])
            {
                GameObject h;
                if (b[3])
                {
                    //spawn that building in the space
                    h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), (animate? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                }
                else
                {
                    h = Instantiate(posibleBuildings[num].prefab, new Vector3(rnd.x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), (animate? -45 : 0), rnd.y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(rnd.x, rnd.y)), transform);
                }
                //if (!b[3])
                //{
                //    h.transform.Rotate(posibleBuildings[num].rotationSide, -90f);
                //}

                if (num == 2)
                {
                    h.name = "Barracks";
                }

                if (num == 1)
                {
                    functionType = Function.Castle;
                }

                if (animate)
                {
                    Raise rise = h.AddComponent <Raise>();

                    rise.timeToWait = RandomNumber.Range(0f, 2f);//((x + y) / 4f) / 10f;
                    RunAnimation   += rise.StartRaise;
                }

                BuildingVariation v = h.transform.GetChild(0).GetComponent <BuildingVariation>();
                if (v)
                {
                    v.roofColor = identifier.roof;
                    v.woodColor = identifier.wood;
                    v.Customize();
                }


                //assign all the tiles as taken
                for (int i = 0; i < (b[3] ? size.x : size.y); i++)
                {
                    for (int j = 0; j < (b[3] ? size.y : size.x); j++)
                    {
                        interior[(b[1] ? rnd.x - i : rnd.x + i), (b[2] ? rnd.y - j : rnd.y + j)] = Space.taken;
                    }
                }

                return(bNum);
            }

            if (breakLoop > 100)
            {
                return(-1);
            }
        }

        //for (int x = 0; x < interior.GetLength(0); x++)
        //{
        //    for (int y = 0; y < interior.GetLength(1); y++)
        //    {
        //        if ((interior[x, y] == Space.edge && posibleBuildings[num].SpawnsOnEdge) || (interior[x, y] == Space.corner && posibleBuildings[num].SpawnInCorner))
        //        {

        //            bool[] b = FreeSpace(x, y, size);

        //            //if the building fits in the space
        //            if (b[0])
        //            {
        //                GameObject h;
        //                if (b[3])
        //                    //spawn that building in the space
        //                    h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.x - (size.x % 2 == 1 ? .5f : 0) : size.x + (size.x % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0))) + (b[1] ? posibleBuildings[num].posX : posibleBuildings[num].negX), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                else
        //                    h = Instantiate(posibleBuildings[num].prefab, new Vector3(x * 2.5f + MinX * 10f + (b[1] ? -size.y + (size.y % 2 == 1 ? .5f : 0) : size.y - (size.y % 2 == 1 ? .5f : 0)), -45, y * 2.5f + MinY * 10f + (b[2] ? -size.x + (size.x % 2 == 1 ? .5f : 0) : size.x - (size.x % 2 == 1 ? .5f : 0))) + (b[2] ? posibleBuildings[num].posY : posibleBuildings[num].negY), Quaternion.Euler(FindEdgeDirection(x, y)), transform);
        //                //if (!b[3])
        //                //{
        //                //    h.transform.Rotate(posibleBuildings[num].rotationSide, -90f);
        //                //}

        //                Raise rise = h.AddComponent<Raise>();

        //                if (num == 1)
        //                    functionType = Function.Castle;

        //                rise.timeToWait = RandomNumber.Range(0f, 2f);//((x + y) / 4f) / 10f;
        //                rise.StartRaise();

        //                BuildingVariation v = h.transform.GetChild(0).GetComponent<BuildingVariation>();
        //                if (v)
        //                {
        //                    v.roofColor = identifier.roof;
        //                    v.woodColor = identifier.wood;
        //                    v.Customize();
        //                }


        //                //assign all the tiles as taken
        //                for (int i = 0; i < (b[3] ? size.x : size.y); i++)
        //                {
        //                    for (int j = 0; j < (b[3] ? size.y : size.x); j++)
        //                    {
        //                        interior[(b[1] ? x - i : x + i), (b[2] ? y - j : y + j)] = Space.taken;
        //                    }
        //                }

        //                return bNum;
        //            }
        //        }
        //    }
        //}

        return(0);
    }