PlayerEntityView.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using FL.Battle;
  2. using FL.Battle.Components;
  3. using Spine.Unity;
  4. using UnityEngine;
  5. using XGame.Framework.Map;
  6. using XGame.Framework.ObjectCollection;
  7. namespace FL.Map
  8. {
  9. public class PlayerEntityView : BattleEntityView<PlayerEntityVM>, ISkillContext, ISpineContext, IVfxContext, IStatesContext
  10. {
  11. public override Transform UIPoint => VM.UIPoint;
  12. protected override EEntityType DefaultTargetType => EEntityType.Monster;
  13. //public void FindTarget(int skillId)
  14. //{
  15. // Selector.FindAsync(this, EEntityType.Monster, (target) =>
  16. // {
  17. // SelectTarget(target, skillId);
  18. // });
  19. //}
  20. public IAnimator Animator => GetComponent<SpineComponent>();
  21. #region ISkillContext
  22. Transform ISkillContext.ActionRoot => VM.ActionRoot;
  23. void ISkillContext.OnSkillStart(int skillId)
  24. {
  25. }
  26. void ISkillContext.OnSkillStop(int skillId)
  27. {
  28. }
  29. #endregion
  30. #region ISpineContext
  31. SkeletonAnimation ISpineContext.Skeleton => VM.PlayerSkeleton;
  32. #endregion
  33. #region IVfxContext
  34. Transform IVfxContext.WorldTr => null;
  35. Transform IVfxContext.CenterTr => VM.Tr;
  36. Transform IVfxContext.CastTr => VM.VfxRoot;
  37. #endregion
  38. public override EpigraphicsComponent Epigraphics => null;
  39. }
  40. public class PlayerEntityVM : EntityViewModel
  41. {
  42. public Transform ActionRoot { get; private set; }
  43. public SkeletonAnimation PlayerSkeleton { get; private set; }
  44. public Transform VfxRoot { get; private set; }
  45. public Transform UIPoint { get; private set; }
  46. protected override void OnInit(IObjectCollector collector)
  47. {
  48. ActionRoot = collector.GetGameObject("ActionRoot").transform;
  49. PlayerSkeleton = collector.GetComponent<SkeletonAnimation>("PlayerSkeleton");
  50. VfxRoot = collector.GetGameObject("VfxRoot").transform;
  51. UIPoint = collector.GetGameObject("UIPoint").transform;
  52. }
  53. }
  54. }