123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- namespace Spine
- {
- public class Animation
- {
- public Animation(string name, List<Timeline> timelines, float duration)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name cannot be null.");
- }
- if (timelines == null)
- {
- throw new ArgumentNullException("timelines cannot be null.");
- }
- this.name = name;
- this.timelines = timelines;
- this.duration = duration;
- }
- public string Name
- {
- get
- {
- return this.name;
- }
- }
- public List<Timeline> Timelines
- {
- get
- {
- return this.timelines;
- }
- set
- {
- this.timelines = value;
- }
- }
- public float Duration
- {
- get
- {
- return this.duration;
- }
- set
- {
- this.duration = value;
- }
- }
- public void Apply(Skeleton skeleton, float lastTime, float time, bool loop, List<Event> events)
- {
- if (skeleton == null)
- {
- throw new ArgumentNullException("skeleton cannot be null.");
- }
- if (loop && this.duration != 0f)
- {
- time %= this.duration;
- lastTime %= this.duration;
- }
- List<Timeline> list = this.timelines;
- int i = 0;
- int count = list.Count;
- while (i < count)
- {
- list[i].Apply(skeleton, lastTime, time, events, 1f);
- i++;
- }
- }
- public void Mix(Skeleton skeleton, float lastTime, float time, bool loop, List<Event> events, float alpha)
- {
- if (skeleton == null)
- {
- throw new ArgumentNullException("skeleton cannot be null.");
- }
- if (loop && this.duration != 0f)
- {
- time %= this.duration;
- lastTime %= this.duration;
- }
- List<Timeline> list = this.timelines;
- int i = 0;
- int count = list.Count;
- while (i < count)
- {
- list[i].Apply(skeleton, lastTime, time, events, alpha);
- i++;
- }
- }
- internal static int binarySearch(float[] values, float target, int step)
- {
- int num = 0;
- int num2 = values.Length / step - 2;
- if (num2 == 0)
- {
- return step;
- }
- int num3 = (int)((uint)num2 >> 1);
- for (;;)
- {
- if (values[(num3 + 1) * step] <= target)
- {
- num = num3 + 1;
- }
- else
- {
- num2 = num3;
- }
- if (num == num2)
- {
- break;
- }
- num3 = (int)((uint)(num + num2) >> 1);
- }
- return (num + 1) * step;
- }
- internal static int binarySearch(float[] values, float target)
- {
- int num = 0;
- int num2 = values.Length - 2;
- if (num2 == 0)
- {
- return 1;
- }
- int num3 = (int)((uint)num2 >> 1);
- for (;;)
- {
- if (values[num3 + 1] <= target)
- {
- num = num3 + 1;
- }
- else
- {
- num2 = num3;
- }
- if (num == num2)
- {
- break;
- }
- num3 = (int)((uint)(num + num2) >> 1);
- }
- return num + 1;
- }
- internal static int linearSearch(float[] values, float target, int step)
- {
- int i = 0;
- int num = values.Length - step;
- while (i <= num)
- {
- if (values[i] > target)
- {
- return i;
- }
- i += step;
- }
- return -1;
- }
- internal List<Timeline> timelines;
- internal float duration;
- internal string name;
- }
- }
|