示例#1
0
    public void Start()
    {
        if(_instance==null)
            _instance = this;

        _cubes					= new List<VCube>();
        _reBuild				= new List<VCube>();
        _reBuildCollider		= new List<VCube>();
        _reBuildColliderCount	= 0;

        _map					= new byte[width+1, height+1, depth+1];
        _colors					= new Color[width+1, height+1, depth+1];

        // Instantiate all cube
        for(int x=0; x<width/RES; x++)
        for(int y=0; y<height/RES; y++)
        for(int z=0; z<depth/RES; z++)
        {
            Bounds cubeBounds = new Bounds();
            cubeBounds.min = new Vector3(x, y, z)*RES;
            cubeBounds.max = cubeBounds.min + new Vector3(RES, RES, RES);
            VCube cube = new VCube(cubeBounds, this);
            _cubes.Add(cube);
        }

        // Initialise all point in map
        ResetMap();
    }
示例#2
0
    /*
    private void BordMap()
    {
        for(int z=0; z<2       ; z++)
        for(int x=0; x<width +1; x++)
        for(int y=0; y<height+1; y++)
            _map[x,y,z*depth] = 255;
        for(int y=0; y<2       ; y++)
        for(int x=0; x<width +1; x++)
        for(int z=0; z<depth +1; z++)
            _map[x,y*height,z] = 255;
        for(int x=0; x<2       ; x++)
        for(int y=0; y<height+1; y++)
        for(int z=0; z<depth +1; z++)
            _map[x*width,y,z] = 255;
    }
    */
    // Rebuild this cube
    public void ReBuild(VCube cube)
    {
        // Add mesh to re build list
        if(!_reBuild.Contains(cube))
            _reBuild.Add(cube);

        // Add mesh collider to rebuild list
        if(!_reBuildCollider.Contains(cube))
            _reBuildCollider.Add(cube);
    }