Example #1
0
    private IEnumerator Start()
    {
        unityQuadtree = new UnityQuadtree(Vector2.zero, new Vector2(10, 10))
        {
            MaxLevel = 3
        };

        unityQuadtree.Expand();
        unityQuadtree.Children[2].Expand();
        unityQuadtree.Children[3].Expand();
        unityQuadtree.Children[3].Children[1].Expand();

        yield return(StartCoroutine(CalculateNeighbourDifferences()));

        Debug.Log(unityQuadtree.Children[3].Children[1].Children[3].LocationCodeString + " <- " + Quadtree.BinaryToDecimal(unityQuadtree.Children[3].Children[1].Children[3].NeighbourLocationCode(Direction.West),
                                                                                                                           unityQuadtree.MaxLevel));
    }
Example #2
0
 public UnityQuadtree(UnityQuadtree parent, Quadrant quadrant) : base(parent, quadrant)
 {
     Size     = parent.Size / 2;
     Position = parent.Position + new Vector2Int((int)quadrant >> 1 & 1, (int)quadrant & 1) * Size;
 }