MonsterEntityView.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 MonsterEntityView : BattleEntityView<MonsterEntityVM>, ISkillContext, ISpineContext, IVfxContext, IStatesContext
  10. {
  11. public override Transform UIPoint => VM.UIPoint;
  12. protected override EEntityType DefaultTargetType => EEntityType.Player;
  13. //public void FindTarget(int skillId)
  14. //{
  15. // Selector.FindAsync(this, EEntityType.Player, (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.Skeleton;
  26. #endregion
  27. #region IVfxContext
  28. Transform IVfxContext.WorldTr => null;
  29. Transform IVfxContext.CenterTr => VM.Tr;
  30. Transform IVfxContext.CastTr => VM.Tr;
  31. #endregion
  32. public override EpigraphicsComponent Epigraphics => null;
  33. }
  34. public class MonsterEntityVM : EntityViewModel
  35. {
  36. public Transform ActionRoot { get; private set; }
  37. public Transform UIPoint { get; private set; }
  38. public SkeletonAnimation Skeleton { get; private set; }
  39. protected override void OnInit(IObjectCollector collector)
  40. {
  41. ActionRoot = collector.GetGameObject("ActionRoot").transform;
  42. UIPoint = collector.GetGameObject("UIPoint").transform;
  43. Skeleton = collector.GetComponent<SkeletonAnimation>("Skeleton");
  44. }
  45. }
  46. }