public bool InThere(UIElement script, UserEvent user, Vector2 dot) { Vector3 os = Vector3.zero; float px = script.Pivot.x; os.x = (0.5f - px) * script.m_sizeDelta.x; float py = script.Pivot.y; os.y = (0.5f - py) * script.m_sizeDelta.y; var q = user.GlobalRotation; var o = user.GlobalPosition; Vector3 scale = user.GlobalScale; float w = Radius; if (w == 0) { w = script.m_sizeDelta.x; if (w > script.m_sizeDelta.y) { w = script.m_sizeDelta.y; } w *= 0.5f; w *= Ratio; } if (scale.x != scale.y) { float h = w * scale.y; w = w * scale.x; float rx = w; float lx = -rx; lx += os.x; rx += os.x; float ty = h; float dy = -ty; ty += os.y; dy += os.y; dot.x -= o.x; dot.y -= o.y; if (scale.x > scale.y) { Vector2 a = new Vector2(lx, os.y); a = q * a; Vector2 b = new Vector2(os.x, ty); b = q * b; Vector2 c = new Vector2(rx, os.y); c = q * c; if (InArc(ref a, ref b, ref c, ref dot)) { return(true); } b.x = os.x; b.y = dy; b = q * b; return(InArc(ref a, ref b, ref c, ref dot)); } else { Vector2 a = new Vector2(os.x, ty); a = q * a; Vector2 b = new Vector2(rx, os.y); b = q * b; Vector2 c = new Vector2(os.x, dy); c = q * c; if (InArc(ref a, ref b, ref c, ref dot)) { return(true); } b.x = lx; b.y = os.y; b = q * b; return(InArc(ref a, ref b, ref c, ref dot)); } } else { os = q * os; w *= scale.x; float x = dot.x - o.x - os.x; float y = dot.y - o.y - os.y; if (x * x + y * y < w * w) { return(true); } } return(false); }
/// <summary> /// 该用户事件是否存在焦点 /// </summary> /// <param name="eve">用户事件实例</param> /// <returns></returns> public bool ExistFocus(UserEvent eve) { return(MultiFocus.Contains(eve)); }
static void DuringSlide(UserEvent back) { if (back.mVelocity.x == 0 & back.mVelocity.y == 0) { return; } back.xTime += UserAction.TimeSlice; back.yTime += UserAction.TimeSlice; float x = 0, y = 0; bool endx = false, endy = false; if (back.mVelocity.x != 0) { float t = (float)MathH.PowDistance(back.DecayRateX, back.maxVelocity.x, back.xTime); x = t - back.lastX; back.lastX = t; float vx = Mathf.Pow(back.DecayRateX, back.xTime) * back.maxVelocity.x; if (vx <0.001f& vx> -0.001f) { back.mVelocity.x = 0; endx = true; } else { back.mVelocity.x = vx; } } if (back.mVelocity.y != 0) { float t = (float)MathH.PowDistance(back.DecayRateY, back.maxVelocity.y, back.yTime); y = t - back.lastY; back.lastY = t; float vy = Mathf.Pow(back.DecayRateY, back.yTime) * back.maxVelocity.y; if (vy <0.001f& vy> -0.001f) { back.mVelocity.y = 0; endy = true; } else { back.mVelocity.y = vy; } } if (back.Scrolling != null) { back.Scrolling(back, new Vector2(x, y)); } if (endx) { if (back.ScrollEndX != null) { back.ScrollEndX(back); } } if (endy) { if (back.ScrollEndY != null) { back.ScrollEndY(back); } } }