예제 #1
0
        public override bool Trigger(object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var twn = SPTween.Tween(_target);

            for (int i = 0; i < _data.Length; i++)
            {
                twn.ByAnimMode(_data[i].Mode, _data[i].MemberName, EaseMethods.GetEase(_data[i].Ease), _data[i].ValueS.Value, _data[i].Duration, _data[i].ValueE.Value);
            }
            twn.Use(_timeSupplier.TimeSupplier);
            twn.SetId(_target);

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger());
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger());
            }

            twn.Play(true, _tweenToken);
            return(true);
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ   = _target.GetTarget <object>(arg);
            var source = _source.GetTarget <object>(arg);

            var twn = SPTween.Tween(targ)
                      .TweenWithToken(_mode, EaseMethods.GetEase(_ease), _duration.Seconds, source, _sourceAlt)
                      .Use(_duration.TimeSupplier)
                      .SetId(targ);

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true, _tweenToken);
            return(true);
        }
예제 #3
0
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = _target.GetTarget <AudioSource>(arg);

            if (targ == null)
            {
                return(false);
            }
            if (!targ.isPlaying)
            {
                return(false);
            }

            if (_fadeOutDur.Seconds > 0f)
            {
                float cache = targ.volume;
                SPTween.Tween(targ)
                .To("volume", _fadeOutDur.Seconds, 0f)
                .Use(_fadeOutDur.TimeSupplier)
                .OnFinish((s, e) =>
                {
                    targ.Stop();
                    targ.volume = cache;
                    switch (_disableAudioSource)
                    {
                    case DisableMode.DisableComponent:
                        targ.enabled = false;
                        break;

                    case DisableMode.DisableGameObject:
                        targ.gameObject.SetActive(false);
                        break;
                    }
                })
                .Play(true);
            }
            else
            {
                targ.Stop();
                switch (_disableAudioSource)
                {
                case DisableMode.DisableComponent:
                    targ.enabled = false;
                    break;

                case DisableMode.DisableGameObject:
                    targ.gameObject.SetActive(false);
                    break;
                }
            }

            return(true);
        }
        protected override void OnDisable()
        {
            base.OnDisable();

            if (_killOnDisable)
            {
                SPTween.KillAll(_target, _tweenToken);
            }
        }
