hch
2025-09-10 a80d9e64b60403c71ff7ff32c9e94e6833f50ace
Main/System/Battle/BattleObject/BattleObject.cs
@@ -48,7 +48,10 @@
        private set;
    }
    protected BattleDrops battleDrops;
    private RectTransform m_heroRectTrans;
    public RectTransform heroRectTrans
    {
@@ -66,9 +69,8 @@
    protected Renderer[] renderers;
    public Transform effectNode;
    private List<HB405_tagMCAddExp> hB405_tagMCAddExps = new List<HB405_tagMCAddExp>();
    public BattleHeroInfoBar heroInfoBar;
    public BattleObject(BattleField _battleField)
    {
@@ -87,13 +89,22 @@
        buffMgr.Init(this);
        renderers = heroGo.GetComponentsInChildren<Renderer>(true);
    }
        heroInfoBar = heroGo.GetComponentInChildren<BattleHeroInfoBar>(true);
        heroInfoBar.SetBattleObject(this);
        //  根据阵营翻转血条
        var heroInfoBarScale = heroInfoBar.transform.localScale;
        heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1;
        heroInfoBar.transform.localScale = heroInfoBarScale;
    }
    public virtual void Run()
    {
        motionBase.Run();
        heroInfoBar.Run();
    }
    public virtual void Pause()
@@ -108,7 +119,6 @@
    public virtual void Destroy()
    {
        motionBase.onAnimationComplete -= OnAnimationComplete;
        motionBase.Release();
@@ -128,12 +138,16 @@
        switch ((PlayerDataType)_refreshInfo.RefreshType)
        {
            case PlayerDataType.HP:
                long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
                teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                break;
            case PlayerDataType.MaxHP:
                teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                break;
            case PlayerDataType.XP:
                long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                heroInfoBar.UpdateHP(teamHero.rage, toXp, 100);
                teamHero.rage = (int)GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                break;
            default:
@@ -225,14 +239,24 @@
        return true;
    }
    public virtual void Hurt(List<long> damageValues, long _totalDamage, uint attackType)
    public virtual void Hurt(List<long> damageValues, long _totalDamage, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig)
    {
        PopDamage(teamHero.curHp, damageValues, attackType);
        PopDamage(damageValues, hurt, skillConfig);
        motionBase.PlayAnimation(MotionName.hit, false);
        //  扣血
        //  扣血流给别的敌方刷新好了
        teamHero.curHp -= _totalDamage;
    }
    public void SuckHp(uint suckHP, SkillConfig skillConfig)
    {
    }
    public void HurtByReflect(uint bounceHP, SkillConfig skillConfig)
    {
    }
    //  闪避开始
@@ -264,9 +288,9 @@
        motionBase.PlayAnimation(MotionName.dead, false);
    }
    protected virtual void OnAnimationComplete(MotionName motionName)
    protected virtual void OnAnimationComplete(string motionName)
    {
        if (motionName == MotionName.dead)
        if (motionName == MotionName.dead.ToString().ToLower())
        {
            OnDeadAnimationComplete();
            onDeathAnimationComplete?.Invoke();
@@ -289,19 +313,12 @@
    }
    // 伤害还要看 是否闪避 暴击 and so on 需要有一个DamageType 服务器应该会给
    protected virtual void PopDamage(long curHp, List<long> damageValues, uint attackType)
    protected virtual void PopDamage(List<long> damageValues, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig)
    {
        //  其实应该通知出去给UI界面解耦 让UI界面自己来显示的 YYL TODO
        //  播放伤害数字
        //  这里可以实现一个伤害数字的弹出效果
        //  比如使用一个UI组件来显示伤害数字
        foreach (var damage in damageValues)
        {
            Debug.Log($"Damage: {damage}");
        }
        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, hurt, skillConfig);
        // YYL TODO 是否需要挂在在自身的follow点上
        EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleField.guid, this, damageValues);
        EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
    }
    public RectTransform GetAliasTeamNode()
@@ -324,22 +341,32 @@
        // YYL TODO
        //  休息状态
        //  多一个zzz的一个特效
        heroGo.SetActive(true);
        motionBase.PlayAnimation(MotionName.idle, true);
        heroRectTrans.anchoredPosition = Vector2.zero;
    }
    public void PushExpPackList(List<HB405_tagMCAddExp> _hB405_tagMCAddExps)
    public void PushDropItems(BattleDrops _battleDrops)
    {
        // YYL TODO 死亡后弹出经验掉落提醒
        hB405_tagMCAddExps = _hB405_tagMCAddExps;
        battleDrops = _battleDrops;
    }
    public void DropExp()
    public void PerformDrop()
    {
        // YYL TODO
        // hB405_tagMCAddExps
        if (null == battleDrops || battleDrops.dropItemPackIndex.Count == 0)
            return;
        EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>(
            EventName.BATTLE_DROP_ITEMS, battleField.guid, battleDrops, OnPerformDropFinish);
    }
    protected void OnPerformDropFinish()
    {
        battleDrops = null;
    }
#if UNITY_EDITOR_STOP_USING