コード例 #1
0
        private FloorUnit[] InitializeMap()
        {
            FloorUnit[] res = new FloorUnit[numOfChunk];

            int cnt = 0;

            for (int i = 0; i < maxX; i++)
            {
                for (int j = 0; j < maxZ; j++)
                {
                    if (combineMesh.IsChunkExists(i, j))
                    {
                        res[cnt]   = new FloorUnit();
                        res[cnt].x = i;
                        res[cnt].z = j;
                        cnt++;
                    }
                }
            }

            return(res);
        }
コード例 #2
0
    private FloorUnit[] InitializeMap()
    {
        LinkedList <Transform> flo   = new LinkedList <Transform>();
        LinkedList <Transform> other = new LinkedList <Transform>();

        //FloorUnit[,] temp=new FloorUnit[FloorMaker.wnum,FloorMaker.dnum];
        GetAllChildren(this.gameObject.transform, flo, other);
        //Debug.Log(flo.Count);

        FloorUnit[,] cubeSpace = new FloorUnit[120, 120];
        int count = 0;

        foreach (var cube in flo)
        {
            int x = Mathf.FloorToInt(cube.position.x);
            int z = Mathf.FloorToInt(cube.position.z);
            if (cubeSpace[x, z] == null)
            {
                count++;
                FloorUnit unit = new FloorUnit();
                unit.obj  = cube.gameObject;
                unit.list = new LinkedList <GameObject>();
                unit.list.AddFirst(new LinkedListNode <GameObject>(cube.gameObject));
                cubeSpace[x, z] = unit;
            }
        }
        foreach (var cube in other)
        {
            int x = Mathf.FloorToInt(cube.position.x);
            int z = Mathf.FloorToInt(cube.position.z);
            if (cubeSpace[x, z] != null)
            {
                cubeSpace[x, z].list.AddLast(new LinkedListNode <GameObject>(cube.gameObject));
            }
        }
        //Debug.Log(count);
        FloorUnit[] res   = new FloorUnit[count];
        int         index = 0;

        for (int i = 0; i < 120; i++)
        {
            for (int j = 0; j < 120; j++)
            {
                if (cubeSpace[i, j] != null)
                {
                    res[index++] = cubeSpace[i, j];
                }
            }
        }
        Debug.Log(index);

        //int x, z;

        //foreach (Transform t in flo) {
        //	x = Mathf.FloorToInt ((t.position.x-FloorMaker.offset)/FloorMaker.floorUnitSize);
        //	z = Mathf.FloorToInt ((t.position.z-FloorMaker.offset)/FloorMaker.floorUnitSize);
        //	if (temp [x, z] == null) {
        //		temp[x,z]=new FloorUnit{
        //			obj=t.gameObject,
        //			list=new LinkedList<GameObject>()
        //		};
        //		temp [x, z].list.AddLast (t.gameObject);
        //	}

        //}

        //foreach (Transform t in other) {
        //	x = Mathf.FloorToInt (t.position.x/FloorMaker.floorUnitSize);
        //	z = Mathf.FloorToInt (t.position.z/FloorMaker.floorUnitSize);
        //	temp [x, z].list.AddLast(t.gameObject);
        //}

        //int num = 0;
        //foreach (Transform t in flo) {
        //	x = Mathf.FloorToInt ((t.position.x-FloorMaker.offset)/FloorMaker.floorUnitSize);
        //	z = Mathf.FloorToInt ((t.position.z-FloorMaker.offset)/FloorMaker.floorUnitSize);
        //	res[num] = temp [x, z];
        //	num++;
        //}

        return(res);
    }