示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (map2D == null || map2D.Width != width || map2D.Height != height || map2D.ElementSize != elementSize)
        {
            RecretaeMap();
        }

        if (go == null)
        {
            return;
        }
        var ab = go.GetComponent <AabbScript>();

        if (ab == null)
        {
            return;
        }

        if (!putted)
        {
            putted = true;
            map2D.Put(ab);
        }
        else
        {
            map2D.UpdatePos(ab);
        }
    }
示例#2
0
    private void RecretaeMap()
    {
        HashSet <IAabb> all = new HashSet <IAabb>();

        if (map2D != null)
        {
            all = map2D.GetIntersections(new FloatRect(0, 0, map2D.Width * map2D.ElementSize, map2D.Height * map2D.ElementSize));
        }
        map2D = new Map2D(width, height, elementSize);
        foreach (var a in all)
        {
            map2D.Put(a);
        }
    }