Пример #1
0
    public void Init(Vector3Int size)
    {
        this.Size = size;
        items     = new List <ItemObject>();
        space     = new Dictionary <int, List <ItemObject> >();

        floor = transform.Find("floor").GetComponent <Floor>();
        floor.Init(new Vector2Int(size.x, size.z));

        walls    = new Wall[4];
        pillarsV = new Pillar[4];
        pillarsH = new Pillar[4];
        for (int i = 0; i < 4; i++)
        {
            Wall       wall     = transform.Find("wall_" + wallNames[i]).GetComponent <Wall>();
            Direction  dir      = wallDirections[i];
            int        x        = (int)Mathf.Abs(Vector3.Dot(dir.Vector, size));
            Vector2Int wallSize = new Vector2Int(x, size.y);
            wall.Init(wallSize, dir);
            walls[i] = wall;

            Pillar pillarV = transform.Find("v_" + wallNames[i]).GetComponent <Pillar>();
            pillarV.Init();
            pillarsV[i] = pillarV;

            Pillar pillarH = transform.Find("h_" + wallNames[i]).GetComponent <Pillar>();
            pillarH.Init();
            pillarsH[i] = pillarH;
        }

        // showWalls
        showWalls = new int[2];
    }
Пример #2
0
    private void GeneratePillars()
    {
        if (pillars == null)
        {
            return;
        }

        int i = 0;

        foreach (BoardPillar pillar in pillars)
        {
            Vector3 pos = position + new Vector3(pillar.pos.x * posOffset, 0, pillar.pos.y * posOffset);

            GameObject pillarObj = null;
            if (pillar.type == BoardPillarType.Regular)
            {
                pillarObj = (GameObject)Instantiate(regularPillar, pos, Quaternion.identity);
            }
            else if (pillar.type == BoardPillarType.Key)
            {
                pillarObj = (GameObject)Instantiate(keyPillar, pos, Quaternion.identity);
            }

            Pillar pillarScript = pillarObj.GetComponent <Pillar>();
            pillarScript.Init(this, i, pillar.pos);
            i++;
        }
    }