Ejemplo n.º 1
0
    public void Draw()
    {
        if (DebugData.QuadtreeDrawAllRects)
        {
            EG_Debug.DrawRect(_rect, DRAW_QUAD_COLOR);
        }

        if (Time.frameCount - _lastActivityFrameNumber <= LAST_ACTIVITY_DRAW_MARGIN && DebugData.QuadtreeDrawTicks)
        {
            EG_Debug.DrawRect(_rect.Shrink(0.1f), DRAW_ACTIVITY_COLOR);
        }

        if (DebugData.QuadtreeDrawObjects)
        {
            for (int i = 0; i < _objects.Count; i++)
            {
                EG_Debug.DrawRect(_objects[i].Key, DRAW_OBJECT_COLOR);
            }
        }

        if (HasChildNodes)
        {
            _childNodes.Do(x => x.Draw());
        }
    }
    public virtual void Draw()
    {
        if (!DebugData.SpatialHashDrawAllBuckets && !DebugData.SpatialHashDrawTicks)
        {
            return;
        }

        foreach (Vector2 bucketPosition in _buckets.Keys)
        {
            Rect rect = new Rect(bucketPosition * CellSize, Vector2.one * CellSize);

            if (DebugData.SpatialHashDrawAllBuckets)
            {
                EG_Debug.DrawRect(rect, IdleBucketColor);
            }

            if (DebugData.SpatialHashDrawTicks)
            {
                EG_Debug.DrawRect(rect.Shrink(0.1f), UsedBucketColor);
            }
        }
    }
    public static void Draw()
    {
        if (DebugData.RegionsDrawAllBounds)
        {
            foreach (Region region in _regions)
            {
                EG_Debug.DrawRect(region.Bounds, Color.white);
            }
        }

        if (DebugData.RegionsDrawSelected)
        {
            Vector2 mousePosInWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (Contains(mousePosInWorld))
            {
                Region region = GetRegion(mousePosInWorld);

                EG_Debug.DrawText("----------SELECTED REGION----------\n" + region);

                foreach (int connection in region.Connections)
                {
                    EG_Debug.DrawText(connection + ": " + RegionConnectionManager.GetRegions(connection).Count());
                }

                foreach (Vector2 pos in region.OwnedPositions)
                {
                    EG_Debug.DrawSquare(new Rect(pos, Vector2.one), DEBUG_SELECTED_REGION_COLOR);
                }

                if (DebugData.RegionsDrawEntities)
                {
                    foreach (Entity entity in region.Entities)
                    {
                        EG_Debug.DrawRect(entity.Rect, DEBUG_REGION_ENTITY_COLOR);
                    }
                }

                if (DebugData.RegionsDrawNeighbors)
                {
                    foreach (Region neighbor in region.Neighbors)
                    {
                        foreach (Vector2 pos in neighbor.OwnedPositions)
                        {
                            EG_Debug.DrawSquare(new Rect(pos, Vector2.one), DEBUG_NEIGHBOR_REGION_COLOR);
                        }
                    }
                }

                if (DebugData.RegionsDrawEdges)
                {
                    foreach (Region.Connection connection in region.Connections)
                    {
                        Vector2 pos  = connection.Position;
                        Vector2 size = new Vector2((connection.Normal.x == 0) ? 1 : connection.Normal.x * connection.Length, (connection.Normal.y == 0) ? 1 : connection.Normal.y * connection.Length);

                        Rect rect = new Rect(pos, size);

                        EG_Debug.DrawSquare(rect, DEBUG_REGION_EDGE_COLOR);
                        EG_Debug.DrawRect(rect, Color.black);
                    }
                }
            }
        }
    }