public void RoughFFrames_to_Animation(List <FFrame> fframes) { AnAnimation aa = new AnAnimation(); animations = new AnAnimation[1]; aa.frames = new Frame[fframes.Count]; for (int i = 0; i < fframes.Count; i++) { //find lowest int lowestId = 9999; for (int b = 0; b < fframes.Count; b++) { if (fframes[b].order < lowestId) { lowestId = b; } } //harvest lowest aa.frames[i] = new Frame(fframes[lowestId].x, fframes[lowestId].y, fframes[lowestId].time, fframes[lowestId].size); fframes.RemoveAt(lowestId); } animations[0] = aa; }
void Update() { if (animations != null && animations.Length > 0) { AnAnimation ani = animations[0]; Frame frame = animations[0].frames[ani.currentFrame]; if (frame.time < 0) { if (frame.time == -1) { ani.currentFrame = Random.Range(0, ani.frames.Length); } SetFrame(ani); this.enabled = false; } else { if (fa.time >= (ani.timeSet + ani.delay)) { //then advance the frame ani.currentFrame++; ani.timeSet = fa.time; if (ani.currentFrame >= ani.frames.Length) { //how do I handle the end of the animation? switch (ani.endOfAnimation) { case EndOfAnimation.Stick: ani.delay = -1; ani.currentFrame--; break; case EndOfAnimation.Loop: ani.currentFrame = 0; ani.delay = frame.time; break; case EndOfAnimation.Switch: ani.delay = -1; ani.currentFrame = 0; PlayAnimation(ani.switchToId); break; } } ani.delay = frame.time; SetFrame(ani); } } } }
public void SetFrame(AnAnimation ani) { SetTexture(ani.frames[ani.currentFrame].x, ani.frames[ani.currentFrame].y, go, ani.frames[ani.currentFrame].size, meshFilter); }