예제 #1
0
    // Use this for initialization
    void Start()
    {
        space = new mSpace(0, 0, width - 1, height - 1);
        map   = new Tree(space);

        map = map.splitmSpace(space, splitTime);

        tm = TileMapManager.Instance;
        tm.Initialize(width, height);

        //Debug.Log(tm.GetTile(1, 2));
        //Tile test;
        //test = tm.GetTile(1, 2);
        //test.SetGroundInfo(EGround.Wall);
        Tree temp = map;

        drawPath(map, PathType.Wall);
        makeRoom(temp);
        drawSplitedSpace(temp);
        drawPath(map, PathType.Path);


        //drawPathBlock(map.root.mx, map.root.my);
        //Debug.Log(GetSpaceFromTree(map).root.x);
    }
예제 #2
0
    void drawStraitLine(mSpace a, mSpace b, PathType type)
    {
        //Debug.Log("A" + a.mx + " " + a.my + "B" + b.mx + " " + b.my);
        //int pathWidth = 1;
        if (a.mx == b.mx)
        {
            int start, end;
            if (a.my < b.my)
            {
                start = a.my;
                end   = b.my;
            }
            else
            {
                start = b.my;
                end   = a.my;
            }

            for (int i = start + 1; i < end; i++)
            {
                drawPathBlock(a.mx, i, type);

                /*Tile test;
                 * test = tm.GetTile(a.mx, i);
                 * test.SetGroundInfo(EGround.Water);*/
            }
        }
        else if (a.my == b.my)
        {
            int start, end;
            if (a.mx < b.mx)
            {
                start = a.mx;
                end   = b.mx;
            }
            else
            {
                start = b.my;
                end   = a.my;
            }

            for (int i = start; i < end; i++)
            {
                drawPathBlock(i, a.my, type);

                /*
                 * Tile test;
                 * test = tm.GetTile(i, a.my);
                 * test.SetGroundInfo(EGround.Water);
                 */
            }
        }
        else
        {
            Debug.Log("WEIRD POINT A" + a.mx + "," + a.my + " B:" + b.mx + "," + b.my);
        }
    }
예제 #3
0
    public Tree splitmSpace(mSpace space, int iter)
    {
        Tree rt = new Tree(space);

        if (iter != 0)
        {
            splitedmSpace asdf = new splitedmSpace(space);
            rt.childl = splitmSpace(asdf.first, iter - 1);
            rt.childr = splitmSpace(asdf.second, iter - 1);
        }
        return(rt);
    }
예제 #4
0
    public splitedmSpace(mSpace space)
    {
        float rate = (float)0.3;

        //if (space.w / space.h > 1.6 && )
        //if (random(0, 1) == 0)
        if (space.w / space.h > 0.95)
        {//세로
            this.first  = new mSpace(space.x, space.y, randomRatio(space.w, rate), space.h);
            this.second = new mSpace(first.x + first.w, space.y, space.w - first.w, space.h);
        }
        else
        {//가로
            this.first  = new mSpace(space.x, space.y, space.w, randomRatio(space.h, rate));
            this.second = new mSpace(space.x, first.y + first.h, space.w, space.h - first.h);
        }
    }
예제 #5
0
    void drawSpace(mSpace target)
    {
        Tile test;

        //Debug.Log(target.x + " " + target.y + " " + target.w + " " + target.h);

        for (int i = 0; i < target.h + 1; i++)
        {
            for (int j = 0; j < target.w + 1; j++)
            {
                if (i == 0 || i == target.h || j == 0 || j == target.w)
                {
                    test = TileMapManager.GetTile(new Coordinate(target.x + j, target.y + i));
                    test.SetGroundInfo(E_Ground.Wall);
                }
                else
                {
                    test = TileMapManager.GetTile(new Coordinate(target.x + j, target.y + i));
                    test.SetGroundInfo(E_Ground.Ground);
                }
            }
        }
    }
예제 #6
0
 public Tree(mSpace init)
 {
     root = init;
 }