yyl
2026-02-09 5a4e34c8a85737c0fa5b5775122da31155cbaef3
Main/System/Battle/BattleObject/HeroBattleObject.cs
@@ -15,6 +15,11 @@
    public GameObject heroGo => _heroGo;
    public MotionBase motionBase;
    public TeamHero teamHero { get; private set; }
    // Buff 管理器(只有 Hero 有 buff 系统)
    public BattleObjectBuffMgr buffMgr;
    private RectTransform m_heroRectTrans;
@@ -53,13 +58,15 @@
    public void Init(GameObject _heroGo, TeamHero _teamHero, BattleCamp _camp)
    {
        this._heroGo = _heroGo;
        Init(_teamHero, _camp);
    }
    public override void Init(TeamHero _teamHero, BattleCamp _camp)
    {
        teamHero = _teamHero;
        Camp = _camp;
        ObjID = _teamHero.ObjID;
        InitInternal();
    }
    private void InitInternal()
    {
        motionBase = new MotionBase();
        motionBase.Init(_heroGo.GetComponentInChildren<SkeletonAnimation>(true));
        buffMgr = new BattleObjectBuffMgr();
@@ -89,6 +96,41 @@
            heroInfoBar.SetActive(true);
        }
        SetFront();
        if (battleField.ToString() != BattleConst.StoryBattleField &&
            battleField.ToString() != BattleConst.TianziBillboradBattleField)
        {
            var hitArea = heroGo.GetComponent<Image>();
            if (hitArea == null)
            {
                hitArea = heroGo.AddComponent<Image>();
                hitArea.color = new Color(0, 0, 0, 0); //让射线检测到
            }
            var btn = heroGo.GetComponent<ButtonEx>();
            if (btn == null)
            {
                btn = heroGo.AddComponent<ButtonEx>();
                btn.interval = 0.5f;// 防止频繁连续点击
            }
            btn.AddListener(() =>
            {
                // 判断点击的是我方阵营还是敌方阵营,目前左边都是我方阵营
                bool isMySide = Camp == BattleCamp.Red;
                EventBroadcast.Instance.Broadcast(EventName.BATTLE_CLICK_HERO, new BattleClickHeroData()
                {
                    battleName = battleField.ToString(),
                    isMySide = isMySide,
                    mapID = battleField.MapID,
                    funcLineID = battleField.FuncLineID,
                    npcID = teamHero.NPCID,
                    posNum = teamHero.positionNum,
                    heroID = teamHero.heroId,
                    teams = battleField?.battleObjMgr.GetBattleObjList(isMySide ? BattleCamp.Red : BattleCamp.Blue),
                });
            });
        }
    }
    public override void Run()
@@ -144,9 +186,9 @@
        }
    }
    
    public override Spine.TrackEntry PlaySkillAnimation(SkillConfig skillConfig, SkillBase skillBase, bool isCounter, Action onComplete)
    public override Spine.TrackEntry PlaySkillAnimation(SkillConfig skillConfig, SkillSkinConfig skillSkinConfig, SkillBase skillBase, bool isCounter, Action onComplete)
    {
        return motionBase.PlaySkillAnimation(skillConfig, skillBase, isCounter, onComplete);
        return motionBase.PlaySkillAnimation(skillConfig, skillSkinConfig, skillBase, isCounter, onComplete);
    }
    
    public override bool CanStartDeath()
@@ -154,9 +196,9 @@
        return motionBase.CanStartDeath();
    }
    
    public override bool CanCastSkillAnimation(SkillConfig skillConfig)
    public override bool CanCastSkillAnimation(SkillSkinConfig skillSkinConfig)
    {
        return motionBase.CanCastSkill(skillConfig);
        return motionBase.CanCastSkill(skillSkinConfig);
    }
    
    public override SkeletonAnimation GetSkeletonAnimation()
