123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using FL.Battle;
- using FL.Battle.Components;
- using Spine.Unity;
- using UnityEngine;
- using XGame.Framework.Map;
- using XGame.Framework.ObjectCollection;
- namespace FL.Map
- {
- public class PartnerEntityView : BattleEntityView<PartnerEntityVM>, ISkillContext, IAnimatorContext, IVfxContext, IStatesContext, IEpigraphicsContext
- {
- /// <summary>
- /// 随从没有血条等UI资源
- /// </summary>
- public override Transform UIPoint => null;
- protected override EEntityType DefaultTargetType => EEntityType.Monster;
- //public void FindTarget(int skillId)
- //{
- // Selector.FindAsync(this, EEntityType.Monster, (target) =>
- // {
- // SelectTarget(target, skillId);
- // });
- //}
- public IAnimator Animator => GetComponent<AnimatorComponent>();
- #region ISkillContext
- Transform ISkillContext.ActionRoot => VM.ActionRoot;
- void ISkillContext.OnSkillStart(int skillId)
- {
- }
- void ISkillContext.OnSkillStop(int skillId)
- {
- }
- #endregion
- //#region ISpineContext
- //SkeletonAnimation ISpineContext.Skeleton => VM.Skeleton;
- //#endregion
- #region IAnimatorContext
- Animator IAnimatorContext.Animator => VM.Animator;
- #endregion
- #region IVfxContext
- Transform IVfxContext.WorldTr => null;
- Transform IVfxContext.CenterTr => VM.Tr;
- Transform IVfxContext.CastTr => VM.VfxRoot;
- #endregion
- int IEpigraphicsContext.EpigraphId => (Entity as PartnerEntity).EpigraphId;
- public override EpigraphicsComponent Epigraphics => GetComponent<EpigraphicsComponent>();
- /// <summary>
- /// 随从的身体镜像,所有武器默认向左,玩家左边的武器镜像翻转朝右
- /// </summary>
- public void BodyMirror()
- {
- //var scale = Vector3.one * PartnerTableRepo.Get(Entity.TableId).Size;
- //scale.z = 1;
- //if (LocalPosition.x < 0)
- //{
- // scale.x *= -1;
- //}
- //VM.Skeleton.transform.localScale = scale;
- }
- }
- public class PartnerEntityVM : EntityViewModel
- {
- public Transform ActionRoot { get; private set; }
- public SkeletonAnimation Skeleton { get; private set; }
- public Transform VfxRoot { get; private set; }
- public Animator Animator { get; private set; }
- protected override void OnInit(IObjectCollector collector)
- {
- ActionRoot = collector.GetGameObject("ActionRoot").transform;
- Skeleton = collector.GetComponent<SkeletonAnimation>("Skeleton");
- VfxRoot = collector.GetGameObject("VfxRoot").transform;
- Animator = collector.GetComponent<Animator>("Animator");
- }
- }
- }
|