lcy
2 天以前 f1e5df1fc8eadd0eb27e0a6870501fa25a42b5a1
Main/System/Battle/BattleObject/BattleObject.cs
@@ -48,7 +48,7 @@
        private set;
    }
    protected BattleDrops battleDrops;
    protected BattleDrops m_battleDrops;
    private RectTransform m_heroRectTrans;
@@ -87,6 +87,8 @@
        buffMgr = new BattleObjectBuffMgr();
        buffMgr.Init(this);
        buffMgr.onIsControlChanged += OnControledChange;
        layerMgr = new BattleObjectLayerMgr();
        layerMgr.Init(this);
@@ -99,8 +101,15 @@
        var heroInfoBarScale = heroInfoBar.transform.localScale;
        heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1;
        heroInfoBar.transform.localScale = heroInfoBarScale;
        heroInfoBar.SetActive(true);
        if (battleField is StoryBattleField && (battleField as StoryBattleField).battleState == StoryBattleState.Break)
        {
            //主线关卡休息中的不显示血条
            heroInfoBar.SetActive(false);
        }
        else
        {
            heroInfoBar.SetActive(true);
        }
        SetFront();
    }
@@ -127,6 +136,9 @@
        motionBase.Release();
        motionBase = null;
        buffMgr.onIsControlChanged -= OnControledChange;
        buffMgr.Release();
        buffMgr = null;
        teamHero = null;
        ObjID = 0;
@@ -137,18 +149,40 @@
        }
    }
    //  有变化了才会调用这个函数
    private void OnControledChange(int groupType, bool value)
    {
        //  这里是受到硬控时候 需要表现的动画
        if (groupType == BattleConst.HardControlGroup)
        {
            //  从没被硬控到被硬控
            if (value)
            {
                motionBase.SetControledAnimation();
            }
            else
            {
                motionBase.CancelControledAnimation();
            }
        }
    }
    public void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo)
    {
        // 天子的挑战拦截血条,不拦截怒气
        BattleObject boss = battleField.FindBoss();
        if (boss != null && battleField.MapID == 30020 && boss.ObjID == _refreshInfo.ObjID && _refreshInfo.RefreshType != (ushort)PlayerDataType.XP)
            return;
        switch ((PlayerDataType)_refreshInfo.RefreshType)
        {
            case PlayerDataType.HP:
                long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
                teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                break;
            case PlayerDataType.MaxHP:
                teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
                break;
            case PlayerDataType.XP:
                long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
@@ -163,16 +197,20 @@
    public void ObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData)
    {
        // 天子的挑战拦截血条,不拦截怒气
        BattleObject boss = battleField.FindBoss();
        if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID && vNetData.RefreshType != (ushort)PlayerDataType.XP)
            return;
        switch ((PlayerDataType)vNetData.RefreshType)
        {
            case PlayerDataType.HP:
                long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
                teamHero.curHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
                break;
            case PlayerDataType.MaxHP:
                teamHero.maxHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
                break;
            case PlayerDataType.XP:
                long toXp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
@@ -268,17 +306,15 @@
        return true;
    }
    public virtual void Hurt(List<long> damageValues, long _totalDamage,
        HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, int hitIndex,
        BattleDrops battleDrops, HB422_tagMCTurnFightObjDead deadPack)
    public virtual void Hurt(BattleHurtParam battleHurtParam)
    {
        bool isLastHit = hitIndex >= skillConfig.DamageDivide.Length - 1;
        bool firstHit = hitIndex == 0;
        BattleDmgInfo dmgInfo = PopDamage(damageValues, _totalDamage, hurt, skillConfig, isLastHit);
        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
        bool firstHit = battleHurtParam.hitIndex == 0;
        BattleDmgInfo dmgInfo = PopDamage(battleHurtParam);
        //  这里
        if (dmgInfo.IsType(DamageType.Dodge))
        if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup])
        {
            if (isLastHit)
            {
@@ -292,36 +328,37 @@
            }
        }
        bool isFatalAttack = (null != deadPack) && isLastHit;
        bool isFatalAttack = (null != battleHurtParam.deadPack) && isLastHit;
        if (isFatalAttack)
        {
            if (null != battleDrops)
            if (null != battleHurtParam.battleDrops)
            {
                PushDropItems(battleDrops);
                PushDropItems(battleHurtParam.battleDrops);
            }
            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { deadPack });
            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { battleHurtParam.deadPack });
        }
        else
        {
            if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage()))
            if (dmgInfo.IsType(DamageType.Block))
            {
                motionBase.PlayAnimation(MotionName.hit, false);
                battleField.battleEffectMgr.PlayEffect(this, 19999, heroRectTrans, Camp);
            }
            else
            {
                if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage()))
                {
                    if (!buffMgr.isControled[BattleConst.HardControlGroup])
                    {
                        motionBase.PlayAnimation(MotionName.hit, false);
                    }
                }
            }
        }
    }
    public void SuckHp(uint suckHP, SkillConfig skillConfig)
    {
        teamHero.curHp = Math.Min(teamHero.maxHp, teamHero.curHp + (int)suckHP);
    }
    public void HurtByReflect(uint bounceHP, SkillConfig skillConfig)
    {
        teamHero.curHp = Math.Max(0, teamHero.curHp - (int)bounceHP);
    }
