From 03942026b95aba9f0af1c637749ad27de399b932 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 11 十一月 2025 22:54:58 +0800
Subject: [PATCH] 0312 优化掉落战力计算卡顿问题
---
Main/Utility/JaceCalculator.cs | 57 +++++++
Main/System/DayMission/DayMissionManager.cs | 4
Main/System/Main/FightPowerFormula.cs.meta | 11 +
Main/Utility/GlobalTimeEvent.cs | 8
Main/System/Main/FightPowerManager.cs | 138 +++++++++++++++----
Main/System/Main/FightPowerFormula.cs | 158 ++++++++++++++++++++++
6 files changed, 337 insertions(+), 39 deletions(-)
diff --git a/Main/System/DayMission/DayMissionManager.cs b/Main/System/DayMission/DayMissionManager.cs
index daccfee..208d51b 100644
--- a/Main/System/DayMission/DayMissionManager.cs
+++ b/Main/System/DayMission/DayMissionManager.cs
@@ -20,7 +20,7 @@
public override void Init()
{
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
- GlobalTimeEvent.Instance.MS100Event += OnMSEvent;
+ GlobalTimeEvent.Instance.MSEvent += OnMSEvent;
ParseConfig();
}
@@ -28,7 +28,7 @@
public override void Release()
{
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- GlobalTimeEvent.Instance.MS100Event -= OnMSEvent;
+ GlobalTimeEvent.Instance.MSEvent -= OnMSEvent;
}
void OnBeforePlayerDataInitialize()
diff --git a/Main/System/Main/FightPowerFormula.cs b/Main/System/Main/FightPowerFormula.cs
new file mode 100644
index 0000000..9aca394
--- /dev/null
+++ b/Main/System/Main/FightPowerFormula.cs
@@ -0,0 +1,158 @@
+
+using System.Collections.Generic;
+
+public class FightPowerFormula
+{
+ // 鍩虹灞炴�у叕寮�
+ // 鎴樻枟灞炴�у叕寮�
+ // (lvValue+equipValue+bookValue+realmValue+gubaoValue+hjgValue+horseValue)+(heroSelfValue+lineupHaloValue+starTalentValue+breakLVValue+awakeTalentValue)+fetterValue
+ // 鎴樻枟鍔涘叕寮�
+ // long(Atk*AtkRatio+MaxHP*MaxHPRatio+Def*DefRatio+(StunRate*StunRateRatio+SuperHitRate*SuperHitRateRatio+ComboRate*ComboRateRatio+MissRate*MissRateRatio+ParryRate*ParryRateRatio+SuckHPPer*SuckHPPerRatio+StunRateDef*StunRateDefRatio+SuperHitRateDef*SuperHitRateDefRatio+ComboRateDef*ComboRateDefRatio+MissRateDef*MissRateDefRatio+ParryRateDef*ParryRateDefRatio+SuckHPPerDef*SuckHPPerDefRatio+FinalDamPer*FinalDamPerRatio+FinalDamPerDef*FinalDamPerDefRatio+PhyDamPer*PhyDamPerRatio+PhyDamPerDef*PhyDamPerDefRatio+MagDamPer*MagDamPerRatio+MagDamPerDef*MagDamPerDefRatio+NormalSkillPer*NormalSkillPerRatio+NormalSkillPerDef*NormalSkillPerDefRatio+AngerSkillPer*AngerSkillPerRatio+AngerSkillPerDef*AngerSkillPerDefRatio+SuperDamPer*SuperDamPerRatio+SuperDamPerDef*SuperDamPerDefRatio+CurePer*CurePerRatio+CurePerDef*CurePerDefRatio+ShieldPer*ShieldPerRatio+ShieldPerDef*ShieldPerDefRatio+DOTPer*DOTPerRatio+DOTPerDef*DOTPerDefRatio+WeiFinalDamPer*WeiFinalDamPerRatio+WeiFinalDamPerDef*WeiFinalDamPerDefRatio+ShuFinalDamPer*ShuFinalDamPerRatio+ShuFinalDamPerDef*ShuFinalDamPerDefRatio+WuFinalDamPer*WuFinalDamPerRatio+WuFinalDamPerDef*WuFinalDamPerDefRatio+QunFinalDamPer*QunFinalDamPerRatio+QunFinalDamPerDef*QunFinalDamPerDefRatio)/100.0-55000)
+
+ public static double GetBaseAttr(Dictionary<string, double> variables)
+ {
+
+ double lvValue = variables["lvValue"];
+ double equipValue = variables["equipValue"];
+ double bookValue = variables["bookValue"];
+ double realmValue = variables["realmValue"];
+ double gubaoValue = variables["gubaoValue"];
+ double hjgValue = variables["hjgValue"];
+ double horseValue = variables["horseValue"];
+ double lineupHaloPer = variables["lineupHaloPer"];
+ double bookPer = variables["bookPer"];
+ double realmPer = variables["realmPer"];
+ double gubaoPer = variables["gubaoPer"];
+ double hjgPer = variables["hjgPer"];
+ double horsePer = variables["horsePer"];
+ double lineupInitAddPer = variables["lineupInitAddPer"];
+ double lineupLVAddPer = variables["lineupLVAddPer"];
+ double lineupBreakLVAddPer = variables["lineupBreakLVAddPer"];
+ double lineupStarAddPer = variables["lineupStarAddPer"];
+ double inheritPer = variables["inheritPer"];
+ double fetterPer = variables["fetterPer"];
+ double starTalentPer = variables["starTalentPer"];
+ double breakLVPer = variables["breakLVPer"];
+ double awakeTalentPer = variables["awakeTalentPer"];
+ double heroSelfValue = variables["heroSelfValue"];
+
+ return (lvValue + equipValue + bookValue + realmValue + gubaoValue + hjgValue + horseValue) * (1 + lineupHaloPer + bookPer + realmPer + gubaoPer + hjgPer + horsePer + lineupInitAddPer + lineupLVAddPer + lineupBreakLVAddPer + lineupStarAddPer) * (inheritPer + fetterPer + starTalentPer + breakLVPer + awakeTalentPer) + heroSelfValue;
+ }
+
+ public static double GetFightAttr(Dictionary<string, double> variables)
+ {
+ double lvValue = variables["lvValue"];
+ double equipValue = variables["equipValue"];
+ double bookValue = variables["bookValue"];
+ double realmValue = variables["realmValue"];
+ double gubaoValue = variables["gubaoValue"];
+ double hjgValue = variables["hjgValue"];
+ double horseValue = variables["horseValue"];
+ double heroSelfValue = variables["heroSelfValue"];
+ double lineupHaloValue = variables["lineupHaloValue"];
+ double starTalentValue = variables["starTalentValue"];
+ double breakLVValue = variables["breakLVValue"];
+ double awakeTalentValue = variables["awakeTalentValue"];
+ double fetterValue = variables["fetterValue"];
+
+ return lvValue + equipValue + bookValue + realmValue + gubaoValue + hjgValue + horseValue + (heroSelfValue + lineupHaloValue + starTalentValue + breakLVValue + awakeTalentValue) + fetterValue;
+ }
+
+ public static double GetFightPower(Dictionary<string, double> variables)
+ {
+ double Atk = variables["Atk"];
+ double AtkRatio = variables["AtkRatio"];
+ double MaxHP = variables["MaxHP"];
+ double MaxHPRatio = variables["MaxHPRatio"];
+ double Def = variables["Def"];
+ double DefRatio = variables["DefRatio"];
+ double StunRate = variables["StunRate"];
+ double StunRateRatio = variables["StunRateRatio"];
+ double SuperHitRate = variables["SuperHitRate"];
+ double SuperHitRateRatio = variables["SuperHitRateRatio"];
+ double ComboRate = variables["ComboRate"];
+ double ComboRateRatio = variables["ComboRateRatio"];
+ double MissRate = variables["MissRate"];
+ double MissRateRatio = variables["MissRateRatio"];
+ double ParryRate = variables["ParryRate"];
+ double ParryRateRatio = variables["ParryRateRatio"];
+ double SuckHPPer = variables["SuckHPPer"];
+ double SuckHPPerRatio = variables["SuckHPPerRatio"];
+ double StunRateDef = variables["StunRateDef"];
+ double StunRateDefRatio = variables["StunRateDefRatio"];
+ double SuperHitRateDef = variables["SuperHitRateDef"];
+ double SuperHitRateDefRatio = variables["SuperHitRateDefRatio"];
+ double ComboRateDef = variables["ComboRateDef"];
+ double ComboRateDefRatio = variables["ComboRateDefRatio"];
+ double MissRateDef = variables["MissRateDef"];
+ double MissRateDefRatio = variables["MissRateDefRatio"];
+ double ParryRateDef = variables["ParryRateDef"];
+ double ParryRateDefRatio = variables["ParryRateDefRatio"];
+ double SuckHPPerDef = variables["SuckHPPerDef"];
+ double SuckHPPerDefRatio = variables["SuckHPPerDefRatio"];
+ double FinalDamPer = variables["FinalDamPer"];
+ double FinalDamPerRatio = variables["FinalDamPerRatio"];
+ double FinalDamPerDef = variables["FinalDamPerDef"];
+ double FinalDamPerDefRatio = variables["FinalDamPerDefRatio"];
+ double PhyDamPer = variables["PhyDamPer"];
+ double PhyDamPerRatio = variables["PhyDamPerRatio"];
+ double PhyDamPerDef = variables["PhyDamPerDef"];
+ double PhyDamPerDefRatio = variables["PhyDamPerDefRatio"];
+ double MagDamPer = variables["MagDamPer"];
+ double MagDamPerRatio = variables["MagDamPerRatio"];
+ double MagDamPerDef = variables["MagDamPerDef"];
+ double MagDamPerDefRatio = variables["MagDamPerDefRatio"];
+ double NormalSkillPer = variables["NormalSkillPer"];
+ double NormalSkillPerRatio = variables["NormalSkillPerRatio"];
+ double NormalSkillPerDef = variables["NormalSkillPerDef"];
+ double NormalSkillPerDefRatio = variables["NormalSkillPerDefRatio"];
+ double AngerSkillPer = variables["AngerSkillPer"];
+ double AngerSkillPerRatio = variables["AngerSkillPerRatio"];
+ double AngerSkillPerDef = variables["AngerSkillPerDef"];
+ double AngerSkillPerDefRatio = variables["AngerSkillPerDefRatio"];
+ double SuperDamPer = variables["SuperDamPer"];
+ double SuperDamPerRatio = variables["SuperDamPerRatio"];
+ double SuperDamPerDef = variables["SuperDamPerDef"];
+ double SuperDamPerDefRatio = variables["SuperDamPerDefRatio"];
+ double CurePer = variables["CurePer"];
+ double CurePerRatio = variables["CurePerRatio"];
+ double CurePerDef = variables["CurePerDef"];
+ double CurePerDefRatio = variables["CurePerDefRatio"];
+ double ShieldPer = variables["ShieldPer"];
+ double ShieldPerRatio = variables["ShieldPerRatio"];
+ double ShieldPerDef = variables["ShieldPerDef"];
+ double ShieldPerDefRatio = variables["ShieldPerDefRatio"];
+ double DOTPer = variables["DOTPer"];
+ double DOTPerRatio = variables["DOTPerRatio"];
+ double DOTPerDef = variables["DOTPerDef"];
+ double DOTPerDefRatio = variables["DOTPerDefRatio"];
+ double WeiFinalDamPer = variables["WeiFinalDamPer"];
+ double WeiFinalDamPerRatio = variables["WeiFinalDamPerRatio"];
+ double WeiFinalDamPerDef = variables["WeiFinalDamPerDef"];
+ double WeiFinalDamPerDefRatio = variables["WeiFinalDamPerDefRatio"];
+ double ShuFinalDamPer = variables["ShuFinalDamPer"];
+ double ShuFinalDamPerRatio = variables["ShuFinalDamPerRatio"];
+ double ShuFinalDamPerDef = variables["ShuFinalDamPerDef"];
+ double ShuFinalDamPerDefRatio = variables["ShuFinalDamPerDefRatio"];
+ double WuFinalDamPer = variables["WuFinalDamPer"];
+ double WuFinalDamPerRatio = variables["WuFinalDamPerRatio"];
+ double WuFinalDamPerDef = variables["WuFinalDamPerDef"];
+ double WuFinalDamPerDefRatio = variables["WuFinalDamPerDefRatio"];
+ double QunFinalDamPer = variables["QunFinalDamPer"];
+ double QunFinalDamPerRatio = variables["QunFinalDamPerRatio"];
+ double QunFinalDamPerDef = variables["QunFinalDamPerDef"];
+ double QunFinalDamPerDefRatio = variables["QunFinalDamPerDefRatio"];
+
+
+
+ return Atk * AtkRatio + MaxHP * MaxHPRatio + Def * DefRatio + (StunRate * StunRateRatio + SuperHitRate * SuperHitRateRatio + ComboRate * ComboRateRatio + MissRate * MissRateRatio + ParryRate * ParryRateRatio + SuckHPPer * SuckHPPerRatio + StunRateDef * StunRateDefRatio + SuperHitRateDef * SuperHitRateDefRatio + ComboRateDef * ComboRateDefRatio + MissRateDef * MissRateDefRatio + ParryRateDef * ParryRateDefRatio + SuckHPPerDef * SuckHPPerDefRatio + FinalDamPer * FinalDamPerRatio + FinalDamPerDef * FinalDamPerDefRatio + PhyDamPer * PhyDamPerRatio + PhyDamPerDef * PhyDamPerDefRatio + MagDamPer * MagDamPerRatio + MagDamPerDef * MagDamPerDefRatio + NormalSkillPer * NormalSkillPerRatio + NormalSkillPerDef * NormalSkillPerDefRatio + AngerSkillPer * AngerSkillPerRatio + AngerSkillPerDef * AngerSkillPerDefRatio + SuperDamPer * SuperDamPerRatio + SuperDamPerDef * SuperDamPerDefRatio + CurePer * CurePerRatio + CurePerDef * CurePerDefRatio + ShieldPer * ShieldPerRatio + ShieldPerDef * ShieldPerDefRatio + DOTPer * DOTPerRatio + DOTPerDef * DOTPerDefRatio + WeiFinalDamPer * WeiFinalDamPerRatio + WeiFinalDamPerDef * WeiFinalDamPerDefRatio + ShuFinalDamPer * ShuFinalDamPerRatio + ShuFinalDamPerDef * ShuFinalDamPerDefRatio + WuFinalDamPer * WuFinalDamPerRatio + WuFinalDamPerDef * WuFinalDamPerDefRatio + QunFinalDamPer * QunFinalDamPerRatio + QunFinalDamPerDef * QunFinalDamPerDefRatio) / 100.0 - 55000;
+
+ }
+
+ public static double GetSkillsFightPower(Dictionary<string, double> variables)
+ {
+ double SkillPower = variables["SkillPower"];
+ double OfficialLV = variables["OfficialLV"];
+ return SkillPower * OfficialLV;
+ }
+}
\ No newline at end of file
diff --git a/Main/System/Main/FightPowerFormula.cs.meta b/Main/System/Main/FightPowerFormula.cs.meta
new file mode 100644
index 0000000..40b9582
--- /dev/null
+++ b/Main/System/Main/FightPowerFormula.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7ccd965ff7cf97e40bc0c620b706bcff
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Main/FightPowerManager.cs b/Main/System/Main/FightPowerManager.cs
index 05a4476..a73bea9 100644
--- a/Main/System/Main/FightPowerManager.cs
+++ b/Main/System/Main/FightPowerManager.cs
@@ -4,7 +4,7 @@
using System.Linq;
using UnityEngine;
using LitJson;
-using Spine;
+
//锛佸崟鑻遍泟鏌ョ湅鎴樺姏 鍙畻鑷繁鐨勪笂闃靛睘鎬� 涓嶇畻缇佺粖 鎬讳笂闃靛睘鎬� 鍏夌幆
// 鎴樺姏鐨勮绠楁柟寮�
@@ -20,7 +20,7 @@
Dictionary<string, double> propertyVariables = new Dictionary<string, double>();
Dictionary<string, double> fightPowerVariables = new Dictionary<string, double>(); //鎬绘垬鍔涗腑鐨勫崟姝﹀皢鎴樺姏
-
+ int useFormulaType = 0; //鍏紡璋冪敤鏂瑰紡0 浠g爜 1鍏紡
public FightPowerManager()
{
// 鏁板��1锛氬熀纭�涓夌淮灞炴�ц绠楀叕寮�
@@ -53,7 +53,7 @@
dropIndexCalc = dropindex;
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氬垵濮嬪寲鍙傛暟 dropIndex锛�" + dropIndexCalc + " 闃靛瀷锛�" + teamTypeCalc + " ispreview:" + ispreview);
+ // Debug.Log("鎴樺姏锛氬垵濮嬪寲鍙傛暟 dropIndex锛�" + dropIndexCalc + " 闃靛瀷锛�" + teamTypeCalc + " ispreview:" + ispreview);
#endif
}
#endregion
@@ -74,14 +74,14 @@
//绛夌骇灞炴��
void RefreshLVAttrs()
{
- lvAttrs.Clear();
+ // lvAttrs.Clear();
var playerLVConfig = PlayerLVConfig.Get(PlayerDatas.Instance.baseData.LV);
foreach (var attrType in PlayerPropertyConfig.baseAttrs)
{
lvAttrs[attrType] = GetPlayerLVValue(playerLVConfig, attrType);
}
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氱瓑绾у睘鎬� " + JsonMapper.ToJson(lvAttrs));
+ // Debug.Log("鎴樺姏锛氱瓑绾у睘鎬� " + JsonMapper.ToJson(lvAttrs));
#endif
}
@@ -107,7 +107,7 @@
//瀹樿亴灞炴��
void RefreshOfficialAttrs()
{
- officialAttrs.Clear();
+ // officialAttrs.Clear();
var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
for (int i = 0; i < config.AddAttrType.Length; i++)
{
@@ -115,7 +115,7 @@
officialAttrs[id] = config.AddAttrNum[i];
}
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氬畼鑱屽睘鎬� " + JsonMapper.ToJson(officialAttrs));
+ // Debug.Log("鎴樺姏锛氬畼鑱屽睘鎬� " + JsonMapper.ToJson(officialAttrs));
#endif
}
@@ -175,7 +175,7 @@
}
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氳澶囧睘鎬� " + JsonMapper.ToJson(equipAttrs));
+ // Debug.Log("鎴樺姏锛氳澶囧睘鎬� " + JsonMapper.ToJson(equipAttrs));
#endif
}
@@ -187,12 +187,12 @@
lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower);
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氫笂闃靛睘鎬� " + JsonMapper.ToJson(lineUpPerDict));
+ // Debug.Log("鎴樺姏锛氫笂闃靛睘鎬� " + JsonMapper.ToJson(lineUpPerDict));
#endif
// 闃靛锛氬浗瀹讹紙鍏夌幆锛夊睘鎬�
countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower);
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氬浗瀹讹紙鍏夌幆锛夊睘鎬� " + JsonMapper.ToJson(countryAttrs));
+ // Debug.Log("鎴樺姏锛氬浗瀹讹紙鍏夌幆锛夊睘鎬� " + JsonMapper.ToJson(countryAttrs));
#endif
}
@@ -223,7 +223,7 @@
// 鍗曞熀纭�灞炴�ц绠�
public double GetPropertyVaule(int attrType, HeroInfo hero, string formula)
{
- propertyVariables.Clear();
+ // propertyVariables.Clear();
propertyVariables["lvValue"] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0;
propertyVariables["equipValue"] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0;
propertyVariables["bookValue"] = 0;
@@ -263,12 +263,66 @@
#if UNITY_EDITOR
//鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
- var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
- if (!tmpPropertyVariables.IsNullOrEmpty())
- propertyStrForDebug += $"灞炴�D {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}";
+ // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
+ // if (!tmpPropertyVariables.IsNullOrEmpty())
+ // propertyStrForDebug += $"灞炴�D {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}";
#endif
return JaceCalculator.Calculate(formula, propertyVariables);
}
+
+ public double GetPropertyVaule(int attrType, HeroInfo hero, int type)
+ {
+ // propertyVariables.Clear();
+ propertyVariables["lvValue"] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0;
+ propertyVariables["equipValue"] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0;
+ propertyVariables["bookValue"] = 0;
+ propertyVariables["bookPer"] = GetBookPer(attrType) / 10000.0f;
+ propertyVariables["realmValue"] = officialAttrs.ContainsKey(attrType) ? officialAttrs[attrType] : 0;
+ propertyVariables["realmPer"] = GetOfficialPer(attrType) / 10000.0f;
+ propertyVariables["gubaoValue"] = 0;
+ propertyVariables["gubaoPer"] = 0;
+ propertyVariables["hjgValue"] = 0;
+ propertyVariables["hjgPer"] = 0;
+ propertyVariables["horseValue"] = 0;
+ propertyVariables["horsePer"] = 0;
+
+ //锛侊紒锛佸崟姝﹀皢鎴樺姏棰勮鐨勮瘽闇�瑕佹帓闄ら槦浼嶅奖鍝嶆垬鍔涳紝鍙畻姝﹀皢鑷韩鐨勪笂闃靛睘鎬�
+ propertyVariables["lineupInitAddPer"] = GetLineUpPer(attrType, "lineupInitAddPer") / 10000.0f;
+ propertyVariables["lineupLVAddPer"] = GetLineUpPer(attrType, "lineupLVAddPer") / 10000.0f;
+ propertyVariables["lineupBreakLVAddPer"] = GetLineUpPer(attrType, "lineupBreakLVAddPer") / 10000.0f;
+ propertyVariables["lineupStarAddPer"] = GetLineUpPer(attrType, "lineupStarAddPer") / 10000.0f;
+
+ //闃靛鍏夌幆 涓夊洿鐧惧垎姣斿姞鎴�
+ propertyVariables["lineupHaloValue"] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0;
+ propertyVariables["lineupHaloPer"] = GetCountryPer(attrType) / 10000.0f;
+
+
+ //姝﹀皢灞炴��
+ propertyVariables["inheritPer"] = hero.GetInheritAttrPer(attrType) / 10000.0f;
+ propertyVariables["heroSelfValue"] = hero.GetSelfAddValue(attrType);
+ propertyVariables["heroSelfPer"] = hero.GetSelfAddPer(attrType) / 10000.0f;
+ propertyVariables["starTalentValue"] = hero.GetTalentAttrValue(attrType);
+ propertyVariables["starTalentPer"] = hero.GetTalentAttrPer(attrType) / 10000.0f;
+ propertyVariables["breakLVValue"] = hero.GetBreakAttrValue(attrType);
+ propertyVariables["breakLVPer"] = hero.GetBreakAttrPer(attrType) / 10000.0f;
+ propertyVariables["awakeTalentValue"] = hero.GetAwakeAttrValue(attrType);
+ propertyVariables["awakeTalentPer"] = hero.GetAwakeAttrPer(attrType) / 10000.0f;
+ propertyVariables["fetterValue"] = hero.GetFetterAttrValue(attrType);
+ propertyVariables["fetterPer"] = hero.GetFetterAttrPer(attrType) / 10000.0f;
+
+#if UNITY_EDITOR
+ //鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
+ // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
+ // if (!tmpPropertyVariables.IsNullOrEmpty())
+ // propertyStrForDebug += $"灞炴�D {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}";
+#endif
+ if (type == 0)
+ return FightPowerFormula.GetBaseAttr(propertyVariables);
+ else
+ return FightPowerFormula.GetFightAttr(propertyVariables);
+ }
+
+
int GetLineUpPer(int attrType, string key)
@@ -325,7 +379,7 @@
public long CalculatePower()
{
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氬紑濮嬭绠�");
+ // Debug.Log("鎴樺姏锛氬紑濮嬭绠�");
#endif
// --- 鍏堣绠楁墍鏈夊姛鑳界殑姹囨�诲睘鎬� ---
RefreshLVAttrs();
@@ -359,7 +413,7 @@
}
#if UNITY_EDITOR
- Debug.Log("鎴樺姏锛氳绠楀畬姣� " + fightPower);
+ // Debug.Log("鎴樺姏锛氳绠楀畬姣� " + fightPower);
#endif
return fightPower;
}
@@ -386,16 +440,22 @@
}
if (config.showType == 1)
{
- fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, propertyFormula), 3);
+ if (useFormulaType == 0)
+ fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 0), 3);
+ else
+ fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, propertyFormula), 3);
}
else
{
- fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3);
+ if (useFormulaType == 0)
+ fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 1), 3);
+ else
+ fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3);
}
}
#if UNITY_EDITOR
- Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
+ // Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
#endif
//灞炴�х郴鏁版牴鎹畼鑱岀瓑绾х殑鍔犳垚
@@ -443,13 +503,21 @@
fightPowerVariables["CurePerRatio"] = fightPowerRatioConfig.CurePerRatio;
fightPowerVariables["CurePerDefRatio"] = fightPowerRatioConfig.CurePerDefRatio;
+ long fightPower;
+ if (useFormulaType == 0)
+ {
+ fightPower = (long)FightPowerFormula.GetFightPower(fightPowerVariables);
+ }
+ else
+ {
- long fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables);
+ fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables);
+ }
#if UNITY_EDITOR
- //鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
- var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
- if (!tmpFightPowerVariables.IsNullOrEmpty())
- Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�ф垬鍔� {fightPower} 灞炴�ф垬鍔涘弬鏁� {JsonMapper.ToJson(tmpFightPowerVariables)}");
+ //鎺掗櫎鍊间负0鐨勫睘鎬ц緭鍑�
+ // var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value);
+ // if (!tmpFightPowerVariables.IsNullOrEmpty())
+ // Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�ф垬鍔� {fightPower} 灞炴�ф垬鍔涘弬鏁� {JsonMapper.ToJson(tmpFightPowerVariables)}");
#endif
//鍔犱笂鎶�鑳芥垬鍔�
@@ -458,15 +526,23 @@
fightPowerVariables["OfficialLV"] = PlayerDatas.Instance.baseData.realmLevel;
fightPowerVariables["SkillPower"] = hero.GetSkillsFightPower();
- long skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables);
+ long skillPower;
+ if (useFormulaType == 0)
+ {
+ skillPower = (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables);
+ }
+ else
+ {
+ skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables);
+ }
#if UNITY_EDITOR
- Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎶�鑳芥垬鍔� {skillPower} 鎶�鑳藉弬鏁� {JsonMapper.ToJson(fightPowerVariables)}");
+ // Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎶�鑳芥垬鍔� {skillPower} 鎶�鑳藉弬鏁� {JsonMapper.ToJson(fightPowerVariables)}");
- Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎬绘垬鍔� {fightPower + skillPower}");
+ // Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 鎬绘垬鍔� {fightPower + skillPower}");
#endif
- return fightPower + skillPower;
+ return fightPower + skillPower;
}
@@ -550,15 +626,15 @@
}
if (config.showType == 1)
{
- tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, propertyFormula);
+ tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 0);
}
else
{
- tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, fightPropertyFormula);
+ tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 1);
}
}
#if UNITY_EDITOR
- Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
+ // Debug.Log($"鎴樺姏锛氭灏咺D {hero.heroId} 灞炴�т俊鎭� {propertyStrForDebug}");
#endif
return tmpAttrs;
}
diff --git a/Main/Utility/GlobalTimeEvent.cs b/Main/Utility/GlobalTimeEvent.cs
index 9da381a..f6605cf 100644
--- a/Main/Utility/GlobalTimeEvent.cs
+++ b/Main/Utility/GlobalTimeEvent.cs
@@ -6,7 +6,7 @@
public class GlobalTimeEvent : SingletonMonobehaviour<GlobalTimeEvent>
{
- public event Action MS100Event;
+ public event Action MSEvent; // 姣�50ms
public event Action secondEvent;
public event Action fiveSecondEvent;
public event Action minuteEvent;
@@ -34,11 +34,11 @@
private void Update()
{
var ms = Time.time;
- if (ms - msBuf >= 0.1f)
+ if (ms - msBuf >= 0.05f)
{
- if (MS100Event != null)
+ if (MSEvent != null)
{
- MS100Event();
+ MSEvent();
}
msBuf = ms;
}
diff --git a/Main/Utility/JaceCalculator.cs b/Main/Utility/JaceCalculator.cs
index 941f833..f1ca3b2 100644
--- a/Main/Utility/JaceCalculator.cs
+++ b/Main/Utility/JaceCalculator.cs
@@ -5,9 +5,15 @@
public static class JaceCalculator
{
private static readonly CalculationEngine Engine = new CalculationEngine();
+ private static readonly Dictionary<string, double> _reusableVariables = new Dictionary<string, double>();
+ private static readonly object _lockObject = new object();
+
+ // 鍏紡缂撳瓨锛岄伩鍏嶉噸澶嶈В鏋�
+ private static readonly Dictionary<string, Func<Dictionary<string, double>, double>> _formulaCache =
+ new Dictionary<string, Func<Dictionary<string, double>, double>>();
/// <summary>
- /// 瑙f瀽骞惰绠楁暟瀛﹁〃杈惧紡
+ /// 瑙f瀽骞惰绠楁暟瀛﹁〃杈惧紡锛堜紭鍖栫増鏈紝鍑忓皯GC锛�
/// </summary>
/// <param name="formula">鏁板琛ㄨ揪寮忓瓧绗︿覆</param>
/// <param name="variables">鍙橀噺瀛楀吀</param>
@@ -26,7 +32,14 @@
try
{
- return Engine.Calculate(formula, variables);
+ // 浣跨敤缂撳瓨浼樺寲
+ if (!_formulaCache.TryGetValue(formula, out var compiledFormula))
+ {
+ compiledFormula = Engine.Build(formula);
+ _formulaCache[formula] = compiledFormula;
+ }
+
+ return compiledFormula(variables);
}
catch (Exception ex)
{
@@ -34,9 +47,49 @@
}
}
+ /// <summary>
+ /// 棰勭紪璇戝父鐢ㄥ叕寮忥紝鍑忓皯杩愯鏃惰В鏋愬紑閿�
+ /// </summary>
+ /// <param name="formulas">闇�瑕侀缂栬瘧鐨勫叕寮忔暟缁�</param>
+ public static void PrecompileFormulas(params string[] formulas)
+ {
+ if (formulas == null || formulas.Length == 0) return;
+
+ lock (_lockObject)
+ {
+ foreach (var formula in formulas)
+ {
+ if (!string.IsNullOrEmpty(formula) && !_formulaCache.ContainsKey(formula))
+ {
+ try
+ {
+ var compiledFormula = Engine.Build(formula);
+ _formulaCache[formula] = compiledFormula;
+ }
+ catch (Exception ex)
+ {
+ UnityEngine.Debug.LogWarning($"Failed to precompile formula '{formula}': {ex.Message}");
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// 娓呯┖鍏紡缂撳瓨锛堢敤浜庡唴瀛樼鐞嗭級
+ /// </summary>
+ public static void ClearCache()
+ {
+ lock (_lockObject)
+ {
+ _formulaCache.Clear();
+ }
+ }
+
public static void Init()
{
Engine.AddFunction("int", (Func<double, double>)(x => (int)x));
Engine.AddFunction("long", (Func<double, double>)(x => (long)x));
+
}
}
\ No newline at end of file
--
Gitblit v1.8.0