Пример #1
0
        public static bool CtrlTeamMemberFix_UpdateProperty(CtrlTeamMember __instance, List <CharacterMapping> characterMapping)
        {
            List <PartyInfo> list = new List <PartyInfo>();

            foreach (CharacterMapping characterMapping2 in characterMapping)
            {
                CharacterInfoData     characterInfoData     = Game.GameData.Character[characterMapping2.InfoId];
                CharacterExteriorData characterExteriorData = Game.GameData.Exterior[characterMapping2.ExteriorId];
                list.Add(new PartyInfo
                {
                    Protrait = characterExteriorData.Protrait,
                    Element  = characterInfoData.Element,
                    FullName = characterExteriorData.SurName + characterExteriorData.Name,
                    Hp       = (float)characterInfoData.Property[CharacterProperty.HP].Value,
                    MaxHp    = (float)characterInfoData.Property[CharacterProperty.Max_HP].Value,
                    Mp       = (float)characterInfoData.Property[CharacterProperty.MP].Value,
                    MaxMp    = (float)characterInfoData.Property[CharacterProperty.Max_MP].Value
                });
            }
            Traverse.Create(__instance).Field("view").GetValue <UITeamMember>().UpdateProperty(list);
            return(false);
        }
Пример #2
0
        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");
        }