DrawOrderTimeline.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Spine
  4. {
  5. public class DrawOrderTimeline : Timeline
  6. {
  7. public DrawOrderTimeline(int frameCount)
  8. {
  9. this.frames = new float[frameCount];
  10. this.drawOrders = new int[frameCount][];
  11. }
  12. public float[] Frames
  13. {
  14. get
  15. {
  16. return this.frames;
  17. }
  18. set
  19. {
  20. this.frames = value;
  21. }
  22. }
  23. public int[][] DrawOrders
  24. {
  25. get
  26. {
  27. return this.drawOrders;
  28. }
  29. set
  30. {
  31. this.drawOrders = value;
  32. }
  33. }
  34. public int FrameCount
  35. {
  36. get
  37. {
  38. return this.frames.Length;
  39. }
  40. }
  41. public void SetFrame(int frameIndex, float time, int[] drawOrder)
  42. {
  43. this.frames[frameIndex] = time;
  44. this.drawOrders[frameIndex] = drawOrder;
  45. }
  46. public void Apply(Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha)
  47. {
  48. float[] array = this.frames;
  49. if (time < array[0])
  50. {
  51. return;
  52. }
  53. int num;
  54. if (time >= array[array.Length - 1])
  55. {
  56. num = array.Length - 1;
  57. }
  58. else
  59. {
  60. num = Animation.binarySearch(array, time) - 1;
  61. }
  62. List<Slot> drawOrder = skeleton.drawOrder;
  63. List<Slot> slots = skeleton.slots;
  64. int[] array2 = this.drawOrders[num];
  65. if (array2 == null)
  66. {
  67. drawOrder.Clear();
  68. drawOrder.AddRange(slots);
  69. }
  70. else
  71. {
  72. int i = 0;
  73. int num2 = array2.Length;
  74. while (i < num2)
  75. {
  76. drawOrder[i] = slots[array2[i]];
  77. i++;
  78. }
  79. }
  80. }
  81. internal float[] frames;
  82. private int[][] drawOrders;
  83. }
  84. }