UnitRenderComponet.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using UnityEngine;
  2. using Mono;
  3. using System.Collections.Generic;
  4. using AniType = Mono.AnimationData.AnimationType;
  5. using FairyGUI;
  6. namespace ET.Client
  7. {
  8. [ChildOf(typeof(ModelViewComponent))]
  9. public class UnitRenderComponet : Entity, IAwake<GameObject>, IUpdate, IDestroy
  10. {
  11. public static readonly AnimatorCommand CMDIdle = new AnimatorCommand(AniType.Idle, true);
  12. public static readonly AnimatorCommand CMDRun = new AnimatorCommand(AniType.Run, true);
  13. public static readonly AnimatorCommand CMDDead = new AnimatorCommand(AniType.Dead);
  14. //指令队列
  15. public List<AnimatorCommand> Commands = new ();
  16. public GameObject GameObject { get; set; }
  17. public AnimationData AniData;
  18. public AnimatorCommand DoingCmd;
  19. public GComponent HeadBar;
  20. public Transform HeadPartTrans;
  21. //TODO: 获得模型绑定部件,如不存在返回Root
  22. public Transform GetBindPart(string partName)
  23. {
  24. return GameObject.transform;
  25. }
  26. public void Reset()
  27. {
  28. GameObject = null;
  29. AniData = null;
  30. DoingCmd = null;
  31. HeadBar = null;
  32. HeadPartTrans = null;
  33. }
  34. }
  35. //TODO: 支持ObjectPool
  36. public class AnimatorCommand
  37. {
  38. public AniType Type;
  39. public float Duration = -1f;
  40. public float Speed = 1.0f;
  41. public uint GroupId = 0;
  42. public bool Loop = false;
  43. public AnimatorCommand(AniType type, bool loop = false)
  44. {
  45. this.Type = type;
  46. this.Loop = loop;
  47. }
  48. public bool IsSkillCmd()
  49. {
  50. return Type >= AniType.Skill0 && Type < AniType.SkillMax;
  51. }
  52. }
  53. }