/// <summary> /// 进攻武将攻打防守武将 /// </summary> /// <param name="moves"></param> /// <param name="attackrole"></param> /// <param name="denfenserole"></param> /// <param name="fight"></param> private void AttackRolesFight(AttackRoles attackrole, WarMovesVo moves, DefenseRoles denfenserole, WarFight fight) { try { var condition = new List <int>(); var rolevo = AddNewRoleVo(attackrole, moves); //是否出发地形地形效果 // var isArea = CheckArea(defrole, fight, attrole, rolevo); if (attackrole.isFirstAttack) { condition.Add((int)WarFightCondition.FirstAttack); } condition.Add((int)WarFightCondition.Attack); CheckAttackRoleSkill(attackrole, condition, fight, denfenserole, rolevo, WarFightSkillType.Character); CheckAttackRoleSkill(attackrole, condition, fight, denfenserole, rolevo, WarFightSkillType.NinjaSkill); CheckAttackRoleSkill(attackrole, condition, fight, denfenserole, rolevo, WarFightSkillType.NinjaMystery); if (CheckAttackRoleSkill(attackrole, condition, fight, denfenserole, rolevo, WarFightSkillType.Skill)) //秘技释放以后气力值清零 { attackrole.qili = 0; } CheckAttackRoleSkill(attackrole, condition, fight, denfenserole, rolevo, WarFightSkillType.Katha); AttackRoleAttack(attackrole, denfenserole, rolevo); CheckDefenseRoleBlood(denfenserole, fight); } catch (Exception e) { XTrace.WriteLine("进攻武将技能出错{0}", e.Message); throw; } }
/// <summary> /// 检测进攻武将,武将特性是否触发 /// </summary> /// <returns></returns> private bool CheckAttackRoleSkill(AttackRoles role, List <int> nowcondition, WarFight fight, DefenseRoles defenserole, WarFightRoleVo rolevo, WarFightSkillType type) { var skills = role.skills.Where(q => q.type == type).ToList(); foreach (var skill in skills) { var ismatch = CheckAttackRoleCondition(role, nowcondition, fight, defenserole, skill); if (!ismatch) { continue; } if (type == WarFightSkillType.Katha && role.buffs.Any(q => q.type == (int)WarFightEffectType.StartKatha) && role.buffs.All(q => q.type != (int)WarFightEffectType.StopKatha)) //是否立即释放奥义 { AttackRoleEffectsAdd(role, skill.FightSkillEffects, defenserole, rolevo, (int)type); return(true); } AttackRoleEffectsAdd(role, skill.FightSkillEffects, defenserole, rolevo, (int)type); if (type == WarFightSkillType.Skill) //气力清零 { role.qili -= 0; } return(true); } return(false); }
/// <summary> /// 验证是否出发地形效果 /// </summary> /// <param name="fight"></param> /// <param name="attackrole"></param> /// <param name="rolevo"></param> /// <param name="role"></param> /// <returns></returns> private bool CheckArea(DefenseRoles role, WarFight fight, AttackRoles attackrole, WarFightRoleVo rolevo) { var type = (int)WarFightSkillType.Area; var area = fight.Area.FirstOrDefault(q => q.X == role.X && q.Y == role.Y); if (area == null) { return(false); } var effectstring = fight.Weather == (int)WeatherType.Rain ? area.raineffect : area.suneffect; if (effectstring == "") { return(false); } var effects = WarSkillEffect.GetEffectStringInit(effectstring, true); if (area.type == (int)AreaType.陷阱) { type = (int)WarFightSkillType.Trap; } DefenseRoleEffectsAdd(role, effects, attackrole, rolevo, type); fight.Area.Remove(area); return(true); }
/// <summary> /// 攻打城门 /// </summary> /// <param name="moves"></param> /// <param name="attackrole"></param> /// <param name="fight"></param> private void AttackDoorFight(WarMovesVo moves, AttackRoles attackrole, WarFight fight) { if (fight.Door.SoldierCount == 0) { return; } var type = GetHurt(attackrole, fight.Door); if (fight.Door.SoldierCount <= 0) { fight.Door.SoldierCount = 0; for (int i = 0; i < fight.AttackRoles.Count; i++) { fight.AttackRoles[i].AttackRange = Common.GetInstance().Sacked(attackrole.X, attackrole.Y); if (fight.AttackRoles[i].isFightDoor) { fight.AttackRoles[i].isFightDoor = false; } } } var rolevo = AddNewRoleVo(attackrole, moves); WarFightRoleVoAddEffect(rolevo, fight.Door.RoleId, (int)EffectFaceTo.Rival, type, attackrole.SoldierCount, fight.Door.SoldierCount, 0, 0, 0); //防守武将回归 DefenseRolesBack(fight, moves); }
/// <summary> /// 验证伏兵是否出现 /// </summary> /// <param name="defenseroles">伏兵集合</param> /// <param name="attroles">进攻武将</param> /// <param name="defenserange">伏兵防守范围</param> /// <returns></returns> private List <DefenseRoles> CheckDarkRole(List <DefenseRoles> defenseroles, AttackRoles attroles, List <DefenseRange> defenserange) { //寻找能够攻击到该武将的进攻武将id集合 var rids = defenserange.Where(q => q.X == attroles.X && q.Y == attroles.Y).Select(q => q.RoleId).Distinct(); return(defenseroles.Where(q => rids.Contains(q.RoleId)).ToList()); }
/// <summary> /// 防守武将增加buff /// </summary> /// <param name="role"></param> /// <param name="usertype"></param> /// <param name="times"></param> /// <param name="type"></param> /// <param name="value"></param> private void AttackRoleAddNewBuff(AttackRoles role, int type, int value, int usertype, int times) { var buff = new WarFightSkillBuff() { type = type, value = value, times = times, usertype = usertype }; var repeatbuff = new WarFightSkillBuff(); //检测是否已经有该buff效果 repeatbuff = role.buffs.FirstOrDefault(q => q.type == buff.type && q.usertype == buff.usertype); if (repeatbuff == null) //没有相同类型的buff { role.buffs.Add(buff); } else { if (repeatbuff.value > buff.value) { return; } role.buffs.Remove(repeatbuff); role.buffs.Add(buff); } }
/// <summary> /// 进攻武将进攻 /// </summary> /// <param name="defrole"></param> /// <param name="attrole"></param> /// <param name="rolevo"></param> /// <returns></returns> private void AttackRoleAttack(AttackRoles attrole, DefenseRoles defrole, WarFightRoleVo rolevo) { // defrole.SoldierCount -= 10;//测试数据 var type = GetHurt(attrole, defrole); //var type = (int)WarFightEffectType.普通攻击; WarFightRoleVoAddEffect(rolevo, defrole.RoleId, (int)EffectFaceTo.Rival, type, attrole.SoldierCount, defrole.SoldierCount, 0, 0, 0); }
/// <summary> /// 防守武将进攻 /// </summary> /// <param name="defrole"></param> /// <param name="attrole"></param> /// <param name="rolevo"></param> /// <returns></returns> private void DefenseRoleAttack(DefenseRoles defrole, AttackRoles attrole, WarFightRoleVo rolevo) { // attrole.SoldierCount -= 10;//测试数据 var type = GetHurt(defrole, attrole); WarFightRoleVoAddEffect(rolevo, attrole.RoleId, (int)EffectFaceTo.Rival, type, defrole.SoldierCount, attrole.SoldierCount, 0, 0, 0); }
/// <summary> /// 公式计算伤害 /// </summary> /// <param name="defrole"></param> /// <param name="attackroles"></param> /// <returns></returns> private int GetHurt(DefenseRoles defrole, AttackRoles attackroles) { var attacktype = (int)WarFightEffectVoType.普通攻击; var dodge = attackroles.dodge + attackroles.buffs.Where(q => q.type == (int)WarFightEffectType.Dodge).Sum(q => q.value); var rolehits = defrole.hits + defrole.buffs.Where(q => q.type == (int)WarFightEffectType.Hits).Sum(q => q.value); var hits = Common.GetInstance().GetRule("32094", rolehits, dodge); var ishurt = new RandomSingle().IsTrue(hits); if (!ishurt) { return((int)WarFightEffectVoType.躲避); } // var basecap = Common.GetInstance().GetRule("32086", defrole.Role.base_captain); var equipattack = Common.GetInstance().GetRule("32087", defrole.EquipAddAttack); var total_fo = tg_role.GetSingleTotal(RoleAttributeType.ROLE_FORCE, defrole.Role); var roleattack = Common.GetInstance().GetRule("32088", total_fo, defrole.Role.base_captain); var soldierattack = Common.GetInstance().GetRule("32089", defrole.attack, defrole.morale, defrole.SoldierCount); var rivaldefense = Common.GetInstance().GetRule("32090", attackroles.EquipAddDefense); var addhurt = Common.GetInstance().GetRule("32091", defrole.Role.base_force); var redhurt = Common.GetInstance().GetRule("32092", attackroles.Role.base_brains); var rangesplit = defrole.hurtRange.Split("_"); var hurtrange = RNG.Next(Convert.ToInt32(rangesplit[0]), (Convert.ToInt32(rangesplit[1]))); var skilladdattack = defrole.buffs.Where(q => q.type == (int)WarFightEffectType.AddAttack) .Sum(q => q.value); var skilladddefense = attackroles.buffs.Where(q => q.type == (int)WarFightEffectType.AddDefense).Sum(q => q.value); var list = new List <Double>() { equipattack, roleattack, soldierattack, rivaldefense, addhurt, redhurt, skilladdattack, skilladddefense, hurtrange, }; var hurt = Common.GetInstance().GetRule("32093", list); var crit = defrole.crit + defrole.buffs.Where(q => q.type == (int)WarFightEffectType.Hits).Sum(q => q.value); var iscrit = new RandomSingle().IsTrue(crit); if (iscrit) { attacktype = (int)WarFightEffectVoType.暴击; hurt = Common.GetInstance().GetRule("32095", hurt); } attackroles.SoldierCount -= (int)hurt; return(attacktype); }
/// <summary> /// 验证进攻武将进攻范围是否有防守武将 /// </summary> /// <param name="defenseroles">防守武将集合</param> /// <param name="attroles">进攻武将集合</param> /// <param name="door">城门</param> /// <param name="home">本丸</param> /// <returns></returns> private DefenseRoles CheckIsDefenseRole(List <DefenseRoles> defenseroles, AttackRoles attroles, DefenseRoles door, DefenseRoles home) { var getdefense = new List <DefenseRoles>(); #if DEBUG XTrace.WriteLine("进攻武将坐标({0},{1})", attroles.X, attroles.Y); for (int j = 0; j < attroles.AttackRange.Count; j++) { XTrace.WriteLine("进攻武将攻击范围({0},{1})", attroles.AttackRange[j].X, attroles.AttackRange[j].Y); } #endif foreach (var defenserole in defenseroles) { if (defenserole.SoldierCount <= 0 || defenserole.isShow == false) { continue; } #if DEBUG XTrace.WriteLine("防守武将{0}的坐标({1},{2}),", defenserole.roleName, defenserole.X, defenserole.Y); #endif if (attroles.AttackRange.Any(q => q.X == defenserole.X && q.Y == defenserole.Y)) { getdefense.Add(defenserole); } } if (!getdefense.Any()) //攻击范围内没有防守武将 { //验证是否攻打城门 if (door.SoldierCount > 0) { if (attroles.AttackRange.Any(q => q.X == 2 && q.Y > 1 && q.Y < 7)) { attroles.isFightDoor = true; return(door); } } //验证是否攻打本丸 if (attroles.AttackRange.Any(q => q.X == home.X && q.Y == home.Y)) { attroles.isFightCity = true; return(home); } return(null); } ; #if DEBUG XTrace.WriteLine("进攻武将{0}攻击范围内有防守武将{1}", attroles.roleName, getdefense.OrderBy(q => q.SoldierCount).FirstOrDefault().roleName); #endif //寻找防守武将中血量最少的 return(getdefense.OrderBy(q => q.SoldierCount).FirstOrDefault()); }
/// <summary> /// 进攻武将加入到回合中 /// </summary> /// <param name="role">进攻武将</param> /// <param name="moves">回合数据</param> /// <returns></returns> private WarFightRoleVo AddNewRoleVo(AttackRoles role, WarMovesVo moves) { var vo = moves.roles.FirstOrDefault(q => q.roleId == role.RoleId); if (vo == null) { vo = EntityToRoleVo(role); moves.roles.Add(vo); } return(vo); }
/// <summary> /// 获取回合开始时的士气和气力 /// </summary> /// <param name="role"></param> private void GetAttackRoleMoraleAndQili(AttackRoles role) { role.morale -= 20; if (role.morale <= 0) { role.morale = 0; } role.qili += 10; if (role.qili > 100) { role.qili = 100; } }
/// <summary> /// 进攻武将实体转换成vo /// </summary> /// <param name="role">进攻武将</param> /// <returns></returns> private WarFightRoleVo EntityToRoleVo(AttackRoles role) { return(new WarFightRoleVo() { blood = role.SoldierCount, roleId = role.RoleId, point = new PointVo() { x = role.X, y = role.Y }, type = 0, campType = 0, lines = null, effects = new List <WarEffectVo>(), energy = role.qili }); }
/// <summary> /// 验证进攻武将是否死亡 /// </summary> /// <param name="role">进攻武将实体</param> /// <param name="fight">战斗实体</param> /// <returns></returns> private bool CheckAttackRoleBlood(AttackRoles role, WarFight fight) { if (role.SoldierCount <= 0) { role.SoldierCount = 0; //lock (this) //{ // fight.AttackRoles.Remove(role); //} fight.AttackSort.FirstOrDefault(q => q.RoleId == role.RoleId).isDie = true; } if (fight.AttackRoles.All(q => q.SoldierCount == 0)) { return(true); } return(false); }
/// <summary> /// 攻打本丸 /// </summary> /// <param name="moves"></param> /// <param name="attackrole"></param> /// <param name="fight"></param> private bool AttackHomeFight(WarMovesVo moves, AttackRoles attackrole, WarFight fight) { if (fight.City.SoldierCount == 0) { return(true); } var type = GetHurt(attackrole, fight.City); if (fight.City.SoldierCount < 0) { fight.City.SoldierCount = 0; return(true); } var rolevo = AddNewRoleVo(attackrole, moves); WarFightRoleVoAddEffect(rolevo, fight.City.RoleId, (int)EffectFaceTo.Rival, type, attackrole.SoldierCount, fight.City.SoldierCount, 0, 0, 0); return(false); }
/// <summary> /// 防守武将攻打进攻武将 /// </summary> /// <param name="defrole"></param> /// <param name="moves"></param> /// <param name="attrole"></param> /// <param name="fight"></param> private bool DefenseRolesFight(DefenseRoles defrole, WarMovesVo moves, AttackRoles attrole, WarFight fight) { try { if (defrole.SoldierCount <= 0 || attrole.SoldierCount <= 0) { return(false); } var condition = new List <int>(); var rolevo = AddNewRoleVo(defrole, moves); if (defrole.type == (int)WarFightRoleType.伏兵) //伏兵 { condition.Add((int)WarFightCondition.DarkRoleFirstAttack); WarFightRoleVoAddEffect(rolevo, defrole.RoleId, (int)EffectFaceTo.Me, (int)WarFightEffectVoType.伏兵, attrole.SoldierCount, defrole.SoldierCount, 0, 0, 0); defrole.isShow = true; } //是否出发地形地形效果 var isArea = CheckArea(defrole, fight, attrole, rolevo); if (defrole.isFirstAttack) { condition.Add((int)WarFightCondition.FirstAttack); } condition.Add((int)WarFightCondition.Attack); CheckSkill(defrole, condition, fight, attrole, rolevo, WarFightSkillType.Character); CheckSkill(defrole, condition, fight, attrole, rolevo, WarFightSkillType.NinjaSkill); CheckSkill(defrole, condition, fight, attrole, rolevo, WarFightSkillType.NinjaMystery); CheckSkill(defrole, condition, fight, attrole, rolevo, WarFightSkillType.Skill); CheckSkill(defrole, condition, fight, attrole, rolevo, WarFightSkillType.Katha); //最后进攻 DefenseRoleAttack(defrole, attrole, rolevo); var isend = CheckAttackRoleBlood(attrole, fight); return(isend); } catch (Exception e) { XTrace.WriteLine(e.Message); return(false); } }
/// <summary> /// 防守武将技能释放条件验证 /// </summary> /// <param name="role">防守武将</param> /// <param name="nowcondition"></param> /// <param name="fight"></param> /// <param name="attrole"></param> /// <param name="conditions"></param> /// <returns></returns> private bool CheckDefenseRoleCondition(DefenseRoles role, List <int> nowcondition, WarFight fight, AttackRoles attrole, List <string> conditions) { var ismatch = true; foreach (var item in conditions) { var condition = Convert.ToInt32(item); #region 技能条件验证 switch (condition) { case (int)WarFightCondition.Attack: if (nowcondition.Contains(condition)) { ismatch = false; } break; case (int)WarFightCondition.Rain: { if (fight.Weather != condition) { ismatch = false; } } break; case (int)WarFightCondition.Attacked: { if (nowcondition.Contains(condition)) { ismatch = false; } } break; case (int)WarFightCondition.FirstAttack: { if (nowcondition.Contains(condition)) { ismatch = false; } } break; case (int)WarFightCondition.DarkRoleFirstAttack: { if (nowcondition.Contains(condition)) { ismatch = false; } } break; case (int)WarFightCondition.FiveSame: { if (fight.FiveSharp != condition) { ismatch = false; } } break; case (int)WarFightCondition.SkillAttack: { if (nowcondition.Contains(condition)) { ismatch = false; } } break; // case (int)WarFightCondition.BloodLess: { if (role.SoldierCount > skill.effectBaseInfo.)ismatch = false; } break; case (int)WarFightCondition.CharmLessMe: { if (role.Role.base_charm < attrole.Role.base_charm) { ismatch = false; } } break; case (int)WarFightCondition.ForceLessMe: { if (role.Role.base_force < attrole.Role.base_force) { ismatch = false; } } break; case (int)WarFightCondition.BrainLessMe: { if (role.Role.base_brains < attrole.Role.base_brains) { ismatch = false; } } break; case (int)WarFightCondition.AreaSlope: { if (!fight.Area.Any(q => q.type == (int)AreaType.高坡 && q.X == role.X && role.Y == q.Y)) { ismatch = false; } } break; case (int)WarFightCondition.AreaRiver: { if (!fight.Area.Any(q => q.type == (int)AreaType.河滩 && q.X == role.X && role.Y == q.Y)) { ismatch = false; } } break; case (int)WarFightCondition.AreaSwamp: { if (!fight.Area.Any(q => q.type == (int)AreaType.沼泽 && q.X == role.X && role.Y == q.Y)) { ismatch = false; } } break; case (int)WarFightCondition.AreaForest: { if (!fight.Area.Any(q => q.type == (int)AreaType.密林 && q.X == role.X && role.Y == q.Y)) { ismatch = false; } } break; case (int)WarFightCondition.FancyAttack: { if (nowcondition.Contains(condition)) { ismatch = false; } } break; } #endregion } return(ismatch); }
/// <summary> /// 防守武将技能触发 /// </summary> /// <param name="role">防守武将</param> /// <param name="effects">技能实体</param> /// <param name="attackrole">进攻武将</param> /// <param name="rolevo">武将vo</param> /// <param name="skilltype"></param> private void DefenseRoleEffectsAdd(DefenseRoles role, List <WarSkillEffect> effects, AttackRoles attackrole, WarFightRoleVo rolevo, int skilltype) { foreach (var effect in effects) { if (effect.Probability > 0 && !new RandomSingle().IsTrue(effect.Probability)) { continue; //效果触发概率 } if (effect.effectSoldier != "0") { if (effect.effectSoldier != role.SoldierId.ToString()) { return; //地形效果兵种 } } var target = effect.target; switch (effect.effectType) { #region 增加攻击力 case (int)WarFightEffectType.AddAttack: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加防御力 case (int)WarFightEffectType.AddDefense: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加命中 case (int)WarFightEffectType.Hits: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加气力 case (int)WarFightEffectType.QiLi: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加兵力 case (int)WarFightEffectType.SoldierCount: { if (effect.target == (int)EffectFaceTo.Me) { role.SoldierCount += effect.effectValue; if (role.SoldierCount > role.bloodMax) { role.SoldierCount = role.bloodMax; } if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (attackrole.SoldierCount > role.bloodMax) { attackrole.SoldierCount = attackrole.bloodMax; } if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加先手值 case (int)WarFightEffectType.FirstAttack: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加暴击率 case (int)WarFightEffectType.BaoJi: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加躲避率 case (int)WarFightEffectType.Dodge: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加士气 case (int)WarFightEffectType.ShiQi: { if (effect.target == (int)EffectFaceTo.Me) { if (effect.times > 1) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 免疫僧兵兵种特性 case (int)WarFightEffectType.CanceCheatroles: { if (effect.target == (int)EffectFaceTo.Me) { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); } else { if (effect.times > 1) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 停止释放奥义 case (int)WarFightEffectType.StopKatha: { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); break; } #endregion #region 立即释放奥义 case (int)WarFightEffectType.StartKatha: { DefenseRoleAddNewBuff(role, effect.effectType, effect.effectValue, skilltype, effect.times); break; } #endregion } if (skilltype != (int)WarFightSkillType.Area) { //vo添加状态 if (effect.target == (int)EffectFaceTo.Me) //对自己 { if (effect.times == 1) { WarFightRoleVoAddEffect(rolevo, role.RoleId, target, SkillTypeToEffectType(skilltype), role.SoldierCount, attackrole.SoldierCount, effect.id, effect.effectType, effect.effectValue); } else { //添加buff WarFightRoleVoAddBuff(rolevo, role.RoleId, effect.effectType, effect.effectValue); } } } } }
/// <summary> /// 进攻武将技能触发 /// </summary> /// <param name="attackrole">进攻武将</param> /// <param name="effects">技能实体</param> /// <param name="defenserole">防守武将</param> /// <param name="rolevo">武将vo</param> /// <param name="skilltype"></param> private void AttackRoleEffectsAdd(AttackRoles attackrole, List <WarSkillEffect> effects, DefenseRoles defenserole, WarFightRoleVo rolevo, int skilltype) { //WarFightRoleVoAddEffect(rolevo, attackrole.RoleId, 0, SkillTypeToEffectType(skilltype), attackrole.SoldierCount, defenserole.SoldierCount, // effects[0].id, 0, 0); //vo增加效果 foreach (var effect in effects) { if (effect.Probability > 0 && !new RandomSingle().IsTrue(effect.Probability)) { continue; //效果触发概率 } if (effect.times == 0) //永久增加 { #region 永久效果 switch (effect.effectType) { #region 增加攻击力 case (int)WarFightEffectType.AddAttack: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.attack += effect.effectValue; } else { defenserole.attack += effect.effectValue; } break; } #endregion #region 增加防御力 case (int)WarFightEffectType.AddDefense: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.defense += effect.effectValue; } else { defenserole.defense += effect.effectValue; } break; } #endregion #region 增加命中 case (int)WarFightEffectType.Hits: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.hits += effect.effectValue; } else { defenserole.hits += effect.effectValue; } break; } #endregion #region 增加气力 case (int)WarFightEffectType.QiLi: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.qili += effect.effectValue; } else { defenserole.qili += effect.effectValue; } break; } #endregion #region 增加兵力 case (int)WarFightEffectType.SoldierCount: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.SoldierCount += effect.effectValue; if (attackrole.SoldierCount > attackrole.bloodMax) { attackrole.SoldierCount = attackrole.bloodMax; } } else { if (attackrole.SoldierCount > attackrole.bloodMax) { attackrole.SoldierCount = attackrole.bloodMax; } if (effect.times > 1) { DefenseRoleAddNewBuff(defenserole, effect.effectType, effect.effectValue, skilltype, effect.times); } } break; } #endregion #region 增加先手值 case (int)WarFightEffectType.FirstAttack: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.AttackSort += effect.effectValue; } else { defenserole.AttackSort += effect.effectValue; } break; } #endregion #region 增加暴击率 case (int)WarFightEffectType.BaoJi: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.crit += effect.effectValue; } else { defenserole.crit += effect.effectValue; } break; } #endregion #region 增加躲避率 case (int)WarFightEffectType.Dodge: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.dodge += effect.effectValue; } else { defenserole.dodge += effect.effectValue; } break; } #endregion #region 增加士气 case (int)WarFightEffectType.ShiQi: { if (effect.target == (int)EffectFaceTo.Me) { attackrole.morale += effect.effectValue; } else { defenserole.morale += effect.effectValue; } break; } #endregion } #endregion WarFightRoleVoAddEffect(rolevo, attackrole.RoleId, effect.target, SkillTypeToEffectType(skilltype), attackrole.SoldierCount, defenserole.SoldierCount, 0, effect.effectType, effect.effectValue); //vo增加效果 continue; } if (effect.target == (int)EffectFaceTo.Me) { AttackRoleAddNewBuff(attackrole, effect.effectType, effect.effectValue, skilltype, effect.times); //实体增加效果数值数据 WarFightRoleVoAddEffect(rolevo, attackrole.RoleId, effect.target, SkillTypeToEffectType(skilltype), attackrole.SoldierCount, defenserole.SoldierCount, 0, effect.effectType, effect.effectValue); //vo增加效果 if (effect.times > 1) //持续超过1回合 //添加buff { WarFightRoleVoAddBuff(rolevo, attackrole.RoleId, effect.effectType, effect.effectValue); } } else { DefenseRoleAddNewBuff(defenserole, effect.effectType, effect.effectValue, skilltype, effect.times); //实体添加buff WarFightRoleVoAddEffect(rolevo, defenserole.RoleId, effect.target, SkillTypeToEffectType(skilltype), attackrole.SoldierCount, defenserole.SoldierCount, 0, effect.effectType, effect.effectValue); //vo增加效果 if (effect.times > 1) // //添加buff { WarFightRoleVoAddBuff(rolevo, defenserole.RoleId, effect.effectType, effect.effectValue); } } } }