Пример #1
0
        Sliceable2D GetSlicerInZone()
        {
            foreach (Sliceable2D slicer in Sliceable2D.GetList())
            {
                if (slicer.limit.counter > 0)
                {
                    continue;
                }

                if (Math2D.PolyCollidePoly(slicer.shape.GetWorld(), GetAIZone()) == false)
                {
                    continue;
                }

                return(slicer);
            }

            return(null);
        }
Пример #2
0
        void OnGUI()
        {
            inspectorPosition = Vector3.zero;

            Vector2D pos = new Vector2D(Camera.main.ScreenToWorldPoint(UnityEngine.Input.mousePosition));

            foreach (Sliceable2D slicer in Sliceable2D.GetList())
            {
                Polygon2D poly = slicer.shape.GetWorld();
                if (poly.PointInPoly(pos))
                {
                    Rect rect = poly.GetBounds();

                    inspectorPosition = new Vector2(rect.center.x, rect.center.y + rect.height / 2);

                    originalSize = slicer.GetComponent <DemoSlicer2DInspectorTracker>().originalSize;
                    currentSize  = poly.GetArea();
                    sliced       = slicer.limit.counter;
                }
            }

            if (Vector3.zero == inspectorPosition)
            {
                return;
            }

            Vector2 p = Camera.main.WorldToScreenPoint(inspectorPosition);

            TextWithShadow(p.x, p.y, "Original Size: " + (int)originalSize + " (100%)");

            inspectorPosition.y += 1;
            p = Camera.main.WorldToScreenPoint(inspectorPosition);

            float currentSizePercent = (float)System.Math.Round((currentSize / originalSize) * 100);

            TextWithShadow(p.x, p.y, "Current Size: " + (int)currentSize + " (" + currentSizePercent + "%)");

            inspectorPosition.y += 1;
            p = Camera.main.WorldToScreenPoint(inspectorPosition);
            TextWithShadow(p.x, p.y, "Sliced: " + sliced + " times");
        }