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, ISkillContext, IAnimatorContext, IVfxContext, IStatesContext, IEpigraphicsContext { /// /// 随从没有血条等UI资源 /// 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(); #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(); /// /// 随从的身体镜像,所有武器默认向左,玩家左边的武器镜像翻转朝右 /// 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("Skeleton"); VfxRoot = collector.GetGameObject("VfxRoot").transform; Animator = collector.GetComponent("Animator"); } } }