public void Dispose() { int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.tweener != null) { item.tweener.Kill(); item.tweener = null; } else if (_playing && item.type == TransitionActionType.Shake) { ((TransitionItem_Shake)item).Stop(false); } item.target = null; item.hook = null; item.hook2 = null; } _items.Clear(); _playing = false; _onComplete = null; }
void _Play(int times, float delay, PlayCompleteCallback onComplete, bool reverse) { Stop(true, true); _totalTimes = times; _reversed = reverse; InternalPlay(delay); _playing = _totalTasks > 0; if (_playing) { _onComplete = onComplete; if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null && item.target != _owner) { item.displayLockToken = item.target.AddDisplayLock(); } } } } else if (onComplete != null) { onComplete(); } }
public void Play(int times, float delay, PlayCompleteCallback onComplete) { Stop(true, true); if (times <= 0) { times = 1; } _totalTimes = times; InternalPlay(delay); _playing = _totalTasks > 0; if (_playing) { _onComplete = onComplete; _owner.internalVisible++; if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null && item.target != _owner) { item.target.internalVisible++; } } } } else if (onComplete != null) { onComplete(); } }
//退出页面 protected void ExitPanel(PlayCompleteCallback callback) { Transition t = panelMask.GetTransition("show_mask"); t.Play(callback);//这个callback就是在Play方法执行完之后,要执行的方法 方法可以是lanmada表达式 //如果不使用回调函数,可能会造成动画没有播放完毕 }
private void CheckAllComplete() { if (!this._playing || this._totalTasks != 0) { return; } if (this._totalTimes < 0) { this.InternalPlay(0); } else { this._totalTimes--; if (this._totalTimes > 0) { this.InternalPlay(0); } else { this._playing = false; if (this._onComplete != null) { PlayCompleteCallback func = this._onComplete; this._onComplete = null; func(); } } } }
public void Play(int times, float delay, PlayCompleteCallback onComplete) { Stop(true, true); if (times <= 0) times = 1; _totalTimes = times; InternalPlay(delay); _playing = _totalTasks > 0; if (_playing) { _onComplete = onComplete; _owner.internalVisible++; if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null && item.target != _owner) item.target.internalVisible++; } } } else if (onComplete != null) onComplete(); }
void CheckAllComplete() { if (_playing && _totalTasks == 0) { if (_totalTimes < 0) { InternalPlay(0); } else { _totalTimes--; if (_totalTimes > 0) { InternalPlay(0); } else { _playing = false; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null) { if (item.displayLockToken != 0) { item.target.ReleaseDisplayLock(item.displayLockToken); item.displayLockToken = 0; } if (item.filterCreated) { item.filterCreated = false; item.target.filter = null; } } } if (_onComplete != null) { PlayCompleteCallback func = _onComplete; _onComplete = null; func(); } } } } }
void CheckAllComplete() { if (_playing && _totalTasks == 0) { if (_totalTimes < 0) { InternalPlay(0); } else { _totalTimes--; if (_totalTimes > 0) { InternalPlay(0); } else { _playing = false; _owner.internalVisible--; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null) { if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0 && item.target != _owner) { item.target.internalVisible--; } if (item.filterCreated) { item.filterCreated = false; item.target.filter = null; } } } if (_onComplete != null) { PlayCompleteCallback func = _onComplete; _onComplete = null; func(); } } } } }
/// <summary> /// /// </summary> /// <param name="setToComplete"></param> /// <param name="processCallback"></param> 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; if (_reversed) { for (int i = cnt - 1; i >= 0; i--) { TransitionItem item = _items[i]; if (item.target == null) { continue; } StopItem(item, setToComplete); } } else { for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target == null) { continue; } StopItem(item, setToComplete); } } if (processCallback && func != null) { func(); } } }
public TransitionItem(Transition owner, TransitionActionType type) { this.type = type; easeType = Ease.OutQuad; value = new TransitionValue(); startValue = new TransitionValue(); endValue = new TransitionValue(); if (type == TransitionActionType.Shake) { onShake = (object param) => { owner.ShakeItem(this); } } ; else if (type == TransitionActionType.Transition) { onPlayComplete = () => { owner.PlayTransComplete(this); } } ; }
public void Dispose() { if (!_playing) { return; } _playing = false; _onComplete = null; int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target == null || 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.Dispose(); } } else if (item.type == TransitionActionType.Shake) { if (item.onShake != null) { Timers.inst.Remove(item.onShake); } } } }
/// <summary> /// /// </summary> /// <param name="onComplete"></param> public void PlayReverse(PlayCompleteCallback onComplete) { PlayReverse(1, 0, onComplete); }
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(); } }
//退出页面 protected void ExitPanel(PlayCompleteCallback playCompleteCallback) { Transition t = panelMask.GetTransition("MaskHide"); t.Play(playCompleteCallback); }
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 CheckAllComplete() { if (_playing && _totalTasks == 0) { if (_totalTimes < 0) { InternalPlay(0); } else { _totalTimes--; if (_totalTimes > 0) InternalPlay(0); else { _playing = false; _owner.internalVisible--; if ((_options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { int cnt = _items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target != null && item.target != _owner) item.target.internalVisible--; } } if (_onComplete != null) { PlayCompleteCallback func = _onComplete; _onComplete = null; func(); } } } } }
override public void Setup(Transition owner) { base.Setup(owner); playCompleteDelegate = () => { owner.OnInnerActionComplete(this); }; }
/// <summary> /// /// </summary> /// <param name="times"></param> /// <param name="delay"></param> /// <param name="onComplete"></param> public void Play(int times, float delay, PlayCompleteCallback onComplete) { _Play(times, delay, onComplete, false); }
public void Play(PlayCompleteCallback onComplete) { _obj.Play(onComplete); }
/// <summary> /// /// </summary> /// <param name="onComplete"></param> public void Play(PlayCompleteCallback onComplete) { Play(1, 0, onComplete); }
public void Dispose() { this._owner = null; this._onComplete = null; this._items.Clear(); }
/// <summary> /// /// </summary> /// <param name="times"></param> /// <param name="delay"></param> /// <param name="onComplete"></param> public void PlayReverse(int times, float delay, PlayCompleteCallback onComplete) { _Play(times, delay, onComplete, true); }
public void SetCompleteCallback(PlayCompleteCallback onComplete) { this._onComplete = onComplete; }
/// <summary> /// /// </summary> /// <param name="setToComplete"></param> /// <param name="processCallback"></param> 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; if (_reversed) { for (int i = cnt - 1; i >= 0; i--) { TransitionItem item = _items[i]; if (item.target == null) continue; StopItem(item, setToComplete); } } else { for (int i = 0; i < cnt; i++) { TransitionItem item = _items[i]; if (item.target == null) continue; StopItem(item, setToComplete); } } if (processCallback && func != null) func(); } }
private void InternalPlay(float delay) { this._totalTasks = 0; this._playing = true; int cnt = this._items.Count; for (int i = 0; i < cnt; i++) { TransitionItem item = this._items[i]; item.target = item.targetId.Length > 0 ? this._owner.GetChildById(item.targetId) : this._owner; if (item.target == null || item.target.disposed) { this._items.RemoveAt(i); --i; --cnt; continue; } item.completed = false; this._totalTasks++; if ((this._options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { ++item.target.ignoreGearVisible; } float startTime = delay; if (this._reversed) { startTime += (this._maxTime - item.time - item.duration); } else { startTime += item.time; } if (item.tween) { this.StartTween(item, delay); } else { item.startValue.Copy(item.value); TransitionValue startValue = item.startValue; switch (item.type) { case TransitionActionType.XY: if (!startValue.b1) { startValue.f.x += item.target.position.x; } if (!startValue.b2) { startValue.f.y += item.target.position.y; } break; case TransitionActionType.Size: if (!startValue.b1) { startValue.f.x += item.target.size.x; } if (!startValue.b2) { startValue.f.y += item.target.size.y; } break; case TransitionActionType.Animation: if (!startValue.b1) { startValue.f.x += (( IAnimationGear )item.target).frame; } break; } item.tweener = DOVirtual.DelayedCall(0, null).OnComplete(() => { item.hook?.Invoke(); this.ApplyValue(item, startValue); this.Complete(item); }); if (startTime > 0) { item.tweener.SetDelay(startTime); } else { this.ApplyValue(item, startValue); } } } if (this._totalTasks == 0) { this._playing = false; if (this._onComplete != null) { PlayCompleteCallback func = this._onComplete; this._onComplete = null; func(); } } }