UnitRenderComponet.cs 1.6 KB

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