예제 #5
0
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = _target.GetTarget <Transform>(arg);

            if (targ == null)
            {
                return(false);
            }

            //var curve = new WaypointPathTweenCurve("position", EaseMethods.GetEase(this._ease), _path.Path.GetArcLength() / this._speed, _path.Path);
            var curve = new AdvancedWaypointPathTweenCurve(EaseMethods.GetEase(this._ease), _path.Path.GetArcLength() / this._speed, _path)
            {
                UpdateTranslation = _updateTranslation,
                UpdateRotation    = _updateRotation
            };

            if (_updateModifierTypes != null && _updateModifierTypes.Length > 0)
            {
                for (int i = 0; i < _updateModifierTypes.Length; i++)
                {
                    var tp = _updateModifierTypes[i].Type;
                    if (tp != null)
                    {
                        curve.AddNodeModifierType(tp);
                    }
                }
            }

            var tween = SPTween.Tween(targ)
                        .UseCurve(curve)
                        .Wrap(this._wrapMode, ((DiscreteFloat.IsInfinity(this._wrapCount)) ? 0 : Mathf.RoundToInt(this._wrapCount)))
                        .Use(this._updateType)
                        .Use(_timeSupplier.TimeSupplier)
                        .Reverse(this._reverse)
                        .OnFinish(this.OnFinishHandler)
                        .Play(false);

            if (this._stopMovementOnDisable)
            {
                if (_activeTweens == null)
                {
                    _activeTweens = new HashSet <Tweener>();
                }
                _activeTweens.Add(tween);
            }

            return(true);
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = this._target.GetTarget <Transform>(arg);

            if (targ == null)
            {
                return(false);
            }
            if (_tweenEntireEntity)
            {
                targ = GameObjectUtil.FindRoot(targ).transform;
            }

            var loc = _location.GetTarget <Transform>(arg);

            if (targ == null || loc == null)
            {
                return(false);
            }

            var twn = SPTween.Tween(targ);

            twn.To("position", loc.position, _duration.Seconds);
            if (_orientWithLocationRotation)
            {
                twn.To("rotation", loc.rotation, _duration.Seconds);
            }

            twn.Use(_duration.TimeSupplier);
            twn.SetId(_target);

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true, _tweenToken);

            return(true);
        }
        protected override void OnDisable()
        {
            base.OnDisable();

            if (_killOnDisable)
            {
                SPTween.Find((t) =>
                {
                    if (t is ObjectTweener && (t as ObjectTweener).Target == _transition)
                    {
                        t.Kill();
                        return(true);
                    }
                    return(false);
                });
            }
        }
        public void FadeIn(float dur, EaseStyle ease = EaseStyle.LinearEaseIn, bool destroyOnComplete = true)
        {
            if (!_active) throw new System.InvalidOperationException("Cannot FadeIn a CameraFade that isnot currently faded out.");

            if (_tween != null)
            {
                _tween.Stop();
                _tween = null;
            }
            _totalDuration = dur;
            _direction = -1;

            _tween = SPTween.Tween(this.OnTweenStep, dur)
                            .Use(_timeSupplier ?? SPTime.Real)
                            .OnFinish(this.OnFadeInComplete)
                            .Play(false);
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(_tweenToken))
            {
                SPTween.KillAll(_target);
            }
            else
            {
                SPTween.KillAll(_target, _tweenToken);
            }

            return(true);
        }
        public override bool Trigger(object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            switch (_mode)
            {
            case TweenHash.AnimMode.To:
                _transition.Values[0].Value = _transition.GetValue();
                break;

            case TweenHash.AnimMode.From:
                _transition.Values[_transition.Values.Count - 1].Value = _transition.GetValue();
                break;
            }

            var twn = SPTween.Tween(_transition)
                      .FromTo("Position", 0f, 1f, _duration)
                      .SetId(this.AutoKillId)
                      .Use(_timeSupplier.TimeSupplier)
                      .Ease(EaseMethods.GetEase(_ease));

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true);

            return(true);
        }
예제 #11
0
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = _target.GetTarget <AudioSource>(arg);

            if (targ == null)
            {
                return(false);
            }
            if (!targ.isPlaying)
            {
                return(false);
            }

            if (_fadeOutDur > 0f)
            {
                float cache = targ.volume;
                SPTween.Tween(targ)
                .To("volume", 0f, _fadeOutDur)
                .OnFinish((s, e) =>
                {
                    targ.Stop();
                    targ.volume = cache;
                })
                .Play(true);
            }
            else
            {
                targ.Stop();
            }

            return(true);
        }
        public void FadeOut(float dur, EaseStyle ease = EaseStyle.LinearEaseOut)
        {
            _active = true;
            _fades.Add(this);

            if (_tween != null)
            {
                _tween.Stop();
                _tween = null;
            }
            _totalDuration = dur;
            _direction = 1;
            if(dur <= 0f)
            {
                this.OnFadeOutComplete(null, null);
            }
            else
            {
                _tween = SPTween.Tween(this.OnTweenStep, dur)
                                .Use(_timeSupplier ?? SPTime.Real)
                                .OnFinish(this.OnFadeOutComplete)
                                .Play(false);
            }
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var target = _target.GetTarget <UnityEngine.Object>(arg);

            if (target == null)
            {
                return(false);
            }

            var twn = SPTween.Tween(target);

            for (int i = 0; i < _data.Length; i++)
            {
                twn.ByAnimMode(_data[i].Mode, _data[i].MemberName, EaseMethods.GetEase(_data[i].Ease), _data[i].Duration, _data[i].ValueS.Value, _data[i].ValueE.Value, _data[i].Option);
            }
            twn.Use(_timeSupplier.TimeSupplier);
            twn.SetId(target);

            if (_onComplete?.HasReceivers ?? false)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick?.HasReceivers ?? false)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true, _tweenToken);
            return(true);
        }