PartnerEntityView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 PartnerEntityView : BattleEntityView<PartnerEntityVM>, ISkillContext, IAnimatorContext, IVfxContext, IStatesContext, IEpigraphicsContext
  10. {
  11. /// <summary>
  12. /// 随从没有血条等UI资源
  13. /// </summary>
  14. public override Transform UIPoint => null;
  15. protected override EEntityType DefaultTargetType => EEntityType.Monster;
  16. //public void FindTarget(int skillId)
  17. //{
  18. // Selector.FindAsync(this, EEntityType.Monster, (target) =>
  19. // {
  20. // SelectTarget(target, skillId);
  21. // });
  22. //}
  23. public IAnimator Animator => GetComponent<AnimatorComponent>();
  24. #region ISkillContext
  25. Transform ISkillContext.ActionRoot => VM.ActionRoot;
  26. void ISkillContext.OnSkillStart(int skillId)
  27. {
  28. }
  29. void ISkillContext.OnSkillStop(int skillId)
  30. {
  31. }
  32. #endregion
  33. //#region ISpineContext
  34. //SkeletonAnimation ISpineContext.Skeleton => VM.Skeleton;
  35. //#endregion
  36. #region IAnimatorContext
  37. Animator IAnimatorContext.Animator => VM.Animator;
  38. #endregion
  39. #region IVfxContext
  40. Transform IVfxContext.WorldTr => null;
  41. Transform IVfxContext.CenterTr => VM.Tr;
  42. Transform IVfxContext.CastTr => VM.VfxRoot;
  43. #endregion
  44. int IEpigraphicsContext.EpigraphId => (Entity as PartnerEntity).EpigraphId;
  45. public override EpigraphicsComponent Epigraphics => GetComponent<EpigraphicsComponent>();
  46. /// <summary>
  47. /// 随从的身体镜像,所有武器默认向左,玩家左边的武器镜像翻转朝右
  48. /// </summary>
  49. public void BodyMirror()
  50. {
  51. //var scale = Vector3.one * PartnerTableRepo.Get(Entity.TableId).Size;
  52. //scale.z = 1;
  53. //if (LocalPosition.x < 0)
  54. //{
  55. // scale.x *= -1;
  56. //}
  57. //VM.Skeleton.transform.localScale = scale;
  58. }
  59. }
  60. public class PartnerEntityVM : EntityViewModel
  61. {
  62. public Transform ActionRoot { get; private set; }
  63. public SkeletonAnimation Skeleton { get; private set; }
  64. public Transform VfxRoot { get; private set; }
  65. public Animator Animator { get; private set; }
  66. protected override void OnInit(IObjectCollector collector)
  67. {
  68. ActionRoot = collector.GetGameObject("ActionRoot").transform;
  69. Skeleton = collector.GetComponent<SkeletonAnimation>("Skeleton");
  70. VfxRoot = collector.GetGameObject("VfxRoot").transform;
  71. Animator = collector.GetComponent<Animator>("Animator");
  72. }
  73. }
  74. }