Esempio n. 1
0
 public virtual void DoRestore(Hashtable dict)
 {
     phaseList.DoRestoreList(dict["phase_arrayList"] as ArrayList, (subDict) =>
     {
         AbstractPhase <T> phase = new AbstractPhase <T>();
         phase.DoRestore(subDict);
         return(phase);
     });
     durationTick = dict["duration_tick"].ToIntOrToDefault();
     isLoop       = dict["is_loop"].ToBoolOrToDefault();
 }
Esempio n. 2
0
        //lerp_tick的范围在[0, 这个this的duration_tick]之间
        public T Tween(AbstractPhase <T> toPhase, int lerpTick, Func <T, T, float, T> lerpCallback)
        {
            T fromValue = value;

            if (toPhase == null)
            {
                return(fromValue);
            }
            T toValue = toPhase.value;

            return(lerpCallback(fromValue, toValue, (float)lerpTick / durationTick));
        }
Esempio n. 3
0
 public override ColliderListInfo Lerp(AbstractPhase <ColliderListInfo> toPhase, int lerpTick)
 {
     return(this.Tween(toPhase, lerpTick,
                       (fromValue, toValue, t) =>
     {
         ColliderListInfo colliderListInfo = new ColliderListInfo();
         colliderListInfo.center = Vector3.Lerp(fromValue.center, toValue.center, t);
         colliderListInfo.atkBoxList = fromValue.atkBoxList;
         colliderListInfo.hitBoxList = fromValue.hitBoxList;
         return colliderListInfo;
     }));
 }
Esempio n. 4
0
        public T GetSnapshot(int targetTick)
        {
            if (targetTick < 0)
            {
                throw new ArgumentException(string.Format("Tick should be zero or positive number. tick:{0}", targetTick));
            }
            if (this.isLoop && targetTick >= this.durationTick)
            {
                targetTick = this.durationTick != 0 ? targetTick % this.durationTick : 0;
            }
            int n        = 0;
            int lerpTick = 0;
            AbstractPhase <T> fromPhase = null;
            AbstractPhase <T> toPhase   = null;

            for (int i = 0; i < this.phaseList.Count; i++)
            {
                AbstractPhase <T> phase = this.phaseList[i];
                n += phase.durationTick;
                if (n > targetTick)
                {
                    fromPhase = phase;
                    toPhase   = i + 1 < this.phaseList.Count ? this.phaseList[i + 1] : null;
                    lerpTick  = targetTick - (n - phase.durationTick);
                    break;
                }
            }
            if (fromPhase == null)
            {
                fromPhase = this.phaseList[this.phaseList.Count - 1];
                toPhase   = null;
                lerpTick  = 0;
            }
            T result = fromPhase.Lerp(toPhase, lerpTick);

            return(result);
        }
Esempio n. 5
0
 public virtual T Lerp(AbstractPhase <T> toPhase, int lerpTick)
 {
     return(default(T));
 }
Esempio n. 6
0
 public override Vector3 Lerp(AbstractPhase <Vector3> toPhase, int lerpTick)
 {
     return(this.Tween(toPhase, lerpTick,
                       (fromValue, toValue, t) => Vector3.Lerp(fromValue, toValue, t)));
 }
Esempio n. 7
0
 public override float Lerp(AbstractPhase <float> toPhase, int lerpTick)
 {
     return(this.Tween(toPhase, lerpTick,
                       (fromValue, toValue, t) => Mathf.Lerp(fromValue, toValue, t)));
 }