AniManager.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using GameFramework.Event;
  6. using UnityEngine.UI;
  7. using RootMotion.FinalIK;
  8. using System.Linq;
  9. namespace MetaClient
  10. {
  11. public class AniManager : MonoBehaviour
  12. {
  13. public static AniManager Instance;
  14. public Dictionary<string, List<BonePicTarget>> aniBPT = new Dictionary<string, List<BonePicTarget>>();
  15. public Dictionary<string, List<BoneData>> bonedata = new Dictionary<string, List<BoneData>>();
  16. public EIKPickOnButtonStyple eIKPickOnButtonStyple = EIKPickOnButtonStyple.None;
  17. public CCDIK cCDIK = null;
  18. public float dis = 0.5f;
  19. public Transform picParent;
  20. public List<Transform> bones = new List<Transform>();
  21. public List<BonePicTarget> chooseImage = new List<BonePicTarget>();
  22. public List<BonePicTarget> bonePicTarget = new List<BonePicTarget>();
  23. private int nowtime = 0;
  24. public string nowAniName = "8";
  25. //private
  26. // Start is called before the first frame update
  27. //public Dictionary<string,>
  28. void Start()
  29. {
  30. bones.ForEach(i =>
  31. {
  32. Vector3 worldPos = i.position;
  33. Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos);
  34. GameObject imgObj = new GameObject();
  35. GameObject target = new GameObject();
  36. target.transform.position = i.position;
  37. var image = imgObj.AddComponent<Image>();
  38. image.color = Color.red;
  39. //if (aniBPT.ContainsKey(i.name)||i.name=="8")
  40. //{
  41. // i.name = "All";
  42. //}
  43. //else
  44. //{
  45. imgObj.name = i.name;
  46. //}
  47. imgObj.transform.position = screenPos;
  48. imgObj.transform.SetParent(picParent);
  49. imgObj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
  50. BonePicTarget _bonePicTarget = new BonePicTarget(i, imgObj.transform, target.transform);
  51. bonePicTarget.Add(_bonePicTarget);
  52. AniPickOnImage pickOnImage = imgObj.AddComponent<AniPickOnImage>();
  53. pickOnImage.bonePicTarget = _bonePicTarget;
  54. pickOnImage.bonePicture = this;
  55. //BoneRotateByTime boneRotateByTime = i.gameObject.AddComponent<BoneRotateByTime>();
  56. // boneRotateByTimes.Add(boneRotateByTime);
  57. });
  58. }
  59. private void Awake()
  60. {
  61. Instance = this;
  62. }
  63. public void Init()
  64. {
  65. GameEntry.Event.Subscribe(AniEventArgs.EventId, UpdateAni);
  66. }
  67. public void SaveMove(string boneName)
  68. {
  69. }
  70. private void UpdateAni(object sender, GameEventArgs e)
  71. {
  72. AniEventArgs crf = (AniEventArgs)e;
  73. if (crf != null)
  74. {
  75. switch (crf.Type)
  76. {
  77. case EAniEventArgsType.None:
  78. break;
  79. case EAniEventArgsType.RotateX:
  80. break;
  81. case EAniEventArgsType.RotateY:
  82. break;
  83. case EAniEventArgsType.Move:
  84. break;
  85. case EAniEventArgsType.PlayKTime:
  86. break;
  87. case EAniEventArgsType.MoveKTime:
  88. break;
  89. case EAniEventArgsType.CopyKTime:
  90. break;
  91. case EAniEventArgsType.DelectKTime:
  92. break;
  93. }
  94. }
  95. }
  96. public void SavePart(EAniBodyPart eAniBodyPart,int time)
  97. {
  98. switch (eAniBodyPart)
  99. {
  100. case EAniBodyPart.None:
  101. break;
  102. case EAniBodyPart.Head:
  103. break;
  104. case EAniBodyPart.Node:
  105. break;
  106. case EAniBodyPart.Xiong:
  107. break;
  108. case EAniBodyPart.Yao:
  109. break;
  110. case EAniBodyPart.FuBu:
  111. break;
  112. case EAniBodyPart.LefftHand:
  113. break;
  114. case EAniBodyPart.RightHand:
  115. break;
  116. case EAniBodyPart.LeftArm:
  117. break;
  118. case EAniBodyPart.RightArm:
  119. break;
  120. case EAniBodyPart.LeftLeg:
  121. break;
  122. case EAniBodyPart.RightLeg:
  123. break;
  124. case EAniBodyPart.All:
  125. break;
  126. }
  127. }
  128. public void Clear() {
  129. GameEntry.Event.Unsubscribe(AniEventArgs.EventId, UpdateAni);
  130. }
  131. // Update is called once per frame
  132. void Update()
  133. {
  134. }
  135. }
  136. public class BonePicTarget
  137. {
  138. public Transform bone;
  139. public Transform pic;
  140. public Transform target;
  141. public BonePicTarget(Transform _bone, Transform _pic, Transform _target)
  142. {
  143. bone = _bone;
  144. pic = _pic;
  145. target = _target;
  146. }
  147. }
  148. public enum EIKPickOnButtonStyple
  149. {
  150. None,
  151. Choose,
  152. Rotate,
  153. Move
  154. }
  155. public enum EAniBodyPart {
  156. None,
  157. Head,
  158. Node,
  159. Xiong,
  160. Yao,
  161. FuBu,
  162. LeftArm,
  163. RightArm,
  164. LefftHand,
  165. RightHand,
  166. LeftLeg,
  167. RightLeg,
  168. All,
  169. }
  170. public class BoneData {
  171. public string Name;
  172. public Dictionary<int, Quaternion> Ro;
  173. public Dictionary<int, Vector3> Pos;
  174. }
  175. }