static public int set_hook2(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); FairyGUI.TransitionHook v; int op = LuaDelegation.checkDelegate(l, 2, out v); if (op == 0) { self.hook2 = v; } else if (op == 1) { self.hook2 += v; } else if (op == 2) { self.hook2 -= v; } pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_completed(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); pushValue(l, true); pushValue(l, self.completed); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_type(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); pushValue(l, true); pushEnum(l, (int)self.type); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { FairyGUI.TransitionItem o; o = new FairyGUI.TransitionItem(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_completed(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); System.Boolean v; checkType(l, 2, out v); self.completed = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_tweener(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); DG.Tweening.Tween v; checkType(l, 2, out v); self.tweener = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_targetId(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); System.String v; checkType(l, 2, out v); self.targetId = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_repeat(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); System.Int32 v; checkType(l, 2, out v); self.repeat = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int __Shake(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); System.Object a1; checkType(l, 2, out a1); self.__Shake(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_endValue(IntPtr l) { try { FairyGUI.TransitionItem self = (FairyGUI.TransitionItem)checkSelf(l); FairyGUI.TransitionValue v; checkType(l, 2, out v); self.endValue = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
void StopItem(TransitionItem item, bool setToComplete) { if (item.displayLockToken != 0) { item.target.ReleaseDisplayLock(item.displayLockToken); item.displayLockToken = 0; } if (item.type == TransitionActionType.ColorFilter && item.filterCreated) { item.target.filter = null; } if (item.completed) { return; } if (item.tweener != null) { item.tweener.Kill(); item.tweener = null; } if (item.type == TransitionActionType.Transition) { Transition trans = ((GComponent)item.target).GetTransition(item.value.s); if (trans != null) { trans.Stop(setToComplete, false); } } else if (item.type == TransitionActionType.Shake) { if (Timers.inst.Exists(item.__Shake)) { Timers.inst.Remove(item.__Shake); item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1, item.target.y - item.startValue.f2); item.target._gearLocked = false; } } else { if (setToComplete) { if (item.tween) { if (!item.yoyo || item.repeat % 2 == 0) { ApplyValue(item, _reversed ? item.startValue : item.endValue); } else { ApplyValue(item, _reversed ? item.endValue : item.startValue); } } else if (item.type != TransitionActionType.Sound) { ApplyValue(item, item.value); } } } }
public void Setup(XML xml) { this.name = xml.GetAttribute("name"); _options = xml.GetAttributeInt("options"); this.autoPlay = xml.GetAttributeBool("autoPlay"); if (this.autoPlay) { this.autoPlayRepeat = xml.GetAttributeInt("autoPlayRepeat", 1); this.autoPlayDelay = xml.GetAttributeFloat("autoPlayDelay"); } XMLList col = xml.Elements("item"); foreach (XML cxml in col) { TransitionItem item = new TransitionItem(); _items.Add(item); item.time = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE; item.targetId = cxml.GetAttribute("target", string.Empty); item.type = FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type")); item.tween = cxml.GetAttributeBool("tween"); item.label = cxml.GetAttribute("label"); if (item.tween) { item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE; if (item.time + item.duration > _maxTime) _maxTime = item.time + item.duration; string ease = cxml.GetAttribute("ease"); if (ease != null) item.easeType = FieldTypes.ParseEaseType(ease); item.repeat = cxml.GetAttributeInt("repeat"); item.yoyo = cxml.GetAttributeBool("yoyo"); item.label2 = cxml.GetAttribute("label2"); string v = cxml.GetAttribute("endValue"); if (v != null) { DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue); DecodeValue(item.type, v, item.endValue); } else { item.tween = false; DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value); } } else { if (item.time > _maxTime) _maxTime = item.time; DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value); } } }
void InternalPlay(float delay) { _ownerBaseX = _owner.x; _ownerBaseY = _owner.y; _totalTasks = 0; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.targetId.Length > 0) { item.target = _owner.GetChildById(item.targetId); } else { item.target = _owner; } if (item.target == null) { continue; } float startTime = delay + item.time; if (item.tween) { item.completed = false; switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: _totalTasks++; if (startTime == 0) { StartTween(item); } else { item.value.f3 = 1; item.tweener = DOVirtual.DelayedCall(startTime, () => { item.tweener = null; StartTween(item); }); } break; case TransitionActionType.Scale: _totalTasks++; item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, new Vector2(item.endValue.f1, item.endValue.f2), item.duration) .SetEase(item.easeType) .OnStart(() => { if (item.hook != null) { item.hook(); } }) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (startTime > 0) { item.tweener.SetDelay(startTime); } else { ApplyValue(item, item.value); } if (item.repeat > 0) { item.tweener.SetLoops(item.repeat + 1, item.yoyo ? LoopType.Yoyo : LoopType.Restart); } break; case TransitionActionType.Alpha: _totalTasks++; item.value.f1 = item.startValue.f1; item.tweener = DOTween.To(() => item.value.f1, v => item.value.f1 = v, item.endValue.f1, item.duration) .SetEase(item.easeType) .OnStart(() => { if (item.hook != null) { item.hook(); } }) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (startTime > 0) { item.tweener.SetDelay(startTime); } else { ApplyValue(item, item.value); } if (item.repeat > 0) { item.tweener.SetLoops(item.repeat + 1, item.yoyo ? LoopType.Yoyo : LoopType.Restart); } break; case TransitionActionType.Rotation: _totalTasks++; item.value.i = item.startValue.i; item.tweener = DOTween.To(() => item.value.i, v => item.value.i = v, item.endValue.i, item.duration) .SetEase(item.easeType) .OnStart(() => { if (item.hook != null) { item.hook(); } }) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (startTime > 0) { item.tweener.SetDelay(startTime); } else { ApplyValue(item, item.value); } if (item.repeat > 0) { item.tweener.SetLoops(item.repeat + 1, item.yoyo ? LoopType.Yoyo : LoopType.Restart); } break; } } else { if (startTime == 0) { ApplyValue(item, item.value); } else { item.completed = false; _totalTasks++; item.value.f3 = 1; item.tweener = DOVirtual.DelayedCall(startTime, () => { item.tweener = null; item.completed = true; _totalTasks--; ApplyValue(item, item.value); if (item.hook != null) { item.hook(); } CheckAllComplete(); }, DOTween.defaultTimeScaleIndependent); } } } }
void StartTween(TransitionItem item) { Vector2 endValue; if (_reversed) { item.value.f1 = item.endValue.f1; item.value.f2 = item.endValue.f2; endValue = new Vector2(item.startValue.f1, item.startValue.f2); } else { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!item.startValue.b1) { item.startValue.f1 = 0; } if (!item.startValue.b2) { item.startValue.f2 = 0; } } else { if (!item.startValue.b1) { item.startValue.f1 = item.target.x; } if (!item.startValue.b2) { item.startValue.f2 = item.target.y; } } } else { if (!item.startValue.b1) { item.startValue.f1 = item.target.width; } if (!item.startValue.b2) { item.startValue.f2 = item.target.height; } } item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; item.value.b1 = item.startValue.b1; item.value.b2 = item.startValue.b2; if (!item.endValue.b1) { item.endValue.f1 = item.value.f1; } if (!item.endValue.b2) { item.endValue.f2 = item.value.f2; } endValue = new Vector2(item.endValue.f1, item.endValue.f2); } item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, endValue, item.duration); SetupTween(item, 0); if (item.hook != null) { item.hook(); } }
void StopItem(TransitionItem item, bool setToComplete) { if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0 && item.target != _owner) { item.target.internalVisible--; } if (item.type == TransitionActionType.ColorFilter && item.filterCreated) { item.target.filter = null; } if (item.completed) { return; } if (item.tweener != null) { item.tweener.Kill(); item.tweener = null; } if (item.type == TransitionActionType.Transition) { Transition trans = ((GComponent)item.target).GetTransition(item.value.s); if (trans != null) { trans.Stop(setToComplete, false); } } else if (item.type == TransitionActionType.Shake) { if (Timers.inst.Exists(item.__Shake)) { Timers.inst.Remove(item.__Shake); item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1, item.target.y - item.startValue.f2); item.target._gearLocked = false; } } else { if (setToComplete) { if (item.tween) { if (!item.yoyo || item.repeat % 2 == 0) { ApplyValue(item, _reversed ? item.startValue : item.endValue); } else { ApplyValue(item, _reversed ? item.endValue : item.startValue); } } else if (item.type != TransitionActionType.Sound) { ApplyValue(item, item.value); } } } }
void ApplyValue(TransitionItem item, TransitionValue value) { item.target._gearLocked = true; switch (item.type) { case TransitionActionType.XY: if (item.target == _owner) { float f1, f2; if (!value.b1) f1 = item.target.x; else f1 = value.f1 + _ownerBaseX; if (!value.b2) f2 = item.target.y; else f2 = value.f2 + _ownerBaseY; item.target.SetXY(f1, f2); } else { if (!value.b1) value.f1 = item.target.x; if (!value.b2) value.f2 = item.target.y; item.target.SetXY(value.f1, value.f2); } break; case TransitionActionType.Size: if (!value.b1) value.f1 = item.target.width; if (!value.b2) value.f2 = item.target.height; item.target.SetSize(value.f1, value.f2); break; case TransitionActionType.Pivot: item.target.SetPivot(value.f1, value.f2); break; case TransitionActionType.Alpha: item.target.alpha = value.f1; break; case TransitionActionType.Rotation: item.target.rotation = value.i; break; case TransitionActionType.Scale: item.target.SetScale(value.f1, value.f2); break; case TransitionActionType.Color: ((IColorGear)item.target).color = value.c; break; case TransitionActionType.Animation: if (!value.b1) value.i = ((IAnimationGear)item.target).frame; ((IAnimationGear)item.target).frame = value.i; ((IAnimationGear)item.target).playing = value.b; break; case TransitionActionType.Visible: item.target.visible = value.b; break; case TransitionActionType.Controller: string[] arr = value.s.Split(jointChar0); foreach (string str in arr) { string[] arr2 = str.Split(jointChar2); Controller cc = ((GComponent)item.target).GetController(arr2[0]); if (cc != null) { string str2 = arr2[1]; if (str2[0] == '$') { str2 = str.Substring(1); cc.selectedPage = str2; } else cc.selectedIndex = int.Parse(str2); } } break; case TransitionActionType.Transition: Transition trans = ((GComponent)item.target).GetTransition(value.s); if (trans != null) { if (value.i == 0) trans.Stop(false, true); else if (trans.playing) trans._totalTimes = value.i == -1 ? int.MaxValue : value.i; else { item.completed = false; _totalTasks++; if (_reversed) trans.PlayReverse(value.i, 0, () => { __playTransComplete(item); }); else trans.Play(value.i, 0, () => { __playTransComplete(item); }); } } break; case TransitionActionType.Sound: AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; if (sound != null) Stage.inst.PlayOneShotSound(sound, value.f1); break; case TransitionActionType.Shake: item.startValue.f1 = 0; //offsetX item.startValue.f2 = 0; //offsetY item.startValue.f3 = item.value.f2;//shakePeriod Timers.inst.AddUpdate(item.__Shake, this); _totalTasks++; item.completed = false; break; } item.target._gearLocked = false; }
/// <summary> /// /// </summary> /// <param name="label"></param> /// <param name="aParams"></param> public void SetValue(string label, params object[] aParams) { int cnt = _items.Count; TransitionValue value; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.label == label) { if (item.tween) { value = item.startValue; } else { value = item.value; } } else if (item.label2 == label) { value = item.endValue; } else { continue; } switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: case TransitionActionType.Pivot: case TransitionActionType.Scale: case TransitionActionType.Skew: value.b1 = true; value.b2 = true; value.f1 = Convert.ToSingle(aParams[0]); value.f2 = Convert.ToSingle(aParams[1]); break; case TransitionActionType.Alpha: value.f1 = Convert.ToSingle(aParams[0]); break; case TransitionActionType.Rotation: value.f1 = Convert.ToInt32(aParams[0]); break; case TransitionActionType.Color: value.AsColor = (Color)aParams[0]; break; case TransitionActionType.Animation: ((TransitionItem_Animation)item).frame = Convert.ToInt32(aParams[0]); if (aParams.Length > 1) { ((TransitionItem_Animation)item).playing = Convert.ToBoolean(aParams[1]); } break; case TransitionActionType.Visible: ((TransitionItem_Visible)item).visible = Convert.ToBoolean(aParams[0]); break; case TransitionActionType.Sound: ((TransitionItem_Sound)item).sound = (string)aParams[0]; if (aParams.Length > 1) { ((TransitionItem_Sound)item).volume = Convert.ToSingle(aParams[1]); } break; case TransitionActionType.Transition: ((TransitionItem_Transition)item).transName = (string)aParams[0]; if (aParams.Length > 1) { ((TransitionItem_Transition)item).transRepeat = Convert.ToInt32(aParams[1]); } break; case TransitionActionType.Shake: ((TransitionItem_Shake)item).shakeAmplitude = Convert.ToSingle(aParams[0]); if (aParams.Length > 1) { ((TransitionItem_Shake)item).shakePeriod = Convert.ToSingle(aParams[1]); } break; case TransitionActionType.ColorFilter: value.f1 = Convert.ToSingle(aParams[0]); value.f2 = Convert.ToSingle(aParams[1]); value.f3 = Convert.ToSingle(aParams[2]); value.f4 = Convert.ToSingle(aParams[3]); break; } } }
void __playTransComplete(TransitionItem item) { _totalTasks--; item.completed = true; CheckAllComplete(); }
void StartTween(TransitionItem item) { Vector2 endValue; if (_reversed) { item.value.f1 = item.endValue.f1; item.value.f2 = item.endValue.f2; endValue = new Vector2(item.startValue.f1, item.startValue.f2); } else { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!item.startValue.b1) { item.startValue.f1 = 0; } if (!item.startValue.b2) { item.startValue.f2 = 0; } } else { if (!item.startValue.b1) { item.startValue.f1 = item.target.x; } if (!item.startValue.b2) { item.startValue.f2 = item.target.y; } } } else { if (!item.startValue.b1) { item.startValue.f1 = item.target.width; } if (!item.startValue.b2) { item.startValue.f2 = item.target.height; } } item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; if (!item.endValue.b1) { item.endValue.f1 = item.value.f1; } if (!item.endValue.b2) { item.endValue.f2 = item.value.f2; } endValue = new Vector2(item.endValue.f1, item.endValue.f2); } item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, endValue, item.duration) .SetEase(item.easeType) .SetUpdate(true) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (item.repeat != 0) { item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); } ApplyValue(item, item.value); if (item.hook != null) { item.hook(); } }
void StopItem(TransitionItem item, bool setToComplete) { if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { if (item.target != _owner) item.target.internalVisible--; } if (item.completed) return; if (item.tweener != null) { item.tweener.Kill(); item.tweener = null; } if (item.type == TransitionActionType.Transition) { Transition trans = ((GComponent)item.target).GetTransition(item.value.s); if (trans != null) trans.Stop(setToComplete, false); } else if (item.type == TransitionActionType.Shake) { if (Timers.inst.Exists(item.__Shake)) { Timers.inst.Remove(item.__Shake); item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1, item.target.y - item.startValue.f2); item.target._gearLocked = false; } } else { if (setToComplete) { if (item.tween) { if (!item.yoyo || item.repeat % 2 == 0) ApplyValue(item, _reversed ? item.startValue : item.endValue); else ApplyValue(item, _reversed ? item.endValue : item.startValue); } else if (item.type != TransitionActionType.Sound) ApplyValue(item, item.value); } } }
void StartTween(TransitionItem item) { Vector2 endValue; if (_reversed) { item.value.f1 = item.endValue.f1; item.value.f2 = item.endValue.f2; endValue = new Vector2(item.startValue.f1, item.startValue.f2); } else { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!item.startValue.b1) item.startValue.f1 = 0; if (!item.startValue.b2) item.startValue.f2 = 0; } else { if (!item.startValue.b1) item.startValue.f1 = item.target.x; if (!item.startValue.b2) item.startValue.f2 = item.target.y; } } else { if (!item.startValue.b1) item.startValue.f1 = item.target.width; if (!item.startValue.b2) item.startValue.f2 = item.target.height; } item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; if (!item.endValue.b1) item.endValue.f1 = item.value.f1; if (!item.endValue.b2) item.endValue.f2 = item.value.f2; endValue = new Vector2(item.endValue.f1, item.endValue.f2); } item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, endValue, item.duration) .SetEase(item.easeType) .SetUpdate(true) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (item.repeat != 0) item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); ApplyValue(item, item.value); if (item.hook != null) item.hook(); }
void StartTween(TransitionItem item, float delay) { TransitionValue startValue; TransitionValue endValue; if (_reversed) { startValue = item.endValue; endValue = item.startValue; } else { startValue = item.startValue; endValue = item.endValue; } switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!startValue.b1) { startValue.f1 = 0; } if (!startValue.b2) { startValue.f2 = 0; } } else { if (!startValue.b1) { startValue.f1 = item.target.x; } if (!startValue.b2) { startValue.f2 = item.target.y; } } } else { if (!startValue.b1) { startValue.f1 = item.target.width; } if (!startValue.b2) { startValue.f2 = item.target.height; } } item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; if (!endValue.b1) { endValue.f1 = item.value.f1; } if (!endValue.b2) { endValue.f2 = item.value.f2; } item.value.b1 = startValue.b1 || endValue.b1; item.value.b2 = startValue.b2 || endValue.b2; item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, new Vector2(endValue.f1, endValue.f2), item.duration); } break; case TransitionActionType.Scale: case TransitionActionType.Skew: { item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, new Vector2(endValue.f1, endValue.f2), item.duration); break; } case TransitionActionType.Alpha: case TransitionActionType.Rotation: { item.value.f1 = startValue.f1; item.tweener = DOTween.To(() => startValue.f1, v => item.value.f1 = v, endValue.f1, item.duration); break; } case TransitionActionType.Color: { item.value.c = startValue.c; item.tweener = DOTween.To(() => startValue.c, v => item.value.c = v, endValue.c, item.duration); break; } case TransitionActionType.ColorFilter: { item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; item.value.f3 = startValue.f3; item.value.f4 = startValue.f4; item.tweener = DOTween.To(() => new Vector4(startValue.f1, startValue.f2, startValue.f3, startValue.f4), v => { item.value.f1 = v.x; item.value.f2 = v.y; item.value.f3 = v.z; item.value.f4 = v.w; }, new Vector4(endValue.f1, endValue.f2, endValue.f3, endValue.f4), item.duration); break; } } item.tweener.SetEase(item.easeType) .SetUpdate(true) .OnStart(() => { if (item.hook != null) { item.hook(); } }) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (delay > 0) { item.tweener.SetDelay(delay); } else { ApplyValue(item, item.value); } if (item.repeat != 0) { item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); } if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } _totalTasks++; item.completed = false; }
void StartTween(TransitionItem item, float delay) { TransitionValue startValue; TransitionValue endValue; if (_reversed) { startValue = item.endValue; endValue = item.startValue; } else { startValue = item.startValue; endValue = item.endValue; } switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!startValue.b1) { startValue.f1 = 0; } if (!startValue.b2) { startValue.f2 = 0; } } else { if (!startValue.b1) { startValue.f1 = item.target.x; } if (!startValue.b2) { startValue.f2 = item.target.y; } } } else { if (!startValue.b1) { startValue.f1 = item.target.width; } if (!startValue.b2) { startValue.f2 = item.target.height; } } item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; if (!endValue.b1) { endValue.f1 = item.value.f1; } if (!endValue.b2) { endValue.f2 = item.value.f2; } item.value.b1 = startValue.b1 || endValue.b1; item.value.b2 = startValue.b2 || endValue.b2; item.tweener = DOTween.To(((TransitionItem_Vector2)item).getter, ((TransitionItem_Vector2)item).setter, endValue.AsVec2, item.duration); } break; case TransitionActionType.Scale: case TransitionActionType.Skew: { item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; item.tweener = DOTween.To(((TransitionItem_Vector2)item).getter, ((TransitionItem_Vector2)item).setter, endValue.AsVec2, item.duration); break; } case TransitionActionType.Alpha: case TransitionActionType.Rotation: { item.value.f1 = startValue.f1; item.tweener = DOTween.To(((TransitionItem_Float)item).getter, ((TransitionItem_Float)item).setter, endValue.f1, item.duration); break; } case TransitionActionType.Color: { item.value.Copy(startValue); item.tweener = DOTween.To(((TransitionItem_Color)item).getter, ((TransitionItem_Color)item).setter, endValue.AsColor, item.duration); break; } case TransitionActionType.ColorFilter: { item.value.Copy(startValue); item.tweener = DOTween.To(((TransitionItem_ColorFilter)item).getter, ((TransitionItem_ColorFilter)item).setter, endValue.AsVec4, item.duration); break; } } item.tweener.SetEase(item.easeType) .SetUpdate(true) .SetRecyclable() .OnStart(item.tweenStartDelegate) .OnUpdate(item.tweenUpdateDelegate) .OnComplete(item.tweenCompleteDelegate); if (delay > 0) { item.tweener.SetDelay(delay); } else { ApplyValue(item, item.value); } if (item.repeat != 0) { item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); } if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } _totalTasks++; item.completed = false; }
void DecodeValue(TransitionItem item, string str, TransitionValue value) { string[] arr; switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: case TransitionActionType.Pivot: case TransitionActionType.Skew: arr = str.Split(','); if (arr[0] == "-") { value.b1 = false; } else { value.f1 = float.Parse(arr[0]); value.b1 = true; } if (arr[1] == "-") { value.b2 = false; } else { value.f2 = float.Parse(arr[1]); value.b2 = true; } break; case TransitionActionType.Alpha: value.f1 = float.Parse(str); break; case TransitionActionType.Rotation: value.f1 = int.Parse(str); break; case TransitionActionType.Scale: arr = str.Split(','); value.f1 = float.Parse(arr[0]); value.f2 = float.Parse(arr[1]); break; case TransitionActionType.Color: value.AsColor = ToolSet.ConvertFromHtmlColor(str); break; case TransitionActionType.Animation: arr = str.Split(','); if (arr[0] == "-") { ((TransitionItem_Animation)item).frame = -1; } else { ((TransitionItem_Animation)item).frame = int.Parse(arr[0]); } ((TransitionItem_Animation)item).playing = arr[1] == "p"; break; case TransitionActionType.Visible: ((TransitionItem_Visible)item).visible = str == "true"; break; case TransitionActionType.Sound: arr = str.Split(','); ((TransitionItem_Sound)item).sound = arr[0]; if (arr.Length > 1) { int intv = int.Parse(arr[1]); if (intv == 100 || intv == 0) { ((TransitionItem_Sound)item).volume = 1; } else { ((TransitionItem_Sound)item).volume = (float)intv / 100f; } } else { ((TransitionItem_Sound)item).volume = 1; } break; case TransitionActionType.Transition: arr = str.Split(','); ((TransitionItem_Transition)item).transName = arr[0]; if (arr.Length > 1) { ((TransitionItem_Transition)item).transRepeat = int.Parse(arr[1]); } else { ((TransitionItem_Transition)item).transRepeat = 1; } break; case TransitionActionType.Shake: arr = str.Split(','); ((TransitionItem_Shake)item).shakeAmplitude = float.Parse(arr[0]); ((TransitionItem_Shake)item).shakePeriod = float.Parse(arr[1]); break; case TransitionActionType.ColorFilter: arr = str.Split(','); value.f1 = float.Parse(arr[0]); value.f2 = float.Parse(arr[1]); value.f3 = float.Parse(arr[2]); value.f4 = float.Parse(arr[3]); break; } }
void ApplyValue(TransitionItem item, TransitionValue value) { item.target._gearLocked = true; switch (item.type) { case TransitionActionType.XY: if (item.target == _owner) { float f1, f2; if (!value.b1) { f1 = item.target.x; } else { f1 = value.f1 + _ownerBaseX; } if (!value.b2) { f2 = item.target.y; } else { f2 = value.f2 + _ownerBaseY; } item.target.SetXY(f1, f2); } else { if (!value.b1) { value.f1 = item.target.x; } if (!value.b2) { value.f2 = item.target.y; } item.target.SetXY(value.f1, value.f2); } if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Size: if (!value.b1) { value.f1 = item.target.width; } if (!value.b2) { value.f2 = item.target.height; } item.target.SetSize(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Pivot: item.target.SetPivot(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Alpha: item.target.alpha = value.f1; break; case TransitionActionType.Rotation: item.target.rotation = value.f1; if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Scale: item.target.SetScale(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Skew: item.target.skew = new Vector2(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(); } break; case TransitionActionType.Color: ((IColorGear)item.target).color = value.c; break; case TransitionActionType.Animation: if (!value.b1) { value.i = ((IAnimationGear)item.target).frame; } ((IAnimationGear)item.target).frame = value.i; ((IAnimationGear)item.target).playing = value.b; break; case TransitionActionType.Visible: item.target.visible = value.b; break; case TransitionActionType.Transition: Transition trans = ((GComponent)item.target).GetTransition(value.s); if (trans != null) { if (value.i == 0) { trans.Stop(false, true); } else if (trans.playing) { trans._totalTimes = value.i == -1 ? int.MaxValue : value.i; } else { item.completed = false; _totalTasks++; if (_reversed) { trans.PlayReverse(value.i, 0, () => { __playTransComplete(item); }); } else { trans.Play(value.i, 0, () => { __playTransComplete(item); }); } if (_timeScale != 1) { trans.timeScale = _timeScale; } } } break; case TransitionActionType.Sound: AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; if (sound != null) { Stage.inst.PlayOneShotSound(sound, value.f1); } break; case TransitionActionType.Shake: item.startValue.f1 = 0; //offsetX item.startValue.f2 = 0; //offsetY item.startValue.f3 = item.value.f2; //shakePeriod Timers.inst.AddUpdate(item.__Shake, this); _totalTasks++; item.completed = false; break; case TransitionActionType.ColorFilter: ColorFilter cf = item.target.filter as ColorFilter; if (cf == null) { cf = new ColorFilter(); item.target.filter = cf; item.filterCreated = true; } else { cf.Reset(); } cf.AdjustBrightness(value.f1); cf.AdjustContrast(value.f2); cf.AdjustSaturation(value.f3); cf.AdjustHue(value.f4); break; } item.target._gearLocked = false; }
void InternalPlay(float delay) { _ownerBaseX = _owner.x; _ownerBaseY = _owner.y; _totalTasks = 0; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.targetId.Length > 0) { item.target = _owner.GetChildById(item.targetId); } else { item.target = _owner; } if (item.target == null) { continue; } if (item.tween) { float startTime = delay; if (_reversed) { startTime += (_maxTime - item.time - item.duration); } else { startTime += item.time; } if (startTime > 0 && (item.type == TransitionActionType.XY || item.type == TransitionActionType.Size)) { _totalTasks++; item.completed = false; item.tweener = DOVirtual.DelayedCall(startTime, item.delayedCallDelegate, true); item.tweener.SetRecyclable(); if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } } else { StartTween(item, startTime); } } else { float startTime = delay; if (_reversed) { startTime += (_maxTime - item.time); } else { startTime += item.time; } if (startTime == 0) { ApplyValue(item, item.value); } else { item.completed = false; _totalTasks++; item.tweener = DOVirtual.DelayedCall(startTime, item.delayedCallDelegate, true); item.tweener.SetRecyclable(); if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } } } } }
internal void ShakeItem(TransitionItem item) { float r = Mathf.Ceil(item.value.f1 * item.startValue.f3 / item.value.f2); Vector2 vr = UnityEngine.Random.insideUnitCircle * r; vr.x = vr.x > 0 ? Mathf.Ceil(vr.x) : Mathf.Floor(vr.x); vr.y = vr.y > 0 ? Mathf.Ceil(vr.y) : Mathf.Floor(vr.y); item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1 + vr.x, item.target.y - item.startValue.f2 + vr.y); item.target._gearLocked = false; item.startValue.f1 = vr.x; item.startValue.f2 = vr.y; item.startValue.f3 -= Time.deltaTime; if (item.startValue.f3 <= 0) { item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1, item.target.y - item.startValue.f2); item.target._gearLocked = false; item.completed = true; _totalTasks--; Timers.inst.Remove(item.__Shake); CheckAllComplete(); } }
internal void ApplyValue(TransitionItem item, TransitionValue value) { item.target._gearLocked = true; switch (item.type) { case TransitionActionType.XY: if (item.target == _owner) { float f1, f2; if (!value.b1) { f1 = item.target.x; } else { f1 = value.f1 + _ownerBaseX; } if (!value.b2) { f2 = item.target.y; } else { f2 = value.f2 + _ownerBaseY; } item.target.SetXY(f1, f2); } else { if (!value.b1) { value.f1 = item.target.x; } if (!value.b2) { value.f2 = item.target.y; } item.target.SetXY(value.f1, value.f2); } if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Size: if (!value.b1) { value.f1 = item.target.width; } if (!value.b2) { value.f2 = item.target.height; } item.target.SetSize(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Pivot: item.target.SetPivot(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Alpha: item.target.alpha = value.f1; break; case TransitionActionType.Rotation: item.target.rotation = value.f1; if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Scale: item.target.SetScale(value.f1, value.f2); if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Skew: item.target.skew = value.AsVec2; if (invalidateBatchingEveryFrame) { _owner.InvalidateBatchingState(true); } break; case TransitionActionType.Color: ((IColorGear)item.target).color = value.AsColor; break; case TransitionActionType.Animation: if (((TransitionItem_Animation)item).frame >= 0) { ((IAnimationGear)item.target).frame = ((TransitionItem_Animation)item).frame; } ((IAnimationGear)item.target).playing = ((TransitionItem_Animation)item).playing; break; case TransitionActionType.Visible: item.target.visible = ((TransitionItem_Visible)item).visible; break; case TransitionActionType.Transition: Transition trans = ((GComponent)item.target).GetTransition(((TransitionItem_Transition)item).transName); if (trans != null) { int tranRepeat = ((TransitionItem_Transition)item).transRepeat; if (tranRepeat == 0) { trans.Stop(false, true); } else if (trans.playing) { trans._totalTimes = tranRepeat; } else { item.completed = false; _totalTasks++; if (_reversed) { trans.PlayReverse(tranRepeat, 0, ((TransitionItem_Transition)item).playCompleteDelegate); } else { trans.Play(tranRepeat, 0, ((TransitionItem_Transition)item).playCompleteDelegate); } if (_timeScale != 1) { trans.timeScale = _timeScale; } } } break; case TransitionActionType.Sound: ((TransitionItem_Sound)item).Play(); break; case TransitionActionType.Shake: ((TransitionItem_Shake)item).Start(); _totalTasks++; item.completed = false; break; case TransitionActionType.ColorFilter: ((TransitionItem_ColorFilter)item).SetFilter(); break; } item.target._gearLocked = false; }
void tweenComplete(TransitionItem item) { item.tweener = null; item.completed = true; _totalTasks--; if (item.hook2 != null) item.hook2(); if (item.type == TransitionActionType.XY || item.type == TransitionActionType.Size || item.type == TransitionActionType.Scale) _owner.InvalidateBatchingState(); CheckAllComplete(); }
public void Setup(XML xml) { this.name = xml.GetAttribute("name"); _options = xml.GetAttributeInt("options"); _autoPlay = xml.GetAttributeBool("autoPlay"); if (_autoPlay) { this.autoPlayRepeat = xml.GetAttributeInt("autoPlayRepeat", 1); this.autoPlayDelay = xml.GetAttributeFloat("autoPlayDelay"); } XMLList.Enumerator et = xml.GetEnumerator("item"); while (et.MoveNext()) { XML cxml = et.Current; TransitionItem item = new TransitionItem(); _items.Add(item); item.time = (float)cxml.GetAttributeInt("time") / (float)FRAME_RATE; item.targetId = cxml.GetAttribute("target", string.Empty); item.type = FieldTypes.ParseTransitionActionType(cxml.GetAttribute("type")); item.tween = cxml.GetAttributeBool("tween"); item.label = cxml.GetAttribute("label"); if (item.tween) { item.duration = (float)cxml.GetAttributeInt("duration") / FRAME_RATE; if (item.time + item.duration > _maxTime) { _maxTime = item.time + item.duration; } string ease = cxml.GetAttribute("ease"); if (ease != null) { item.easeType = FieldTypes.ParseEaseType(ease); } item.repeat = cxml.GetAttributeInt("repeat"); item.yoyo = cxml.GetAttributeBool("yoyo"); item.label2 = cxml.GetAttribute("label2"); string v = cxml.GetAttribute("endValue"); if (v != null) { DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.startValue); DecodeValue(item.type, v, item.endValue); } else { item.tween = false; DecodeValue(item.type, cxml.GetAttribute("startValue", string.Empty), item.value); } } else { if (item.time > _maxTime) { _maxTime = item.time; } DecodeValue(item.type, cxml.GetAttribute("value", string.Empty), item.value); } } }
void ApplyValue(TransitionItem item, TransitionValue value) { item.target._gearLocked = true; switch (item.type) { case TransitionActionType.XY: if (item.target == _owner) { float f1, f2; if (!value.b1) { f1 = item.target.x; } else { f1 = value.f1 + _ownerBaseX; } if (!value.b2) { f2 = item.target.y; } else { f2 = value.f2 + _ownerBaseY; } item.target.SetXY(f1, f2); } else { if (!value.b1) { value.f1 = item.target.x; } if (!value.b2) { value.f2 = item.target.y; } item.target.SetXY(value.f1, value.f2); } break; case TransitionActionType.Size: if (!value.b1) { value.f1 = item.target.width; } if (!value.b2) { value.f2 = item.target.height; } item.target.SetSize(value.f1, value.f2); break; case TransitionActionType.Pivot: item.target.SetPivot(value.f1, value.f2); break; case TransitionActionType.Alpha: item.target.alpha = value.f1; break; case TransitionActionType.Rotation: item.target.rotation = value.i; break; case TransitionActionType.Scale: item.target.SetScale(value.f1, value.f2); break; case TransitionActionType.Color: ((IColorGear)item.target).color = value.c; break; case TransitionActionType.Animation: if (!value.b1) { value.i = ((IAnimationGear)item.target).frame; } ((IAnimationGear)item.target).frame = value.i; ((IAnimationGear)item.target).playing = value.b; break; case TransitionActionType.Visible: item.target.visible = value.b; break; case TransitionActionType.Controller: string[] arr = value.s.Split(jointChar0); foreach (string str in arr) { string[] arr2 = str.Split(jointChar2); Controller cc = ((GComponent)item.target).GetController(arr2[0]); if (cc != null) { string str2 = arr2[1]; if (str2[0] == '$') { str2 = str.Substring(1); cc.selectedPage = str2; } else { cc.selectedIndex = int.Parse(str2); } } } break; case TransitionActionType.Transition: Transition trans = ((GComponent)item.target).GetTransition(value.s); if (trans != null) { if (value.i == 0) { trans.Stop(false, true); } else if (trans.playing) { trans._totalTimes = value.i; } else { item.completed = false; _totalTasks++; trans.Play(value.i, 0, () => { __playTransComplete(item); }); } } break; case TransitionActionType.Sound: AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; if (sound != null) { Stage.inst.PlayOneShotSound(sound, value.f1); } break; case TransitionActionType.Shake: item.startValue.f1 = 0; //offsetX item.startValue.f2 = 0; //offsetY item.startValue.f3 = item.value.f2; //shakePeriod Timers.inst.Add(0.001f, 0, item.__Shake, this); _totalTasks++; item.completed = false; break; } item.target._gearLocked = false; }
void InternalPlay(float delay) { _ownerBaseX = _owner.x; _ownerBaseY = _owner.y; _totalTasks = 0; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.targetId.Length > 0) { item.target = _owner.GetChildById(item.targetId); } else { item.target = _owner; } if (item.target == null) { continue; } if (item.tween) { float startTime = delay; if (_reversed) { startTime += (_maxTime - item.time - item.duration); } else { startTime += item.time; } item.completed = false; switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: _totalTasks++; if (startTime == 0) { StartTween(item); } else { item.tweener = DOVirtual.DelayedCall(startTime, () => { item.tweener = null; StartTween(item); }, true); if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } } break; case TransitionActionType.Scale: case TransitionActionType.Skew: { _totalTasks++; Vector2 endValue; if (_reversed) { item.value.f1 = item.endValue.f1; item.value.f2 = item.endValue.f2; endValue = new Vector2(item.startValue.f1, item.startValue.f2); } else { item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; endValue = new Vector2(item.endValue.f1, item.endValue.f2); } item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, endValue, item.duration); SetupTween(item, startTime); break; } case TransitionActionType.Alpha: { _totalTasks++; float endValue; if (_reversed) { item.value.f1 = item.endValue.f1; endValue = item.startValue.f1; } else { item.value.f1 = item.startValue.f1; endValue = item.endValue.f1; } item.tweener = DOTween.To(() => item.value.f1, v => item.value.f1 = v, endValue, item.duration); SetupTween(item, startTime); break; } case TransitionActionType.Rotation: { _totalTasks++; int endValue; if (_reversed) { item.value.f1 = item.endValue.i; endValue = item.startValue.i; } else { item.value.f1 = item.startValue.i; endValue = item.endValue.i; } item.tweener = DOTween.To(() => item.value.f1, v => item.value.f1 = v, endValue, item.duration); SetupTween(item, startTime); break; } case TransitionActionType.Color: { _totalTasks++; Color endValue; if (_reversed) { item.value.c = item.endValue.c; endValue = item.startValue.c; } else { item.value.c = item.startValue.c; endValue = item.endValue.c; } item.tweener = DOTween.To(() => item.value.c, v => item.value.c = v, endValue, item.duration); SetupTween(item, startTime); break; } case TransitionActionType.ColorFilter: { _totalTasks++; Vector4 endValue; if (_reversed) { item.value.f1 = item.endValue.f1; item.value.f2 = item.endValue.f2; item.value.f3 = item.endValue.f3; item.value.f4 = item.endValue.f4; endValue = new Vector4(item.startValue.f1, item.startValue.f2, item.startValue.f3, item.startValue.f4); } else { item.value.f1 = item.startValue.f1; item.value.f2 = item.startValue.f2; item.value.f3 = item.startValue.f3; item.value.f4 = item.startValue.f4; endValue = new Vector4(item.endValue.f1, item.endValue.f2, item.endValue.f3, item.endValue.f4); } item.tweener = DOTween.To(() => new Vector4(item.value.f1, item.value.f2, item.value.f3, item.value.f4), v => { item.value.f1 = v.x; item.value.f2 = v.y; item.value.f3 = v.z; item.value.f4 = v.w; }, endValue, item.duration); SetupTween(item, startTime); break; } } } else { float startTime = delay; if (_reversed) { startTime += (_maxTime - item.time); } else { startTime += item.time; } if (startTime == 0) { ApplyValue(item, item.value); } else { item.completed = false; _totalTasks++; item.tweener = DOVirtual.DelayedCall(startTime, () => { item.tweener = null; item.completed = true; _totalTasks--; ApplyValue(item, item.value); if (item.hook != null) { item.hook(); } CheckAllComplete(); }, true); if (_timeScale != 1) { item.tweener.timeScale = _timeScale; } } } } }
void StartTween(TransitionItem item, float delay) { TransitionValue startValue; TransitionValue endValue; if (_reversed) { startValue = item.endValue; endValue = item.startValue; } else { startValue = item.startValue; endValue = item.endValue; } switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { if (!startValue.b1) startValue.f1 = 0; if (!startValue.b2) startValue.f2 = 0; } else { if (!startValue.b1) startValue.f1 = item.target.x; if (!startValue.b2) startValue.f2 = item.target.y; } } else { if (!startValue.b1) startValue.f1 = item.target.width; if (!startValue.b2) startValue.f2 = item.target.height; } item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; if (!endValue.b1) endValue.f1 = item.value.f1; if (!endValue.b2) endValue.f2 = item.value.f2; item.value.b1 = startValue.b1 || endValue.b1; item.value.b2 = startValue.b2 || endValue.b2; item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, new Vector2(endValue.f1, endValue.f2), item.duration); } break; case TransitionActionType.Scale: case TransitionActionType.Skew: { item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2), val => { item.value.f1 = val.x; item.value.f2 = val.y; }, new Vector2(endValue.f1, endValue.f2), item.duration); break; } case TransitionActionType.Alpha: case TransitionActionType.Rotation: { item.value.f1 = startValue.f1; item.tweener = DOTween.To(() => startValue.f1, v => item.value.f1 = v, endValue.f1, item.duration); break; } case TransitionActionType.Color: { item.value.c = startValue.c; item.tweener = DOTween.To(() => startValue.c, v => item.value.c = v, endValue.c, item.duration); break; } case TransitionActionType.ColorFilter: { item.value.f1 = startValue.f1; item.value.f2 = startValue.f2; item.value.f3 = startValue.f3; item.value.f4 = startValue.f4; item.tweener = DOTween.To(() => new Vector4(startValue.f1, startValue.f2, startValue.f3, startValue.f4), v => { item.value.f1 = v.x; item.value.f2 = v.y; item.value.f3 = v.z; item.value.f4 = v.w; }, new Vector4(endValue.f1, endValue.f2, endValue.f3, endValue.f4), item.duration); break; } } item.tweener.SetEase(item.easeType) .SetUpdate(true) .OnStart(() => { if (item.hook != null) item.hook(); }) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (delay > 0) item.tweener.SetDelay(delay); else ApplyValue(item, item.value); if (item.repeat != 0) item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); if (_timeScale != 1) item.tweener.timeScale = _timeScale; _totalTasks++; item.completed = false; }
public void SetValue(string label, params object[] aParams) { int cnt = _items.Count; TransitionValue value; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.label == null && item.label2 == null) { continue; } if (item.label == label) { if (item.tween) { value = item.startValue; } else { value = item.value; } } else if (item.label2 == label) { value = item.endValue; } else { continue; } switch (item.type) { case TransitionActionType.XY: case TransitionActionType.Size: case TransitionActionType.Pivot: case TransitionActionType.Scale: value.b1 = true; value.b2 = true; value.f1 = Convert.ToSingle(aParams[0]); value.f2 = Convert.ToSingle(aParams[1]); break; case TransitionActionType.Alpha: value.f1 = Convert.ToSingle(aParams[0]); break; case TransitionActionType.Rotation: value.i = Convert.ToInt32(aParams[0]); break; case TransitionActionType.Color: value.c = (Color)aParams[0]; break; case TransitionActionType.Animation: value.i = Convert.ToInt32(aParams[0]); if (aParams.Length > 1) { value.b = Convert.ToBoolean(aParams[1]); } break; case TransitionActionType.Visible: value.b = Convert.ToBoolean(aParams[0]); break; case TransitionActionType.Controller: value.s = (string)aParams[0]; break; case TransitionActionType.Sound: value.s = (string)aParams[0]; if (aParams.Length > 1) { value.f1 = Convert.ToSingle(aParams[1]); } break; case TransitionActionType.Transition: value.s = (string)aParams[0]; if (aParams.Length > 1) { value.i = Convert.ToInt32(aParams[1]); } break; case TransitionActionType.Shake: value.f1 = Convert.ToSingle(aParams[0]); if (aParams.Length > 1) { value.f2 = Convert.ToSingle(aParams[1]); } break; } } }
void StartTween(TransitionItem item) { if (item.type == TransitionActionType.XY) { if (item.target == _owner) { item.value.f1 = item.startValue.b1 ? item.startValue.f1 : 0; item.value.f2 = item.startValue.b2 ? item.startValue.f2 : 0; } else { item.value.f1 = item.startValue.b1 ? item.startValue.f1 : item.target.x; item.value.f2 = item.startValue.b2 ? item.startValue.f2 : item.target.y; } } else { item.value.f1 = item.startValue.b1 ? item.startValue.f1 : item.target.width; item.value.f2 = item.startValue.b2 ? item.startValue.f2 : item.target.height; } Vector2 endValue = new Vector2(item.endValue.b1 ? item.endValue.f1 : item.value.f1, item.endValue.b2 ? item.endValue.f2 : item.value.f2); item.tweener = DOTween.To(() => new Vector2(item.value.f1, item.value.f2), val => { item.value.f1 = val.value.x; item.value.f2 = val.value.y; }, endValue, item.duration) .SetEase(item.easeType) .OnUpdate(() => { ApplyValue(item, item.value); }) .OnComplete(() => { tweenComplete(item); }); if (item.repeat > 0) item.tweener.SetLoops(item.repeat + 1, item.yoyo ? LoopType.Yoyo : LoopType.Restart); ApplyValue(item, item.value); if (item.hook != null) item.hook(); }
public TransitionItem Clone() { TransitionItem item = new TransitionItem(); item.time = this.time; item.targetId = this.targetId; item.type = this.type; item.duration = this.duration; item.value.Copy(this.value); item.startValue.Copy(this.startValue); item.endValue.Copy(this.endValue); item.easeType = this.easeType; item.repeat = this.repeat; item.yoyo = this.yoyo; item.tween = this.tween; item.label = this.label; item.label2 = this.label2; return item; }
public void Stop(bool setToComplete, bool processCallback) { if (_playing) { _playing = false; _totalTasks = 0; _totalTimes = 0; PlayCompleteCallback func = _onComplete; _onComplete = null; _owner.internalVisible--; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target == null) { continue; } if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { if (item.target != _owner) { item.target.internalVisible--; } } if (item.completed) { continue; } if (item.tweener != null) { item.tweener.Kill(); item.tweener = null; } if (item.type == TransitionActionType.Transition) { Transition trans = ((GComponent)item.target).GetTransition(item.value.s); if (trans != null) { trans.Stop(setToComplete, false); } } else if (item.type == TransitionActionType.Shake) { if (Timers.inst.Exists(item.__Shake)) { Timers.inst.Remove(item.__Shake); item.target._gearLocked = true; item.target.SetXY(item.target.x - item.startValue.f1, item.target.y - item.startValue.f2); item.target._gearLocked = false; } } else { if (setToComplete) { if (item.tween) { if (!item.yoyo || item.repeat % 2 == 0) { ApplyValue(item, item.endValue); } else { ApplyValue(item, item.startValue); } } else if (item.type != TransitionActionType.Sound) { ApplyValue(item, item.value); } } } } if (processCallback && func != null) { func(); } } }
void ApplyValue(TransitionItem item, TransitionValue value) { item.target._gearLocked = true; switch (item.type) { case TransitionActionType.XY: if (item.target == _owner) { float f1, f2; if (!value.b1) f1 = item.target.x; else f1 = value.f1 + _ownerBaseX; if (!value.b2) f2 = item.target.y; else f2 = value.f2 + _ownerBaseY; item.target.SetXY(f1, f2); } else { if (!value.b1) value.f1 = item.target.x; if (!value.b2) value.f2 = item.target.y; item.target.SetXY(value.f1, value.f2); } if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Size: if (!value.b1) value.f1 = item.target.width; if (!value.b2) value.f2 = item.target.height; item.target.SetSize(value.f1, value.f2); if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Pivot: item.target.SetPivot(value.f1, value.f2); if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Alpha: item.target.alpha = value.f1; break; case TransitionActionType.Rotation: item.target.rotation = value.f1; if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Scale: item.target.SetScale(value.f1, value.f2); if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Skew: item.target.skew = new Vector2(value.f1, value.f2); if (invalidateBatchingEveryFrame) _owner.InvalidateBatchingState(); break; case TransitionActionType.Color: ((IColorGear)item.target).color = value.c; break; case TransitionActionType.Animation: if (!value.b1) value.i = ((IAnimationGear)item.target).frame; ((IAnimationGear)item.target).frame = value.i; ((IAnimationGear)item.target).playing = value.b; break; case TransitionActionType.Visible: item.target.visible = value.b; break; case TransitionActionType.Transition: Transition trans = ((GComponent)item.target).GetTransition(value.s); if (trans != null) { if (value.i == 0) trans.Stop(false, true); else if (trans.playing) trans._totalTimes = value.i == -1 ? int.MaxValue : value.i; else { item.completed = false; _totalTasks++; if (_reversed) trans.PlayReverse(value.i, 0, () => { __playTransComplete(item); }); else trans.Play(value.i, 0, () => { __playTransComplete(item); }); if (_timeScale != 1) trans.timeScale = _timeScale; } } break; case TransitionActionType.Sound: AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip; if (sound != null) Stage.inst.PlayOneShotSound(sound, value.f1); break; case TransitionActionType.Shake: item.startValue.f1 = 0; //offsetX item.startValue.f2 = 0; //offsetY item.startValue.f3 = item.value.f2;//shakePeriod Timers.inst.AddUpdate(item.__Shake, this); _totalTasks++; item.completed = false; break; case TransitionActionType.ColorFilter: ColorFilter cf = item.target.filter as ColorFilter; if (cf == null) { cf = new ColorFilter(); item.target.filter = cf; item.filterCreated = true; } else { cf.Reset(); } cf.AdjustBrightness(value.f1); cf.AdjustContrast(value.f2); cf.AdjustSaturation(value.f3); cf.AdjustHue(value.f4); break; } item.target._gearLocked = false; }