예제 #1
0
    private void OnAttackHit(object obj)
    {
        //结算对自身的伤害
        AttackStruct attackStruct = obj as AttackStruct;

        attackStruct.boutAction.iValue = BattleTool.AdjustAttackVal(attackStruct.casterInst, _battleModel.selfData, attackStruct.boutAction.iValue);

        int orignArmor  = _battleModel.selfData.armor;
        int leftArmor   = orignArmor - attackStruct.boutAction.iValue;
        int reduceArmor = 0;
        int reeduceHp   = 0;

        if (leftArmor < 0)
        {
            _battleModel.UpdateArmor(_battleModel.selfData, 0);
            _battleModel.ReduceSelfHp(-leftArmor);
            reduceArmor = orignArmor;
            reeduceHp   = -leftArmor;
        }
        else  //如果护甲有剩余
        {
            _battleModel.UpdateArmor(_battleModel.selfData, leftArmor);
            reduceArmor = attackStruct.boutAction.iValue;
        }
        SoundTool.inst.PlaySoundEffect(ResPath.SFX_SPEAR);  //todo 根据模板表和是否格挡来播放音效
        Message.Send(MsgType.SHOW_HIT_EFFECT, attackStruct);

        OnObjectHitted(attackStruct.casterInst, _battleModel.selfData, reeduceHp, reduceArmor);
    }
예제 #2
0
파일: CardCom.cs 프로젝트: tiance7/XianCard
        //获取卡牌描述
        private string GetCardDesc(string orignDesc)
        {
            //处理攻击
            FighterData selfData = BattleModel.Inst.selfData;

            foreach (Match match in Regex.Matches(orignDesc, PAT_ATTACK))
            {
                int damage;
                int.TryParse(Regex.Match(match.Value, @"\d+").Value, out damage);
                int    newDamage   = BattleTool.AdjustAttackVal(selfData, null, damage);
                string colorDamage = newDamage.ToString();
                if (newDamage > damage)
                {
                    colorDamage = TextTool.FormatUBBColor(colorDamage, "#00FF00");
                }
                else if (newDamage < damage)
                {
                    colorDamage = TextTool.FormatUBBColor(colorDamage, "#FF0000");
                }

                orignDesc = orignDesc.Replace(match.Value, string.Format(GameText.CARD_DAMAGE, colorDamage));
            }

            //处理防御
            foreach (Match match in Regex.Matches(orignDesc, PAT_DEFENCE))
            {
                int defence;
                int.TryParse(Regex.Match(match.Value, @"\d+").Value, out defence);
                int    newDefence   = BattleTool.AdjustArmorVal(selfData, defence);
                string colorDefence = newDefence.ToString();
                if (newDefence > defence)
                {
                    colorDefence = TextTool.FormatUBBColor(colorDefence, "#00FF00");
                }
                else if (newDefence < defence)
                {
                    colorDefence = TextTool.FormatUBBColor(colorDefence, "#FF0000");
                }
                orignDesc = orignDesc.Replace(match.Value, string.Format(GameText.CARD_DEFENCE, colorDefence));
            }

            return(orignDesc);
        }
예제 #3
0
    /// <summary>
    /// 对目标造成伤害
    /// </summary>
    /// <param name="instId"></param>
    /// <param name="iEffectValue"></param>
    internal void DamageEnemy(int instId, int iEffectValue, bool ignoreArmor)
    {
        EnemyInstance enemyInstance = _battleModel.GetEnemy(instId);

        if (enemyInstance == null)
        {
            return;
        }

        iEffectValue = BattleTool.AdjustAttackVal(_battleModel.selfData, enemyInstance, iEffectValue);

        if (false == ignoreArmor)
        {
            if (enemyInstance.armor >= iEffectValue)
            {
                _battleModel.ReduceEnemyArmor(instId, iEffectValue);

                _battleModel.effectStat.damageArmor += (uint)iEffectValue;
                _battleModel.roundStat.damageArmor  += (uint)iEffectValue;
            }
            else
            {
                int iReduceHp    = iEffectValue - enemyInstance.armor;
                int iReduceArmor = enemyInstance.armor;
                _battleModel.effectStat.damageArmor += (uint)iReduceArmor;
                _battleModel.roundStat.damageArmor  += (uint)iReduceArmor;
                _battleModel.ReduceEnemyArmor(instId, enemyInstance.armor);

                _battleModel.ReduceEnemyHp(instId, iReduceHp);
                OnObjectHitted(_battleModel.selfData, enemyInstance, iReduceHp, iReduceArmor);
            }
        }
        else
        {
            _battleModel.ReduceEnemyHp(instId, iEffectValue);
            OnObjectHitted(_battleModel.selfData, enemyInstance, iEffectValue, 0);
        }
        SoundTool.inst.PlaySoundEffect(ResPath.SFX_SPEAR);  //todo 根据模板表 以及是否格挡 播放不同的音效
    }