Beispiel #1
0
    public override void Activate()
    {
        m_view.SetStep(3);

        var boadRectTr = m_view.m_board.GetComponent <RectTransform>();

        Vector3[] corners = new Vector3[4];
        boadRectTr.GetWorldCorners(corners);

        var leftBottomWorld = Vu.XY(boadRectTr.TransformPoint(new Vector3(0, 3, 0)));
        var rightTopWorld   = Vu.XY(boadRectTr.TransformPoint(new Vector3(2, 5, 0)));

        var rect = new RectSides();

        rect.Left   = corners[0].x;
        rect.Right  = corners[2].x;
        rect.Top    = corners[2].y;
        rect.Bottom = corners[0].y;

        var size = rightTopWorld - leftBottomWorld;

        size.x /= m_view.m_board.m_rootCanvas.transform.localScale.x;
        size.y /= m_view.m_board.m_rootCanvas.transform.localScale.y;

        m_view.SetIndicatorTarget(leftBottomWorld, size);
    }
        public static void ButtonBorder(IControlPropertiesValue Params, DrawRect rect, Graphics graf)
        {
            var drawRect = rect.Rect;

            RectSides darkSides, brightSides;

            if (Params["Down"].AsBoolean())
            {
                brightSides = new RectSides()
                {
                    right = true, bottom = true
                };
                darkSides = new RectSides()
                {
                    left = true, top = true
                };
            }
            else
            {
                darkSides = new RectSides()
                {
                    right = true, bottom = true
                };
                brightSides = new RectSides()
                {
                    left = true, top = true
                };
            }
            DrawRectMethods.DrawRectangle(drawRect, graf, Params["Color"].AsColor().DarkColor(20), rect.BorderSize, Params["CornerRadius"].AsInteger(), darkSides);
            DrawRectMethods.DrawRectangle(drawRect, graf, Params["Color"].AsColor().BrightColor(20), rect.BorderSize, Params["CornerRadius"].AsInteger(), brightSides);
            DrawRectMethods.DrawRectangle(drawRect, graf, Params["Color"].AsColor().DarkColor(40), 1, Params["CornerRadius"].AsInteger(), darkSides);
            DrawRectMethods.DrawRectangle(drawRect, graf, Params["Color"].AsColor().DarkColor(10), 1, Params["CornerRadius"].AsInteger(), brightSides);
        }
Beispiel #3
0
    public RectSides RectFromCorners(Vector3[] corners)
    {
        var rect = new RectSides();

        rect.Left   = corners[0].x;
        rect.Right  = corners[2].x;
        rect.Top    = corners[2].y;
        rect.Bottom = corners[0].y;
        return(rect);
    }
Beispiel #4
0
    public static Rect Change(this Rect r, float value, RectSides sides)
    {
        float new_left = 0, new_top = 0, new_right = 0, new_bottom = 0;

        if (sides == RectSides.Left)
        {
            new_left = value;
        }
        if (sides == RectSides.Top)
        {
            new_top = value;
        }
        if (sides == RectSides.Right)
        {
            new_right = value;
        }
        if (sides == RectSides.Bottom)
        {
            new_bottom = value;
        }
        return(new Rect(r.xMin + new_left, r.yMin + new_top, r.width + new_right, r.height + new_bottom));
    }
Beispiel #5
0
        public static RectSides GetViolatedConstraints(Rect parentRect, Rect childRect)
        {
            RectSides rectSides = RectSides.None;

            if (childRect.Left > parentRect.Left && childRect.Right > parentRect.Right)
            {
                rectSides |= RectSides.Left;
            }
            if (childRect.Top > parentRect.Top && childRect.Bottom > parentRect.Bottom)
            {
                rectSides |= RectSides.Top;
            }
            if (childRect.Right < parentRect.Right && childRect.Left < parentRect.Left)
            {
                rectSides |= RectSides.Right;
            }
            if (childRect.Bottom < parentRect.Bottom && childRect.Top < parentRect.Top)
            {
                rectSides |= RectSides.Bottom;
            }
            return(rectSides);
        }
Beispiel #6
0
        public static RectSides GetViolatedConstraints(Rect parentRect, Rect childRect)
        {
            RectSides rectSides = RectSides.None;

            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            if (((Rect)@childRect).Left > ((Rect)@parentRect).Left && ((Rect)@childRect).Right > ((Rect)@parentRect).Right)
            {
                rectSides |= RectSides.Left;
            }
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            if (((Rect)@childRect).Top > ((Rect)@parentRect).Top && ((Rect)@childRect).Bottom > ((Rect)@parentRect).Bottom)
            {
                rectSides |= RectSides.Top;
            }
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            if (((Rect)@childRect).Right < ((Rect)@parentRect).Right && ((Rect)@childRect).Left < ((Rect)@parentRect).Left)
            {
                rectSides |= RectSides.Right;
            }
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            if (((Rect)@childRect).Bottom < ((Rect)@parentRect).Bottom && ((Rect)@childRect).Top < ((Rect)@parentRect).Top)
            {
                rectSides |= RectSides.Bottom;
            }
            return(rectSides);
        }
Beispiel #7
0
 public bool IsInside(RectSides insideRect)
 {
     return
         (IsInsideHori(insideRect) &&
          IsInsideVert(insideRect));
 }
Beispiel #8
0
 public bool IsInsideVert(RectSides insideRect)
 {
     return
         (Bottom <= insideRect.Bottom &&
          Top >= insideRect.Top);
 }
Beispiel #9
0
 public bool IsInsideHori(RectSides insideRect)
 {
     return
         (Left <= insideRect.Left &&
          Right >= insideRect.Right);
 }