@@ -334,6 +371,12 @@
            .SetEase(Ease.OutCubic);
        motionBase.ShowIllusionShadow(true);
        DamageNumConfig damageNumConfig = DamageNumConfig.Get((int)DamageType.Dodge);
        string dodgeStr = ((char)damageNumConfig.prefix).ToString();
        heroInfoBar.ShowTips(dodgeStr, true, false);
        tween.onComplete += () =>
        {
@@ -386,26 +429,25 @@
    }
    // 伤害还要看 是否闪避 暴击 and so on 需要有一个DamageType 服务器应该会给
    protected virtual BattleDmgInfo PopDamage(List<long> damageValues, long _totalDamage, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, bool isLastHit)
    protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
    {
        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, hurt, skillConfig, isLastHit);
        int currentHurtHp = 0;
        for (int i = 0; i < damageValues.Count; i++)
        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam);
        // 天子的挑战拦截血条逻辑
        BattleObject boss = battleField.FindBoss();
        if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID)
        {
            currentHurtHp += (int)damageValues[i];
            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
            return battleDmgInfo;
        }
        else
        {
            heroInfoBar.UpdateDamage(battleDmgInfo);
            // YYL TODO 是否需要挂在在自身的follow点上
            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
            return battleDmgInfo;
        }
        bool isRecovery = battleDmgInfo.IsType(DamageType.Recovery);
        long toHp = Math.Max(0, teamHero.curHp + (isRecovery ? currentHurtHp : -currentHurtHp));
        heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
        teamHero.curHp = toHp;
        // YYL TODO 是否需要挂在在自身的follow点上
        EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
        return battleDmgInfo;
    }
    public RectTransform GetAliasTeamNode()
@@ -438,21 +480,21 @@
    public void PushDropItems(BattleDrops _battleDrops)
    {
        battleDrops = _battleDrops;
        m_battleDrops = _battleDrops;
    }
    public void PerformDrop()
    {
        if (null == battleDrops || battleDrops.dropItemPackIndex.Count == 0)
        if (null == m_battleDrops)
            return;
        EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>(
            EventName.BATTLE_DROP_ITEMS, battleField.guid, battleDrops, OnPerformDropFinish);
            EventName.BATTLE_DROP_ITEMS, battleField.guid, m_battleDrops, OnPerformDropFinish);
    }
    protected void OnPerformDropFinish()
    {
        battleDrops = null;
        m_battleDrops = null;
    }
    public void SetBack()
@@ -468,6 +510,7 @@
    public void SetSpeedRatio(float ratio)
    {
        motionBase.SetSpeedRatio(ratio);
        heroInfoBar.SetSpeedRatio(ratio);
    }