PlayerEntityView.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #endregion
  24. #region ISpineContext
  25. SkeletonAnimation ISpineContext.Skeleton => VM.PlayerSkeleton;
  26. #endregion
  27. #region IVfxContext
  28. Transform IVfxContext.WorldTr => null;
  29. Transform IVfxContext.CenterTr => VM.Tr;
  30. Transform IVfxContext.CastTr => VM.VfxRoot;
  31. #endregion
  32. public override EpigraphicsComponent Epigraphics => null;
  33. }
  34. public class PlayerEntityVM : EntityViewModel
  35. {
  36. public Transform ActionRoot { get; private set; }
  37. public SkeletonAnimation PlayerSkeleton { get; private set; }
  38. public Transform VfxRoot { get; private set; }
  39. public Transform UIPoint { get; private set; }
  40. protected override void OnInit(IObjectCollector collector)
  41. {
  42. ActionRoot = collector.GetGameObject("ActionRoot").transform;
  43. PlayerSkeleton = collector.GetComponent<SkeletonAnimation>("PlayerSkeleton");
  44. VfxRoot = collector.GetGameObject("VfxRoot").transform;
  45. UIPoint = collector.GetGameObject("UIPoint").transform;
  46. }
  47. }
  48. }