예제 #1
0
        public override void Apply()
        {
            GearLookValue gv;

            if (!this._storage.TryGetValue(this._controller.selectedPageId, out gv))
            {
                gv = this._default;
            }

            if (this.tween && UIPackage.constructing == 0 && !disableAllTweenEffect)
            {
                this._owner.SetGearState(GObject.GearState.Look, true);
                this._owner.grayed = gv.grayed;
                this._owner.SetGearState(GObject.GearState.Look, false);

                if (this._tweener != null)
                {
                    if (this._tweenTarget.alpha != gv.alpha || this._tweenTarget.rotation != gv.rotation)
                    {
                        this._tweener.Kill(true);
                        this._tweener = null;
                    }
                    else
                    {
                        return;
                    }
                }

                bool a = !Mathf.Approximately(gv.alpha, this._owner.alpha);
                bool b = !Mathf.Approximately(gv.rotation, this._owner.rotation);
                if (a || b)
                {
                    this._tweenTarget = gv;
                    this._tweener     = DOTween.To(() => new Vector2(this._owner.alpha, this._owner.rotation), val =>
                    {
                        this._owner.SetGearState(GObject.GearState.Look, true);
                        if (a)
                        {
                            this._owner.alpha = val.x;
                        }
                        if (b)
                        {
                            this._owner.rotation = val.y;
                        }
                        this._owner.SetGearState(GObject.GearState.Look, false);
                    }, new Vector2(gv.alpha, gv.rotation), this.tweenTime)
                                        .SetEase(this.easeType)
                                        .SetUpdate(true)
                                        .OnComplete(() =>
                    {
                        this._tweener = null;
                    });

                    if (this.delay > 0)
                    {
                        this._tweener.SetDelay(this.delay);
                    }
                }
            }
            else
            {
                this._owner.SetGearState(GObject.GearState.Look, true);
                this._owner.alpha    = gv.alpha;
                this._owner.rotation = gv.rotation;
                this._owner.grayed   = gv.grayed;
                this._owner.SetGearState(GObject.GearState.Look, false);
            }
        }
예제 #2
0
 protected override void Init()
 {
     this._default = new GearLookValue(this._owner.alpha, this._owner.rotation, this._owner.grayed);
     this._storage = new Dictionary <string, GearLookValue>();
 }