private List<ActionResult> SkillAttack(FightObject fighter, int level, GameConfig gc, int injuryType) { List<ActionResult> results = new List<ActionResult>(); AttackDamage attack; AttackParameter par = new AttackParameter(gc, level); if (injuryType == 0) { attack = new AttackPhysical(fighter, par); } else { attack = new AttackMagic(fighter, par); } TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); if (targetType == TargetType.Single) { var targets = FilterTargets(fighter); if (targets.Count > 0) { ActionResult result = Attack(attack, targets[0]); results.Add(result); } } else { var targets = EnemyTargets(fighter, targetType, par); foreach (var v in targets) { ActionResult result2 = Attack(attack, v, targets); results.Add(result2); } } return results; }
/// <summary> /// 生成所有敌方对象.. /// </summary> /// <param name="fighter"></param> /// <param name="targetType"></param> /// <param name="addTargets"></param> /// <returns></returns> protected List<FightObject> EnemyTargets(FightObject fighter, TargetType targetType, AttackParameter par) { List<FightObject> targets = FilterTargets(fighter); if (targets.Count <= 1 || targetType == TargetType.All) { return targets; } //横向目标(先移除与主目标不在同一排的) if (targetType == TargetType.HorizontalAll || targetType == TargetType.HorizontalRandom) { //targets[0]处为主攻目标,位置编号从0开始,小于等于4的为第1列.大于4的为第2列. if (targets[0].P > 4) { targets.RemoveAll(x => x.P <= 4); } else { targets.RemoveAll(x => x.P > 4); } } //随机目标(随机移除多余目标) if (targetType == TargetType.Random || targetType == TargetType.HorizontalRandom) { //附加目标数量:-1时,表示所有活的; int addTargets = par.LevelConfig.GetIntOrDefault("AddTargets"); if (addTargets++ > 0) { while (targets.Count > addTargets) { int index = NumberRandom.Next(1, targets.Count); targets.RemoveAt(index); } } } return targets; }
/// <summary> /// 免死的技能(修身) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillNoDeath(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); int r = config.GetIntOrDefault("Round"); if (r <= 0) return false; List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { ActionResult result = new ActionResult(target.ID); SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, a); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
/// <summary> /// 增强防御的技能 /// 石壁/神龙(主动) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillIncreaseDefense(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); double b = config.GetDoubleOrDefault("B"); if (a == 0 && b == 0) return false; int r = config.GetIntOrDefault("Round"); if (r <= 0) return false; double c; if (gc.Name == BufferType.ShiBi) { c = a + ((fighter.Life.TiZhi / 50) * b); } else { c = a + ((fighter.Life.JingShen / 50) * b); } if (c <= 0) return false; List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { //添加Buffer ActionResult result = new ActionResult(target.ID); SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
///// <summary> ///// 自身产生Buffer(开刃/沼气/焚烧) ///// </summary> ///// <param name="fighter"></param> ///// <param name="level"></param> ///// <param name="gc"></param> //private bool SkillAddBuffer(FightObject fighter, int level, GameConfig gc) //{ // SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, Byte.MaxValue, gc.Value); // fighter.AddBuffer(buf); // fighter.Action.Value = new Variant(); // ActionResult result = new ActionResult(fighter.ID); // result.ActionFlag |= ActionFlag.AddBuff; // result.Value["AddBuffer"] = buf; // fighter.Action.Result = new List<ActionResult>() { result }; // fighter.Action.FightCount = FightAction.HasAction; // m_actions.Add(fighter.Action); // return true; //} /// <summary> /// 治疗的技能 /// 回春/母育/祭祀/神谕 /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillCure(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); double b = config.GetDoubleOrDefault("B"); double c = config.GetDoubleOrDefault("C"); //double d = config.GetDoubleOrDefault("D"); int r = config.GetIntOrDefault("Round"); List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { ActionResult result = new ActionResult(target.ID); result.ActionFlag |= ActionFlag.Supply; int hp = target.TryHP(a) + (int)(fighter.Life.JingShen * b); target.AddHPAndMP(hp, 0); result.Value["HP"] = hp; //result.Value["ShengMing"] = target.HP; result.Value["ShengMing"] = new MVPair(target.Life.ShengMing, target.HP); //添加Buffer if (r > 0) { SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; } results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
protected List<FightObject> FriendTargets(FightObject fighter, TargetType targetType, AttackParameter par) { List<FightObject> targets = FilterTargets(fighter, false); if (targets.Count <= 1 || targetType == TargetType.TeamAll) { return targets; } if (targetType == TargetType.TeamSingle) { while (targets.Count > 1) { targets.RemoveAt(targets.Count - 1); } } //随机队友(随机移除多余目标) if (targetType == TargetType.TeamRandom) { //附加目标数量:-1时,表示所有活的; int addTargets = par.LevelConfig.GetIntOrDefault("AddTargets"); if (addTargets++ > 0) { while (targets.Count > addTargets) { int index = NumberRandom.Next(1, targets.Count); targets.RemoveAt(index); } } } return targets; }
/// <summary> /// 基本的战斗计算 /// </summary> /// <param name="a">攻击者</param> /// <param name="Par"></param> /// <param name="heji">是否有合击(触发合击时100%命中目标且无法暴击,目标无法反击)</param> public AttackMagic(FightObject a, AttackParameter par, bool heji = false) : base(a) { this.m_Par = par; this.m_heji = heji; }