//记录攻击者和防御者的属性 public static void AttachBattleComputerProperty(CharacterInfoData attacker, CharacterInfoData defender) { Heluo.Logger.LogError("AttachBattleComputerProperty start"); BattleComputer battleComputer = Singleton <BattleComputer> .Instance; BattleFormulaProperty BattleComputerProperty = Traverse.Create(battleComputer).Field("BattleComputerProperty").GetValue <BattleFormulaProperty>(); BattleComputerFormula BattleComputerFormula = Traverse.Create(battleComputer).Field("BattleComputerFormula").GetValue <BattleComputerFormula>(); BattleComputerProperty.Clear(); foreach (object obj in Enum.GetValues(typeof(NurturanceProperty))) { NurturanceProperty prop = (NurturanceProperty)obj; string key = string.Format("attacker_{0}", prop.ToString().ToLower()); int value = attacker.GetUpgradeableProperty((CharacterUpgradableProperty)obj); string key2 = string.Format("defender_{0}", prop.ToString().ToLower()); int value2 = defender.GetUpgradeableProperty((CharacterUpgradableProperty)obj); BattleComputerProperty[key] = value; BattleComputerProperty[key2] = value2; BattleComputerProperty[prop.ToString().ToLower()] = value; } foreach (object obj2 in Enum.GetValues(typeof(BattleProperty))) { BattleProperty battleProperty = (BattleProperty)obj2; string format = "attacker_{0}"; BattleProperty battleProperty2 = battleProperty; string key3 = string.Format(format, battleProperty2.ToString().ToLower()); int value3 = attacker.Property[(CharacterProperty)obj2].Value; string format2 = "defender_{0}"; battleProperty2 = battleProperty; string key4 = string.Format(format2, battleProperty2.ToString().ToLower()); int value4 = defender.Property[(CharacterProperty)obj2].Value; BattleComputerProperty[key3] = value3; BattleComputerProperty[key4] = value4; if (battleProperty == BattleProperty.Move) { break; } } BattleComputerProperty["attacker_element"] = (int)attacker.Element; BattleComputerProperty["defender_element"] = (int)defender.Element; BattleComputerProperty["defender_max_hp"] = defender.Property[CharacterProperty.Max_HP].Value; float num = BattleComputerFormula["basic_attack_of_counter"].Evaluate(BattleComputerProperty.GetDictionary()); BattleComputerProperty.Add("basic_attack_of_counter", (int)num); Heluo.Logger.LogError("AttachBattleComputerProperty end"); }
public static void nonbattleUseHealSkillAction(UITeamMember uiTeamMember, CharacterInfoData attacker, List <CharacterInfoData> defender, int index, SkillData skill) { Heluo.Logger.LogError("nonbattleUseHealSkillAction start"); //mp不足 if (attacker.MP < skill.Item.RequestMP) { string text2 = Game.Data.Get <StringTable>("SecondaryInterface1207").Text; Game.UI.AddMessage(text2, UIPromptMessage.PromptType.Normal); return; } //最小距离大于0则不能给自己治疗 if (selectSkill.Item.MinRange > 0 && defender[index] == attacker) { Game.UI.AddMessage("该技能不能给自己治疗", UIPromptMessage.PromptType.Normal); return; } //最大距离等于0则只能给自己治疗 if (selectSkill.Item.MaxRange == 0 && defender[index] != attacker) { Game.UI.AddMessage("该技能只能给自己治疗", UIPromptMessage.PromptType.Normal); return; } //是否群体回复 int startIndex = index; int endIndex = index + 1; if (skill.Item.TargetArea == TargetArea.Fan || skill.Item.TargetArea == TargetArea.LineGroup || skill.Item.TargetArea == TargetArea.RingGroup) { startIndex = 0; endIndex = defender.Count; } //所有加血对象是否已满血 bool isAllFullHp = true; for (int i = startIndex; i < endIndex; i++) { if (defender[i].HP < defender[i].Property[CharacterProperty.Max_HP].Value) { isAllFullHp = false; break; } } if (isAllFullHp) { Game.UI.AddMessage("HP已满", UIPromptMessage.PromptType.Normal); return; } BattleComputer battleComputer = Singleton <BattleComputer> .Instance; BattleComputerFormula BattleComputerFormula = Traverse.Create(battleComputer).Field("BattleComputerFormula").GetValue <BattleComputerFormula>(); BattleFormulaProperty BattleComputerProperty = Traverse.Create(battleComputer).Field("BattleComputerProperty").GetValue <BattleFormulaProperty>(); attacker.MP -= skill.Item.RequestMP; for (int i = startIndex; i < endIndex; i++) { //原代码用WuxiaUnit参与计算,涉及Grid格子数据,直接调用比较麻烦,所以我这边就把逻辑抄一遍 //只留下和回复技能有关的数据(删来删去发现好像只剩下暴击了),如果有遗漏以后再补(真的会有人发现么) battleComputer.Initialize(); AttachBattleComputerProperty(attacker, defender[i]); //记录攻击者和防御者的属性 float basic_damage = battleComputer.Calculate_Basic_Damage(true); //基础回复值 float num = BattleComputerFormula["critical_rate"].Evaluate(BattleComputerProperty.GetDictionary()); num = Mathf.Clamp(num, 0f, 100f); int probability = UnityEngine.Random.Range(1, 100);; bool IsCritical = probability <= num;//是否暴击 float skill_coefficient = battleComputer.Calculate_Skill_Coefficient(skill);//技能倍率 float num2 = IsCritical ? BattleComputerFormula["damage_coefficient_of_critical"].Evaluate(BattleComputerProperty.GetDictionary()) : 1f; float num7 = basic_damage * num2; int final_damage = 1; //实际上回血技能应该都是+倍率 if (skill.Item.Algorithm == Algorithm.Addition) { final_damage = (int)(num7 + skill_coefficient); } else { final_damage = (int)(num7 * skill_coefficient); } if (selectSkill.Item.DamageType == DamageType.Heal) { defender[i].HP += final_damage; } else if (selectSkill.Item.DamageType == DamageType.MpRecover) { defender[i].MP += final_damage; } } //刷新左侧ui CtrlTeamMember controller = Traverse.Create(uiTeamMember).Field("controller").GetValue <CtrlTeamMember>(); controller.OnShow(); //刷新主界面角色信息 homeController.UpdateCharacterProperty(true); Heluo.Logger.LogError("nonbattleUseHealSkillAction end"); }