Exemple #1
0
    private void CreateWalls(int x, int y)
    {
        for (int wallPosition = 0; wallPosition < 4; wallPosition++)
        {
            int  newX       = x;
            int  newY       = y;
            bool isEdge     = false;
            bool isVertical = false;
            switch (wallPosition)
            {
            case Constants.BOTTOM:
                isEdge = IsBottomOrLeftMostCell(y);
                if (!isEdge)
                {
                    continue;
                }
                break;

            case Constants.LEFT:
                isEdge = IsBottomOrLeftMostCell(x);
                if (!isEdge)
                {
                    continue;
                }
                isVertical = true;
                break;

            case Constants.RIGHT:
                newX       = x + 1;
                isEdge     = IsRightMostCell(x);
                isVertical = true;
                break;

            case Constants.TOP:
                newY   = y + 1;
                isEdge = IsTopCell(y);
                break;
            }

            var t    = _prefab.Instantiate(newX, newY, _parent, isVertical);
            var wall = new Wall(t, isEdge);
            //t.SetParent(_parent, false);
            AddWallToCell(x, y, wall, wallPosition, isEdge);
        }
    }