private IEnumerator DrawCardUntilNotAttack() { CardInstance drawCardInst = null; while (true) { if (!BattleTool.IsDeckHasCard()) //如果没卡了 { if (!BattleTool.IsUsedHasCard()) { yield break; } float shuffleTime = BattleTool.ShuffleDeckFromUsed(); yield return(new WaitForSeconds(shuffleTime)); } if (BattleTool.IsHandCardFull())// 如果手牌满了 { yield break; } drawCardInst = _battleModel.DrawOneCard(false); if (null == drawCardInst || drawCardInst.cardType != CardType.ATTACK) { yield break; } yield return(new WaitForSeconds(0.2f)); } }
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); }
//检查战斗是否结束 private void CheckIsBattleEnd() { if (BattleTool.IsAllEnemyDead()) { Message.Send(MsgType.BATTLE_WIN); } }
public ObjectBase(int objType) { this.objType = objType; instId = BattleTool.GetObjectInstId(); curHp = 0; maxHp = 0; armor = 0; }
public override void DoEffect(BattleManager battlemgr, CardInstance cardInstance, CardEffectTemplate effectTplt, int targetInstId) { BattleModel battleModel = BattleModel.Inst; // 如果有脆弱,减少增加的护甲值 int iAddArmor = effectTplt.iEffectValue; iAddArmor = BattleTool.AdjustArmorVal(battleModel.selfData, iAddArmor); battleModel.AddArmor(battleModel.selfData, iAddArmor); return; }
public override void DoEffect(BattleManager battlemgr, CardInstance cardInstance, CardEffectTemplate effectTplt, int targetInstId) { BattleModel battleModel = BattleModel.Inst; if (effectTplt.nTarget == CardEffectTargetType.ONE_ENEMY) { int iDmgCount = BattleTool.GetCardEffectCount(effectTplt); Core.Inst.StartCoroutine(battlemgr.DamageEnemyCoroutine(iDmgCount, targetInstId, effectTplt)); } else if (effectTplt.nTarget == CardEffectTargetType.ALL_ENEMY) { int iDmgCount = BattleTool.GetCardEffectCount(effectTplt); Core.Inst.StartCoroutine(battlemgr.DamageAllEnemyCoroutine(iDmgCount, effectTplt)); } return; }
//抽多张牌 private IEnumerator DrawCard(int drawNum, bool bRoundStartDraw) { for (int i = 0; i < drawNum; i++) { if (!BattleTool.IsDeckHasCard()) //如果没卡了 { if (!BattleTool.IsUsedHasCard()) { yield break; } float shuffleTime = BattleTool.ShuffleDeckFromUsed(); yield return(new WaitForSeconds(shuffleTime)); } _battleModel.DrawOneCard(bRoundStartDraw); yield return(new WaitForSeconds(0.2f)); } }
//获取卡牌描述 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); }
public override void DoEffect(BattleManager battlemgr, CardInstance cardInstance, CardEffectTemplate effectTplt, int targetInstId) { int iCount = BattleTool.GetCardEffectCount(effectTplt); BattleModel battleModel = BattleModel.Inst; if (effectTplt.nTarget == CardEffectTargetType.ONE_ENEMY) { battleModel.AddBuff(battleModel.selfData, battleModel.GetEnemy(targetInstId), (uint)effectTplt.iEffectValue, iCount); } else if (effectTplt.nTarget == CardEffectTargetType.ALL_ENEMY) { foreach (KeyValuePair <int, EnemyInstance> pair in battleModel.GetEnemys()) { battleModel.AddBuff(battleModel.selfData, pair.Value, (uint)effectTplt.iEffectValue, iCount); } } else if (effectTplt.nTarget == CardEffectTargetType.SELF) { battleModel.AddBuff(battleModel.selfData, battleModel.selfData, (uint)effectTplt.iEffectValue, iCount); } return; }
/// <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 根据模板表 以及是否格挡 播放不同的音效 }
//显示战斗者提示 private void ShowTip(int fighterInstId, Fighter fighter) { _lstTip.Clear(); //回合描述 BoutAction boutAction = BattleTool.GetBoutAction(fighterInstId); if (boutAction != null) { _lstTip.Add(BattleTool.GetActionTip(boutAction)); } //buff描述 List <BuffInst> lstBuff = BattleTool.GetFighterBuff(fighterInstId); if (lstBuff != null) { foreach (var buffInst in lstBuff) { _lstTip.Add(BattleTool.GetBuffTip(buffInst)); } } if (_comTipList == null) { InitTipList(); } _comTipList.visible = true; _comTipList.lstTip.numItems = _lstTip.Count; if (boutAction == null) //如果是自己 { _comTipList.SetXY(fighter.x + fighter.width, (this.height - _lstTip.Count * TIP_RENDER_HEIGHT) / 2); } else { _comTipList.SetXY(fighter.x - TIP_RENDER_WIDTH, (this.height - _lstTip.Count * TIP_RENDER_HEIGHT) / 2); } }
private void InitView() { _lstRewardCard = BattleTool.GenerateRewardCards(); _frmBattleReward.lstReward.numItems = 1; }