Exemplo n.º 1
0
 internal TransitionItem()
 {
     this.easeType   = Ease.OutQuad;
     this.value      = new TransitionValue();
     this.startValue = new TransitionValue();
     this.endValue   = new TransitionValue();
 }
Exemplo n.º 2
0
 internal void Copy(TransitionValue source)
 {
     this.f.x = source.f.x;
     this.f.y = source.f.y;
     this.f3  = source.f3;
     this.i   = source.i;
     this.c   = source.c;
     this.b   = source.b;
     this.s   = source.s;
     this.b1  = source.b1;
     this.b2  = source.b2;
 }
Exemplo n.º 3
0
        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();
                }
            }
        }
Exemplo n.º 4
0
        private void DecodeValue(TransitionActionType type, string str, TransitionValue value)
        {
            string[] arr;
            switch (type)
            {
            case TransitionActionType.XY:
            case TransitionActionType.Size:
                arr = str.Split(',');
                if (arr[0] == "-")
                {
                    value.b1 = false;
                }
                else
                {
                    value.f.x = float.Parse(arr[0]);
                    value.b1  = true;
                }
                if (arr[1] == "-")
                {
                    value.b2 = false;
                }
                else
                {
                    value.f.y = float.Parse(arr[1]);
                    value.b2  = true;
                }
                break;

            case TransitionActionType.Alpha:
            case TransitionActionType.Rotation:
                value.f.x = float.Parse(str);
                break;

            case TransitionActionType.Scale:
                arr       = str.Split(',');
                value.f.x = float.Parse(arr[0]);
                value.f.y = float.Parse(arr[1]);
                break;

            case TransitionActionType.Pivot:
                arr       = str.Split(',');
                value.f.x = float.Parse(arr[0]);
                value.f.y = 1 - float.Parse(arr[1]);
                break;

            case TransitionActionType.Color:
                value.c   = ToolSet.ConvertFromHtmlColor(str);
                value.c.a = 1f;
                break;

            case TransitionActionType.Animation:
                arr = str.Split(',');
                if (arr[0] == "-")
                {
                    value.b1 = false;
                }
                else
                {
                    value.i  = int.Parse(arr[0]);
                    value.b1 = true;
                }
                value.b = arr[1] == "p";
                break;

            case TransitionActionType.Visible:
                value.b = str == "true";
                break;

            case TransitionActionType.Controller:
                value.s = str;
                break;

            case TransitionActionType.Sound:
                arr     = str.Split(',');
                value.s = arr[0];
                if (arr.Length > 1)
                {
                    int intv = int.Parse(arr[1]);
                    if (intv == 100 || intv == 0)
                    {
                        value.f.x = 1;
                    }
                    else
                    {
                        value.f.x = intv / 100f;
                    }
                }
                else
                {
                    value.f.x = 1;
                }
                break;

            case TransitionActionType.Transition:
                arr     = str.Split(',');
                value.s = arr[0];
                value.i = arr.Length > 1 ? int.Parse(arr[1]) : 1;
                break;

            case TransitionActionType.Shake:
                arr       = str.Split(',');
                value.f.x = float.Parse(arr[0]);
                value.f.y = float.Parse(arr[1]);
                break;
            }
        }
Exemplo n.º 5
0
        private void ApplyValue(TransitionItem item, TransitionValue value)
        {
            switch (item.type)
            {
            case TransitionActionType.XY:
            case TransitionActionType.Shake:
                item.target.SetGearState(GObject.GearState.Position, true);
                item.target.position = value.f;
                item.target.SetGearState(GObject.GearState.Position, false);
                break;

            case TransitionActionType.Size:
                item.target.SetGearState(GObject.GearState.Size, true);
                item.target.size = value.f;
                item.target.SetGearState(GObject.GearState.Size, false);
                break;

            case TransitionActionType.Pivot:
                item.target.pivot = value.f;
                break;

            case TransitionActionType.Alpha:
                item.target.SetGearState(GObject.GearState.Look, true);
                item.target.alpha = value.f.x;
                item.target.SetGearState(GObject.GearState.Look, false);
                break;

            case TransitionActionType.Rotation:
                item.target.SetGearState(GObject.GearState.Look, true);
                item.target.rotation = value.f.x;
                item.target.SetGearState(GObject.GearState.Look, false);
                break;

            case TransitionActionType.Scale:
                item.target.SetGearState(GObject.GearState.Size, true);
                item.target.scale = value.f;
                item.target.SetGearState(GObject.GearState.Size, false);
                break;

            case TransitionActionType.Color:
                item.target.SetGearState(GObject.GearState.Color, true);
                item.target.color = value.c;
                item.target.SetGearState(GObject.GearState.Color, false);
                break;

            case TransitionActionType.Animation:
                item.target.SetGearState(GObject.GearState.Animation, true);
                (( IAnimationGear )item.target).frame   = value.i;
                (( IAnimationGear )item.target).playing = value.b;
                item.target.SetGearState(GObject.GearState.Animation, false);
                break;

            case TransitionActionType.Visible:
                item.target.visible = value.b;
                break;

            case TransitionActionType.Controller:
                string[] arr = value.s.Split(',');
                foreach (string str in arr)
                {
                    string[]   arr2 = str.Split('=');
                    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();
                    }
                    else if (trans.playing)
                    {
                        trans._totalTimes = value.i == -1 ? int.MaxValue : value.i;
                    }
                    else
                    {
                        if (this._reversed)
                        {
                            trans.PlayReverse(value.i);
                        }
                        else
                        {
                            trans.Play(value.i);
                        }
                    }
                }
                break;

            case TransitionActionType.Sound:
                AudioClip sound = UIPackage.GetItemAssetByURL(value.s) as AudioClip;
                if (sound != null)
                {
                    Stage.inst.PlayOneShotSound(sound, value.f.x);
                }
                break;
            }
        }