AMBinaryTranslation.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class AMBinaryTranslation : AMBinaryDataBaseObject
  6. {
  7. public static bool CheckType(AMTrack track)
  8. {
  9. return !(track == null) && track.getTrackType() == AMBinaryTranslation.kTypeName;
  10. }
  11. public override void Update(int frame)
  12. {
  13. this.trans_.position = this.pos_array[frame];
  14. }
  15. public override void Write(BinaryWriter binary)
  16. {
  17. List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>();
  18. Vector3[] array = base.Compression<Vector3>(ref this.pos_array, out list);
  19. base.Write(binary);
  20. for (int i = 0; i < this.pos_array.Length; i++)
  21. {
  22. binary.Write(this.pos_array[i].x);
  23. binary.Write(this.pos_array[i].y);
  24. binary.Write(this.pos_array[i].z);
  25. }
  26. }
  27. public override void Read(BinaryReader binary)
  28. {
  29. base.Read(binary);
  30. this.pos_array = new Vector3[this.total_frame];
  31. for (int i = 0; i < this.pos_array.Length; i++)
  32. {
  33. Vector3 zero = Vector3.zero;
  34. zero.x = binary.ReadSingle();
  35. zero.y = binary.ReadSingle();
  36. zero.z = binary.ReadSingle();
  37. this.pos_array[i] = zero;
  38. }
  39. this.trans_ = base.obj.transform;
  40. }
  41. public override void SetGameObject(GameObject new_obj)
  42. {
  43. base.obj = new_obj;
  44. this.trans_ = base.obj.transform;
  45. }
  46. public override string type_name
  47. {
  48. get
  49. {
  50. return AMBinaryTranslation.kTypeName;
  51. }
  52. }
  53. public static string kTypeName = "Translation";
  54. public Transform trans_;
  55. public Vector3[] pos_array;
  56. }