using System; using UnityEngine; using UnityEngine.UI; public class LTDescrImpl : LTDescr { private uint _id; internal new Vector3 fromInternal; internal new Vector3 toInternal; internal Vector3 diffInternal; public new RectTransform rectTransform; public new Text uiText; public new Image uiImage; public new Sprite[] sprites; private static uint global_counter; public new bool toggle { get; set; } public new bool useEstimatedTime { get; set; } public new bool useFrames { get; set; } public new bool useManualTime { get; set; } public new bool hasInitiliazed { get; set; } public new bool hasPhysics { get; set; } public new bool onCompleteOnRepeat { get; set; } public new bool onCompleteOnStart { get; set; } public new bool useRecursion { get; set; } public new float passed { get; set; } public new float delay { get; set; } public new float time { get; set; } public new float lastVal { get; set; } public new int loopCount { get; set; } public new uint counter { get; set; } public new float direction { get; set; } public new float directionLast { get; set; } public new float overshoot { get; set; } public new float period { get; set; } public new bool destroyOnComplete { get; set; } public new Transform trans { get; set; } public Transform toTrans { get; set; } public new LTRect ltRect { get; set; } public new Vector3 from { get { return fromInternal; } set { fromInternal = value; } } public new Vector3 to { get { return toInternal; } set { toInternal = value; } } public new Vector3 diff { get { return diffInternal; } set { diffInternal = value; } } public Vector3 point { get; set; } public Vector3 axis { get; set; } public Quaternion origRotation { get; set; } public LTBezierPath path { get; set; } public LTSpline spline { get; set; } public new TweenAction type { get; set; } public new LeanTweenType tweenType { get; set; } public AnimationCurve animationCurve { get; set; } public new LeanTweenType loopType { get; set; } public new bool hasUpdateCallback { get; set; } public Action onUpdateFloat { get; set; } public Action onUpdateFloatRatio { get; set; } public Action onUpdateFloatObject { get; set; } public Action onUpdateVector2 { get; set; } public Action onUpdateVector3 { get; set; } public Action onUpdateVector3Object { get; set; } public Action onUpdateColor { get; set; } public Action onComplete { get; set; } public Action onCompleteObject { get; set; } public object onCompleteParam { get; set; } public object onUpdateParam { get; set; } public Action onStart { get; set; } public new int uniqueId { get { return (int)(_id | (counter << 16)); } } public new int id { get { return uniqueId; } } public override string ToString() { return string.Concat((!(trans != null)) ? "gameObject:null" : ("gameObject:" + trans.gameObject), " toggle:", toggle, " passed:", passed, " time:", time, " delay:", delay, " direction:", direction, " from:", from, " to:", to, " type:", type, " ease:", tweenType, " useEstimatedTime:", useEstimatedTime, " id:", id, " hasInitiliazed:", hasInitiliazed); } [Obsolete("Use 'LeanTween.cancel( id )' instead")] public new LTDescr cancel(GameObject gameObject) { if (gameObject == trans.gameObject) { LeanTween.removeTween((int)_id, uniqueId); } return this; } public new void reset() { bool flag = (useRecursion = true); toggle = flag; trans = null; float num = (lastVal = 0f); num = (delay = num); passed = num; flag = (useManualTime = false); flag = (onCompleteOnStart = flag); flag = (destroyOnComplete = flag); flag = (onCompleteOnRepeat = flag); flag = (hasInitiliazed = flag); flag = (useFrames = flag); flag = (useEstimatedTime = flag); hasUpdateCallback = flag; animationCurve = null; tweenType = LeanTweenType.linear; loopType = LeanTweenType.once; loopCount = 0; num = (overshoot = 1f); num = (directionLast = num); direction = num; period = 0.3f; point = Vector3.zero; cleanup(); global_counter++; if (global_counter > 32768) { global_counter = 0u; } } public void cleanup() { onUpdateFloat = null; onUpdateFloatRatio = null; onUpdateVector2 = null; onUpdateVector3 = null; onUpdateFloatObject = null; onUpdateVector3Object = null; onUpdateColor = null; onComplete = null; onCompleteObject = null; onCompleteParam = null; onStart = null; rectTransform = null; uiText = null; uiImage = null; sprites = null; } public void init() { hasInitiliazed = true; if (onStart != null) { onStart(); } switch (type) { case TweenAction.MOVE: case TweenAction.MOVE_TO_TRANSFORM: from = trans.position; break; case TweenAction.MOVE_X: fromInternal.x = trans.position.x; break; case TweenAction.MOVE_Y: fromInternal.x = trans.position.y; break; case TweenAction.MOVE_Z: fromInternal.x = trans.position.z; break; case TweenAction.MOVE_LOCAL_X: fromInternal.x = trans.localPosition.x; break; case TweenAction.MOVE_LOCAL_Y: fromInternal.x = trans.localPosition.y; break; case TweenAction.MOVE_LOCAL_Z: fromInternal.x = trans.localPosition.z; break; case TweenAction.SCALE_X: fromInternal.x = trans.localScale.x; break; case TweenAction.SCALE_Y: fromInternal.x = trans.localScale.y; break; case TweenAction.SCALE_Z: fromInternal.x = trans.localScale.z; break; case TweenAction.ALPHA: { SpriteRenderer component2 = trans.gameObject.GetComponent(); if (component2 != null) { fromInternal.x = component2.color.a; } else if (trans.gameObject.GetComponent() != null && trans.gameObject.GetComponent().material.HasProperty("_Color")) { fromInternal.x = trans.gameObject.GetComponent().material.color.a; } else if (trans.gameObject.GetComponent() != null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")) { Color color5 = trans.gameObject.GetComponent().material.GetColor("_TintColor"); fromInternal.x = color5.a; } else { if (trans.childCount <= 0) { break; } foreach (Transform tran in trans) { if (tran.gameObject.GetComponent() != null) { Color color6 = tran.gameObject.GetComponent().material.color; fromInternal.x = color6.a; break; } } } break; } case TweenAction.MOVE_LOCAL: from = trans.localPosition; break; case TweenAction.MOVE_CURVED: case TweenAction.MOVE_CURVED_LOCAL: case TweenAction.MOVE_SPLINE: case TweenAction.MOVE_SPLINE_LOCAL: fromInternal.x = 0f; break; case TweenAction.ROTATE: from = trans.eulerAngles; to = new Vector3(LeanTween.closestRot(fromInternal.x, toInternal.x), LeanTween.closestRot(from.y, to.y), LeanTween.closestRot(from.z, to.z)); break; case TweenAction.ROTATE_X: fromInternal.x = trans.eulerAngles.x; toInternal.x = LeanTween.closestRot(fromInternal.x, toInternal.x); break; case TweenAction.ROTATE_Y: fromInternal.x = trans.eulerAngles.y; toInternal.x = LeanTween.closestRot(fromInternal.x, toInternal.x); break; case TweenAction.ROTATE_Z: fromInternal.x = trans.eulerAngles.z; toInternal.x = LeanTween.closestRot(fromInternal.x, toInternal.x); break; case TweenAction.ROTATE_AROUND: lastVal = 0f; fromInternal.x = 0f; origRotation = trans.rotation; break; case TweenAction.ROTATE_AROUND_LOCAL: lastVal = 0f; fromInternal.x = 0f; origRotation = trans.localRotation; break; case TweenAction.ROTATE_LOCAL: from = trans.localEulerAngles; to = new Vector3(LeanTween.closestRot(fromInternal.x, toInternal.x), LeanTween.closestRot(from.y, to.y), LeanTween.closestRot(from.z, to.z)); break; case TweenAction.SCALE: from = trans.localScale; break; case TweenAction.GUI_MOVE: from = new Vector3(ltRect.rect.x, ltRect.rect.y, 0f); break; case TweenAction.GUI_MOVE_MARGIN: from = new Vector2(ltRect.margin.x, ltRect.margin.y); break; case TweenAction.GUI_SCALE: from = new Vector3(ltRect.rect.width, ltRect.rect.height, 0f); break; case TweenAction.GUI_ALPHA: fromInternal.x = ltRect.alpha; break; case TweenAction.GUI_ROTATE: if (!ltRect.rotateEnabled) { ltRect.rotateEnabled = true; ltRect.resetForRotation(); } fromInternal.x = ltRect.rotation; break; case TweenAction.ALPHA_VERTEX: fromInternal.x = (int)trans.GetComponent().mesh.colors32[0].a; break; case TweenAction.CALLBACK_COLOR: diff = new Vector3(1f, 0f, 0f); break; case TweenAction.COLOR: { SpriteRenderer component = trans.gameObject.GetComponent(); if (component != null) { Color color = component.color; setFromColor(color); } else if (trans.gameObject.GetComponent() != null && trans.gameObject.GetComponent().material.HasProperty("_Color")) { Color color2 = trans.gameObject.GetComponent().material.color; setFromColor(color2); } else if (trans.gameObject.GetComponent() != null && trans.gameObject.GetComponent().material.HasProperty("_TintColor")) { Color color3 = trans.gameObject.GetComponent().material.GetColor("_TintColor"); setFromColor(color3); } else { if (trans.childCount <= 0) { break; } foreach (Transform tran2 in trans) { if (tran2.gameObject.GetComponent() != null) { Color color4 = tran2.gameObject.GetComponent().material.color; setFromColor(color4); break; } } } break; } case TweenAction.CANVAS_ALPHA: uiImage = trans.gameObject.GetComponent(); if (uiImage != null) { fromInternal.x = uiImage.color.a; } else { fromInternal.x = 1f; } break; case TweenAction.CANVAS_COLOR: uiImage = trans.gameObject.GetComponent(); if (uiImage != null) { setFromColor(uiImage.color); } else { setFromColor(Color.white); } break; case TweenAction.CANVASGROUP_ALPHA: fromInternal.x = trans.gameObject.GetComponent().alpha; break; case TweenAction.TEXT_ALPHA: uiText = trans.gameObject.GetComponent(); if (uiText != null) { fromInternal.x = uiText.color.a; } else { fromInternal.x = 1f; } break; case TweenAction.TEXT_COLOR: uiText = trans.gameObject.GetComponent(); if (uiText != null) { setFromColor(uiText.color); } else { setFromColor(Color.white); } break; case TweenAction.CANVAS_MOVE: fromInternal = rectTransform.anchoredPosition3D; break; case TweenAction.CANVAS_MOVE_X: fromInternal.x = rectTransform.anchoredPosition3D.x; break; case TweenAction.CANVAS_MOVE_Y: fromInternal.x = rectTransform.anchoredPosition3D.y; break; case TweenAction.CANVAS_MOVE_Z: fromInternal.x = rectTransform.anchoredPosition3D.z; break; case TweenAction.CANVAS_ROTATEAROUND: case TweenAction.CANVAS_ROTATEAROUND_LOCAL: lastVal = 0f; fromInternal.x = 0f; origRotation = rectTransform.rotation; break; case TweenAction.CANVAS_SCALE: from = rectTransform.localScale; break; case TweenAction.CANVAS_PLAYSPRITE: uiImage = trans.gameObject.GetComponent(); fromInternal.x = 0f; break; } if (type != TweenAction.CALLBACK_COLOR && type != TweenAction.COLOR && type != TweenAction.TEXT_COLOR && type != TweenAction.CANVAS_COLOR) { diff = to - from; } if (onCompleteOnStart) { if (onComplete != null) { onComplete(); } else if (onCompleteObject != null) { onCompleteObject(onCompleteParam); } } } public new LTDescr setFromColor(Color col) { from = new Vector3(0f, col.a, 0f); diff = new Vector3(1f, 0f, 0f); axis = new Vector3(col.r, col.g, col.b); return this; } public new LTDescr pause() { if (direction != 0f) { directionLast = direction; direction = 0f; } return this; } public new LTDescr resume() { direction = directionLast; return this; } public new LTDescr setAxis(Vector3 axis) { this.axis = axis; return this; } public new LTDescr setDelay(float delay) { if (useEstimatedTime) { this.delay = delay; } else { this.delay = delay; } return this; } public new LTDescr setEase(LeanTweenType easeType) { tweenType = easeType; return this; } public new LTDescr setOvershoot(float overshoot) { this.overshoot = overshoot; return this; } public new LTDescr setPeriod(float period) { this.period = period; return this; } public new LTDescr setEase(AnimationCurve easeCurve) { animationCurve = easeCurve; return this; } public new LTDescr setTo(Vector3 to) { if (hasInitiliazed) { this.to = to; diff = to - from; } else { this.to = to; } return this; } public new LTDescr setTo(Transform to) { toTrans = to; return this; } public new LTDescr setFrom(Vector3 from) { if ((bool)trans) { init(); } this.from = from; diff = to - this.from; return this; } public new LTDescr setFrom(float from) { return setFrom(new Vector3(from, 0f, 0f)); } public new LTDescr setDiff(Vector3 diff) { this.diff = diff; return this; } public new LTDescr setHasInitialized(bool has) { hasInitiliazed = has; return this; } public new LTDescr setId(uint id) { _id = id; counter = global_counter; return this; } public new LTDescr setTime(float time) { float num = passed / this.time; passed = time * num; this.time = time; return this; } public new LTDescr setRepeat(int repeat) { loopCount = repeat; if ((repeat > 1 && loopType == LeanTweenType.once) || (repeat < 0 && loopType == LeanTweenType.once)) { loopType = LeanTweenType.clamp; } if (type == TweenAction.CALLBACK || type == TweenAction.CALLBACK_COLOR) { setOnCompleteOnRepeat(true); } return this; } public new LTDescr setLoopType(LeanTweenType loopType) { this.loopType = loopType; return this; } public new LTDescr setUseEstimatedTime(bool useEstimatedTime) { this.useEstimatedTime = useEstimatedTime; return this; } public new LTDescr setIgnoreTimeScale(bool useUnScaledTime) { useEstimatedTime = useUnScaledTime; return this; } public new LTDescr setUseFrames(bool useFrames) { this.useFrames = useFrames; return this; } public new LTDescr setUseManualTime(bool useManualTime) { this.useManualTime = useManualTime; return this; } public new LTDescr setLoopCount(int loopCount) { this.loopCount = loopCount; return this; } public new LTDescr setLoopOnce() { loopType = LeanTweenType.once; return this; } public new LTDescr setLoopClamp() { loopType = LeanTweenType.clamp; if (loopCount == 0) { loopCount = -1; } return this; } public new LTDescr setLoopClamp(int loops) { loopCount = loops; return this; } public new LTDescr setLoopPingPong() { loopType = LeanTweenType.pingPong; if (loopCount == 0) { loopCount = -1; } return this; } public new LTDescr setLoopPingPong(int loops) { loopType = LeanTweenType.pingPong; loopCount = ((loops != -1) ? (loops * 2) : loops); return this; } public new LTDescr setOnComplete(Action onComplete) { this.onComplete = onComplete; return this; } public new LTDescr setOnComplete(Action onComplete) { onCompleteObject = onComplete; return this; } public new LTDescr setOnComplete(Action onComplete, object onCompleteParam) { onCompleteObject = onComplete; if (onCompleteParam != null) { this.onCompleteParam = onCompleteParam; } return this; } public new LTDescr setOnCompleteParam(object onCompleteParam) { this.onCompleteParam = onCompleteParam; return this; } public new LTDescr setOnUpdate(Action onUpdate) { onUpdateFloat = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdateRatio(Action onUpdate) { onUpdateFloatRatio = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdateObject(Action onUpdate) { onUpdateFloatObject = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdateVector2(Action onUpdate) { onUpdateVector2 = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdateVector3(Action onUpdate) { onUpdateVector3 = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdateColor(Action onUpdate) { onUpdateColor = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdate(Action onUpdate) { onUpdateColor = onUpdate; hasUpdateCallback = true; return this; } public new LTDescr setOnUpdate(Action onUpdate, object onUpdateParam = null) { onUpdateFloatObject = onUpdate; hasUpdateCallback = true; if (onUpdateParam != null) { this.onUpdateParam = onUpdateParam; } return this; } public new LTDescr setOnUpdate(Action onUpdate, object onUpdateParam = null) { onUpdateVector3Object = onUpdate; hasUpdateCallback = true; if (onUpdateParam != null) { this.onUpdateParam = onUpdateParam; } return this; } public new LTDescr setOnUpdate(Action onUpdate, object onUpdateParam = null) { onUpdateVector2 = onUpdate; hasUpdateCallback = true; if (onUpdateParam != null) { this.onUpdateParam = onUpdateParam; } return this; } public new LTDescr setOnUpdate(Action onUpdate, object onUpdateParam = null) { onUpdateVector3 = onUpdate; hasUpdateCallback = true; if (onUpdateParam != null) { this.onUpdateParam = onUpdateParam; } return this; } public new LTDescr setOnUpdateParam(object onUpdateParam) { this.onUpdateParam = onUpdateParam; return this; } public new LTDescr setOrientToPath(bool doesOrient) { if (type == TweenAction.MOVE_CURVED || type == TweenAction.MOVE_CURVED_LOCAL) { if (path == null) { path = new LTBezierPath(); } path.orientToPath = doesOrient; } else { spline.orientToPath = doesOrient; } return this; } public new LTDescr setOrientToPath2d(bool doesOrient2d) { setOrientToPath(doesOrient2d); if (type == TweenAction.MOVE_CURVED || type == TweenAction.MOVE_CURVED_LOCAL) { path.orientToPath2d = doesOrient2d; } else { spline.orientToPath2d = doesOrient2d; } return this; } public new LTDescr setRect(LTRect rect) { ltRect = rect; return this; } public new LTDescr setRect(Rect rect) { ltRect = new LTRect(rect); return this; } public new LTDescr setPath(LTBezierPath path) { this.path = path; return this; } public new LTDescr setPoint(Vector3 point) { this.point = point; return this; } public new LTDescr setDestroyOnComplete(bool doesDestroy) { destroyOnComplete = doesDestroy; return this; } public new LTDescr setAudio(object audio) { onCompleteParam = audio; return this; } public new LTDescr setOnCompleteOnRepeat(bool isOn) { onCompleteOnRepeat = isOn; return this; } public new LTDescr setOnCompleteOnStart(bool isOn) { onCompleteOnStart = isOn; return this; } public new LTDescr setRect(RectTransform rect) { rectTransform = rect; return this; } public new LTDescr setSprites(Sprite[] sprites) { this.sprites = sprites; return this; } public new LTDescr setFrameRate(float frameRate) { time = (float)sprites.Length / frameRate; return this; } public new LTDescr setOnStart(Action onStart) { this.onStart = onStart; return this; } public new LTDescr setDirection(float direction) { if (this.direction != -1f && this.direction != 1f) { Debug.LogWarning("You have passed an incorrect direction of '" + direction + "', direction must be -1f or 1f"); return this; } if (this.direction != direction) { if (hasInitiliazed) { this.direction = direction; } else if (path != null) { path = new LTBezierPath(LTUtility.reverse(path.pts)); } else if (spline != null) { spline = new LTSpline(LTUtility.reverse(spline.pts)); } } return this; } public new LTDescr setRecursive(bool useRecursion) { this.useRecursion = useRecursion; return this; } }