@@ -297,7 +339,7 @@
    public override DeathRecordAction Hurt(BattleHurtParam battleHurtParam, SkillRecordAction _parentSkillAction = null)
    {
        DeathRecordAction recordAction = null;
        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillSkinConfig.DamageDivide.Length - 1;
        bool firstHit = battleHurtParam.hitIndex == 0;
        
        // 添加调试日志
@@ -307,9 +349,10 @@
        // ============ 应用目标的血量和护盾变化 ============
        ApplyHurtToTarget(battleHurtParam, isLastHit);
        //  这里
        if (dmgInfo.IsType(DamageType.Dodge) /*&& !buffMgr.isControled[BattleConst.HardControlGroup]*/)//如果被控制了还闪避了 要看看服务器怎么处理了
        if (dmgInfo.IsType(DamageType.Dodge) || dmgInfo.IsType(DamageType.CompletelyDodge))//如果被控制了还闪避了 要看看服务器怎么处理了
        {
            if (isLastHit)
            {
@@ -323,7 +366,7 @@
            if (firstHit)
            {
                OnDodgeBegin();
                OnDodgeBegin(dmgInfo.IsType(DamageType.Dodge) ? DamageType.Dodge : DamageType.CompletelyDodge);
            }
        }
@@ -380,7 +423,7 @@
    const float pingpongTime = 0.4f;
    //  闪避开始
    public override void OnDodgeBegin()
    public override void OnDodgeBegin(DamageType damageType)
    {
        RectTransform rectTrans = heroRectTrans;
        var tween = rectTrans.DOAnchorPos(new Vector3(-30, 0, 0), pingpongTime)
@@ -388,7 +431,9 @@
        motionBase.ShowIllusionShadow(true);
        DamageNumConfig damageNumConfig = DamageNumConfig.Get((int)DamageType.Dodge);
        int damageTypeInt = damageType == DamageType.Dodge ? (int)damageType : BattleConst.CompletelyDodge;
        DamageNumConfig damageNumConfig = DamageNumConfig.Get(damageTypeInt);
        string dodgeStr = ((char)damageNumConfig.prefix).ToString();
@@ -481,6 +526,37 @@
        motionBase.ResetForReborn(false);
        isReborning = false;
    }
    // ============ 实现抽象访问方法 ============
    public override BattleObjectBuffMgr GetBuffMgr() => buffMgr;
    public override int GetPositionNum() => teamHero.positionNum;
    public override float GetModelScale() => teamHero.modelScale;
    public override string GetName() => teamHero.name;
    protected override bool GetIsStunned() => teamHero.isStunned;
    protected override bool GetIsFrozen() => teamHero.isFrozen;
    protected override bool GetIsStoned() => teamHero.isStoned;
    protected override bool GetIsSlient() => teamHero.isSlient;
    protected override bool GetIsDisarmed() => teamHero.isDisarmed;
    protected override bool GetIsInvincible() => teamHero.isInvinceble;
    protected override bool GetIsDead() => teamHero.isDead;
    public override int GetRage() => teamHero.rage;
    protected override void ApplyCasterHpChange(long newHp)
    {
        if (teamHero == null) return;
        teamHero.curHp = newHp;
    }
    public override long GetCurHp() => teamHero == null ? 0 : teamHero.curHp;
    public override long GetMaxHp() => teamHero == null ? 0 : teamHero.maxHp;
    public override void SetCurHp(long value) { if (teamHero == null) return; teamHero.curHp = value; }
    public override void SetIsDead(bool value) { if (teamHero == null) return; teamHero.isDead = value; }
    public override int GetNPCID() => teamHero == null ? 0 : teamHero.NPCID;
    public override long GetFightPower() => teamHero == null ? 0 : teamHero.fightPower;
    // 伤害还要看 是否闪避 暴击 and so on 需要有一个DamageType 服务器应该会给
    protected override BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
@@ -628,7 +704,7 @@
        }
        // ============ 应用施法者的血量和护盾变化 ============
        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillSkinConfig.DamageDivide.Length - 1;
        ApplyHurtToCaster(battleHurtParam, isLastHit);
        // 和Hurt一样,调用PopDamage处理吸血/反伤的显示