Main/Component/UI/Common/LayoutElementSizeClamp.cs
@@ -3,6 +3,11 @@ using UnityEngine.UI; //控制目标的最大最小尺寸 //使用参考 // Preferred Width 和 Height 可以不勾选 // !!!必须勾选 Clamp Enable // Clamp中 Min配最小 和 Max配最大 // Target 配目标,比如脚本可以挂载文字组件上,目标也指向文字组件 [ExecuteAlways] public class LayoutElementSizeClamp : LayoutElement { @@ -25,6 +30,7 @@ } async UniTask UpdateRect() { await UniTask.DelayFrame(1); Main/Config/ConfigManager.cs
@@ -69,6 +69,7 @@ typeof(PlayerAttrConfig), typeof(PlayerFaceConfig), typeof(PriorBundleConfig), typeof(RandomNameConfig), typeof(SignInConfig), typeof(StoreConfig), typeof(SuccessConfig), @@ -291,6 +292,8 @@ ClearConfigDictionary<PlayerFaceConfig>(); // 清空 PriorBundleConfig 字典 ClearConfigDictionary<PriorBundleConfig>(); // 清空 RandomNameConfig 字典 ClearConfigDictionary<RandomNameConfig>(); // 清空 SignInConfig 字典 ClearConfigDictionary<SignInConfig>(); // 清空 StoreConfig 字典 Main/Config/Configs/RandomNameConfig.cs
New file @@ -0,0 +1,47 @@ //-------------------------------------------------------- // [Author]: YYL // [ Date ]: 2025年11月11日 //-------------------------------------------------------- using System.Collections.Generic; using System; using UnityEngine; using LitJson; public partial class RandomNameConfig : ConfigBase<int, RandomNameConfig> { static RandomNameConfig() { // 访问过静态构造函数 visit = true; } public int ID; public string Job; public string RandomName1; public string RandomName2; public override int LoadKey(string _key) { int key = GetKey(_key); return key; } public override void LoadConfig(string input) { try { string[] tables = input.Split('\t'); int.TryParse(tables[0],out ID); Job = tables[1]; RandomName1 = tables[2]; RandomName2 = tables[3]; } catch (Exception exception) { Debug.LogError(exception); } } } Main/Config/Configs/RandomNameConfig.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: be5973bc28eb7ad47bf0054cb653c1da MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Config/PartialConfigs/RandomNameConfig.cs
New file @@ -0,0 +1,46 @@ using System.Collections.Generic; public partial class RandomNameConfig : ConfigBase<int, RandomNameConfig> { // <职业,随机姓> static Dictionary<int, List<string>> randomName1Dict = new Dictionary<int, List<string>>(); // <职业,随机名> static Dictionary<int, List<string>> randomName2Dict = new Dictionary<int, List<string>>(); protected override void OnConfigParseCompleted() { int[] arr = ConfigParse.GetMultipleStr<int>(Job); if (arr.IsNullOrEmpty()) return; foreach (var item in arr) { if (!randomName1Dict.ContainsKey(item)) { randomName1Dict[item] = new List<string>(); } if (!randomName1Dict[item].Contains(RandomName1)) { randomName1Dict[item].Add(RandomName1); } if (!randomName2Dict.ContainsKey(item)) { randomName2Dict[item] = new List<string>(); } if (!randomName2Dict[item].Contains(RandomName2)) { randomName2Dict[item].Add(RandomName2); } } } public static bool TryGetRandomName1ByJob(int job, out List<string> list) { list = null; return !randomName1Dict.IsNullOrEmpty() && randomName1Dict.TryGetValue(job, out list); } public static bool TryGetRandomName2ByJob(int job, out List<string> list) { list = null; return !randomName2Dict.IsNullOrEmpty() && randomName2Dict.TryGetValue(job, out list); } } Main/Config/PartialConfigs/RandomNameConfig.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 6a7049648c8e9ff428d119302bbd4800 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Core/NetworkPackage/DTCFile/ServerPack/HA1_Sys/DTCA123_tagUpdatePlayerNameCount.cs
New file @@ -0,0 +1,12 @@ using UnityEngine; using System.Collections; //A1 23 角色改名次数 #tagUpdatePlayerNameCount public class DTCA123_tagUpdatePlayerNameCount : DtcBasic { public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); HA123_tagUpdatePlayerNameCount vNetData = vNetPack as HA123_tagUpdatePlayerNameCount; RenameManager.Instance.UpdatePlayerNameCount(vNetData); } } Main/Core/NetworkPackage/DTCFile/ServerPack/HA1_Sys/DTCA123_tagUpdatePlayerNameCount.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: fe116c76d9a7fb64cae48b1ccf2620bc MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Core/NetworkPackage/DTCFile/ServerPack/HA9_Function/DTCA921_tagSCRenameResult.cs
New file @@ -0,0 +1,12 @@ using UnityEngine; using System.Collections; // A9 21 角色改名结果 #tagSCRenameResult public class DTCA921_tagSCRenameResult : DtcBasic { public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); HA921_tagSCRenameResult vNetData = vNetPack as HA921_tagSCRenameResult; RenameManager.Instance.UpdateRenameResult(vNetData); } } Main/Core/NetworkPackage/DTCFile/ServerPack/HA9_Function/DTCA921_tagSCRenameResult.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 13b012d2181362849a84ed5b9201d225 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs
@@ -10,7 +10,8 @@ { static byte[] vCmdBytes = new byte[2]; bool canAddPack = false; public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); @@ -18,8 +19,10 @@ // 战报结果 string guid = UIHelper.ServerStringTrim(vNetData.GUID); canAddPack = false; //约定 B430 内容(小包1长度WORD + 包1 + 小包2长度WORD + 包2) //约定第一个包是B424,先发过来的过滤报错通知 try { int vReadIndex = 0; @@ -60,8 +63,11 @@ GameNetPackBasic npk = PackageRegedit.TransPack(ServerType.B430, cmd, vPackBytes); if (npk != null) { vPackList.Add(npk); BattleManager.Instance.PushPackUID(guid, npk.packUID); if (!FilterBeforeB424(npk)) { vPackList.Add(npk); BattleManager.Instance.PushPackUID(guid, npk.packUID); } isRegist = true; } } @@ -83,7 +89,7 @@ { BattleManager.Instance.PushPackage(guid, vPackList[i]); } canAddPack = false; BattleManager.Instance.DistributeNextReportPackage(guid); } catch (Exception e) @@ -92,6 +98,23 @@ } } //约定第一个包是B424,先发过来的过滤报错通知 bool FilterBeforeB424(GameNetPackBasic npk) { if (npk is HB424_tagSCTurnFightInit) { canAddPack = true; return false; } if (!canAddPack) { Debug.LogErrorFormat("服务端需处理 DTCB430_tagSCTurnFightReport 过滤掉B424之前的包:" + npk.ToString()); return true; } return false; } protected List<GameNetPackBasic> AnalysisPackQueueAndDistribute(string guid, List<GameNetPackBasic> vPackList) { Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
@@ -76,7 +76,6 @@ Register(typeof(HB120_tagMCZhanlingInfo), typeof(DTCB120_tagMCZhanlingInfo)); Register(typeof(HA311_tagMCSyncRealmInfo), typeof(DTCA311_tagMCSyncRealmInfo)); Register(typeof(HB110_tagMCTaskInfo), typeof(DTCB110_tagMCTaskInfo)); Register(typeof(HA921_tagUpdatePlayerNameResult), typeof(DTCA921_tagUpdatePlayerNameResult)); Register(typeof(H3202_tagServerResponse), typeof(DTC3202_tagServerResponse)); Register(typeof(HA130_tagMCViewBillboardRet), typeof(DTCA130_tagMCViewBillboardRet)); Register(typeof(HB419_tagSCObjHPRefresh), typeof(DTCB419_tagSCObjHPRefresh)); @@ -124,6 +123,8 @@ Register(typeof(HA342_tagSCSuccessAwardRecordList), typeof(DTCA342_tagSCSuccessAwardRecordList)); Register(typeof(HB128_tagSCLLMJInfo), typeof(DTCB128_tagSCLLMJInfo)); Register(typeof(HA30D_tagSCDaySignInfo), typeof(DTCA30D_tagSCDaySignInfo)); Register(typeof(HA123_tagUpdatePlayerNameCount), typeof(DTCA123_tagUpdatePlayerNameCount)); Register(typeof(HA921_tagSCRenameResult), typeof(DTCA921_tagSCRenameResult)); } //主工程注册封包 Main/Core/NetworkPackage/ServerPack/HA1_Sys/HA123_tagUpdatePlayerNameCount.cs
New file @@ -0,0 +1,17 @@ using UnityEngine; using System.Collections; //A1 23 角色改名次数 #tagUpdatePlayerNameCount public class HA123_tagUpdatePlayerNameCount : GameNetPackBasic { public uint Count; //改名次数 public HA123_tagUpdatePlayerNameCount () { _cmd = (ushort)0xA123; } public override void ReadFromBytes (byte[] vBytes) { TransBytes (out Count, vBytes, NetDataType.DWORD); } } Main/Core/NetworkPackage/ServerPack/HA1_Sys/HA123_tagUpdatePlayerNameCount.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 22a9f002b7d6ce248b9ea930161aea99 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Core/NetworkPackage/ServerPack/HA9_Function/HA921_tagSCRenameResult.cs
New file @@ -0,0 +1,17 @@ using UnityEngine; using System.Collections; // A9 21 角色改名结果 #tagSCRenameResult public class HA921_tagSCRenameResult : GameNetPackBasic { public string PlayerName; // 新名字 public HA921_tagSCRenameResult () { _cmd = (ushort)0xA921; } public override void ReadFromBytes (byte[] vBytes) { TransBytes (out PlayerName, vBytes, NetDataType.Chars, 33); } } Main/Core/NetworkPackage/ServerPack/HA9_Function/HA921_tagSCRenameResult.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 36721f75d20b1bc4dbed1a1b80411885 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/Main.cs
@@ -86,6 +86,7 @@ managers.Add(TianziBillboradManager.Instance); managers.Add(ExpSecretCollectionManager.Instance); managers.Add(SignManager.Instance); managers.Add(RenameManager.Instance); foreach (var manager in managers) { manager.Init(); Main/System/Battle/BaseBattleWin.cs
@@ -42,7 +42,13 @@ // 在打开时需要暂停主线战斗 if (BattleManager.Instance.storyBattleField != null) { BattleManager.Instance.storyBattleField.IsPause = true; if (UIManager.Instance.IsOpened<EquipExchangeWin>()) { UIManager.Instance.CloseWindow<EquipExchangeWin>(); } } } protected override void OnPreClose() Main/System/Battle/BattleManager.cs
@@ -2,6 +2,7 @@ using UnityEngine; using LitJson; using System; using System.Linq; public class BattleManager : GameSystemManager<BattleManager> { @@ -662,13 +663,13 @@ public void DestroyAllBattleField() { foreach (var kvp in battleFields) var battleFieldsList = battleFields.Values.ToList(); foreach (var battleField in battleFieldsList) { BattleField battleField = kvp.Value; if (battleField == null) continue; DestroyBattleField(battleField); battleField.Destroy(); } } } 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() Main/System/Equip/EquipModel.cs
@@ -327,9 +327,6 @@ if (waitEquipOPPack) return false; // 后续补充引导或者其他情况下,不允许切换装备界面 // if (NewBieCenter.Instance.inGuiding) // return; if (UIManager.Instance.IsOpened<EquipExchangeWin>()) { @@ -356,6 +353,11 @@ if (NewBieCenter.Instance.inGuiding) return null; string activeBattleName = BattleManager.Instance.GetActiveBattleName(); if (activeBattleName != "" && activeBattleName != "StoryBattleField") return null; return PackManager.Instance.GetItemByIndex(PackType.DropItem, waitEquipOP.Dequeue()); } Main/System/HeroUI/HeroSkillWin.cs
@@ -1,3 +1,4 @@ using Cysharp.Threading.Tasks; using UnityEngine; using UnityEngine.UI; @@ -7,11 +8,12 @@ /// </summary> public class HeroSkillWin : UIBase { [SerializeField] RectTransform bg; [SerializeField] SkillBaseCell normalSkillCell; [SerializeField] Text nameText; [SerializeField] Text skillTypeText; [SerializeField] RichText descText; [SerializeField] SkillBaseCell angerSkillCell; [SerializeField] Text name2Text; [SerializeField] Text skillType2Text; @@ -24,10 +26,13 @@ { heroID = functionOrder; Refresh(); } protected override void OnPreClose() protected override void NextFrameAfterOpen() { ForceRefreshLayout().Forget(); } @@ -49,4 +54,13 @@ desc2Text.text = skillConfig2.Description; } async UniTask ForceRefreshLayout() { await UniTask.DelayFrame(2); LayoutRebuilder.ForceRebuildLayoutImmediate(bg); // 刷新所有Layout组件 await UniTask.Delay(100); // 刷新所有Layout组件 LayoutRebuilder.ForceRebuildLayoutImmediate(bg); } } Main/System/Main/FightPowerFormula.cs
New file @@ -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; } } Main/System/Main/FightPowerFormula.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 7ccd965ff7cf97e40bc0c620b706bcff MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: 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 代码 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 += $"属性ID {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}"; // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); // if (!tmpPropertyVariables.IsNullOrEmpty()) // propertyStrForDebug += $"属性ID {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 += $"属性ID {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($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); // Debug.Log($"战力:武将ID {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($"战力:武将ID {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($"战力:武将ID {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($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}"); // Debug.Log($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}"); Debug.Log($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}"); // Debug.Log($"战力:武将ID {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($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); // Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); #endif return tmpAttrs; } Main/System/Main/MainWin.cs
@@ -28,7 +28,7 @@ [SerializeField] UIEffectPlayer openCloseAnim; [SerializeField] FillTween cdTween; [SerializeField] Text hammerText; bool isForcePlayFightUIAnim = true; //强制播放战斗锤子框动画 public static event Action TabChangeEvent; @@ -36,7 +36,10 @@ { base.InitComponent(); avatarCell.button.AddListener(() => { }); avatarCell.button.SetListener(() => { UIManager.Instance.OpenWindow<PlayerProfileWin>(); }); } void Display() @@ -50,6 +53,7 @@ { PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh; AutoFightModel.Instance.OnFightEvent += OnSkillCast; RenameManager.Instance.OnUpdateRenameResultEvent += OnUpdateRenameResultEvent; base.OnPreOpen(); // 刷新UI @@ -60,17 +64,22 @@ { PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; AutoFightModel.Instance.OnFightEvent -= OnSkillCast; RenameManager.Instance.OnUpdateRenameResultEvent -= OnUpdateRenameResultEvent; base.OnPreClose(); isForcePlayFightUIAnim = true; } private void OnUpdateRenameResultEvent() { Display(); } void DisplayTopBar() { topBar.SetActive(functionOrder == 0 || functionOrder == 2); } //战斗按钮动画 void ClickAnimation(int index) { @@ -199,7 +208,7 @@ { return; } ClickAnimation(index); // 更新当前选中的标签索引 @@ -433,6 +442,6 @@ OnTabButtonClicked(lastWinOrder); } #endregion } Main/System/Main/MoneyMoveByPath.cs
@@ -20,6 +20,10 @@ public Transform targetPosition; List<ImageEx> imgMoneys = new List<ImageEx>(); int pointCount = 30; Vector3[] points = new Vector3[30]; Vector3[] points2 = new Vector3[30]; /// <summary> /// 播放掉落动画 /// </summary> @@ -54,8 +58,7 @@ } //通过 heightCurve 生成路径,时间为x 总时间为1,y为高度,偏移量为100 int pointCount = 30; Vector3[] points = new Vector3[pointCount]; for (int i = 0; i < pointCount; i++) { float x = i / (pointCount - 1f); @@ -64,8 +67,6 @@ } for (int i = 0; i < imgMoneys.Count; i++) { @@ -84,13 +85,12 @@ // x y 随机下差异 float randX = Random.Range(0.2f, 1f); float randY = Random.Range(0.6f, 1f); Vector3[] points2 = new Vector3[pointCount]; for (int j = 0; j < points.Length; j++) { points2[j] = new Vector3((points[j].x + offsetX)* randDir * randX, points[j].y * randY, points[j].z); } moneyImg.transform.localPosition = points2[0]; moneyImg.transform.DOLocalPath(points2, duration1, PathType.CatmullRom).SetEase(Ease.InOutSine).OnComplete(() => { Main/System/PhantasmPavilion/AvatarCell.cs
@@ -56,6 +56,7 @@ { if (m_button == null) { LoadPrefab(); m_button = this.GetComponent<ButtonEx>("AvatarCell/Img_BG"); } return m_button; Main/System/PlayerProfile.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: d96838ad917e38e418d0c8df7594ac01 folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Main/System/PlayerProfile/ExchangeCodeWin.cs
New file @@ -0,0 +1,89 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ExchangeCodeWin : UIBase { [SerializeField] InputField input; [SerializeField] Button receiveBtn; const string exchangeUrl = "http://gamecenter.secondworld.net.cn:53003/Coupon/CouponCode.php?"; bool isCool = false; float time = 0; protected override void InitComponent() { base.InitComponent(); receiveBtn.AddListener(ClickRecevieBtn); } protected override void OnPreOpen() { base.OnPreOpen(); time = 0; isCool = false; InitUI(); } protected override void OnPreClose() { base.OnPreClose(); } void LateUpdate() { if (isCool) { time += Time.deltaTime; if (time >= 3) { time = 0; isCool = false; } } } private void InitUI() { input.text = string.Empty; } private void ClickRecevieBtn() { if (isCool) return; string passward = input.text; if (string.IsNullOrEmpty(passward)) { SysNotifyMgr.Instance.ShowTip("InputExchangeCode"); return; } else { isCool = true; var tables = new Dictionary<string, string>(); tables["channel"] = VersionConfig.Get().appId; tables["code"] = passward; #if UNITY_EDITOR //tables["accid"] = ModelCenter.Instance.GetModel<LoginModel>().accountBuf; tables["accid"] = PlayerDatas.Instance.baseData.AccID; #else tables["accid"] = ynmbxxjUtil.Instance.FreePlatformInfo.account; #endif tables["sid"] = ServerListCenter.Instance.currentServer.region_flag.ToString(); tables["pushurl"] = ServerListCenter.Instance.currentServer.region_domain; tables["spid"] = VersionConfig.Get().SpID; tables["roleid"] = UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName); tables["level"] = PlayerDatas.Instance.baseData.LV.ToString(); tables["viplevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(exchangeUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, null); } // if (passward.Length > 1) // { // string wxCode = passward.Substring(0, 2); // if (wxCode == "wx") // { // WindowCenter.Instance.Close<WelfareWin>(); // } // } } } Main/System/PlayerProfile/ExchangeCodeWin.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 4fc65570fe03ebc41bddb56d98345fce MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/PlayerProfile/PlayerProfileWin.cs
New file @@ -0,0 +1,86 @@ using UnityEngine; public class PlayerProfileWin : UIBase { [SerializeField] AvatarCell avatarCell; [SerializeField] OfficialTitleCell officialTitleCell; [SerializeField] TextEx txtPlayerName; [SerializeField] TextEx txtFightPoint; [SerializeField] TextEx txtPlayerID; [SerializeField] TextEx txtServerName; [SerializeField] TextEx txtFamilyName; [SerializeField] ButtonEx btnSetting; [SerializeField] ButtonEx btnAnnouncement; [SerializeField] ButtonEx btnCustomerService; [SerializeField] ButtonEx btnRedemptionCode; [SerializeField] ButtonEx btnForum; [SerializeField] ButtonEx btnAssistant; [SerializeField] ButtonEx btnGamingCommunity; [SerializeField] ButtonEx btnSwitchServer; [SerializeField] ButtonEx btnSyncPlatformAvatar; [SerializeField] ButtonEx btnCopy; [SerializeField] ButtonEx btnChangeName; [SerializeField] ButtonEx btnText1; [SerializeField] ButtonEx btnText2; protected override void InitComponent() { base.InitComponent(); btnSetting.SetListener(() => { UIManager.Instance.OpenWindow<SystemSetWin>(); }); btnAnnouncement.SetListener(() => { GameNotice.OpenGameNoticeForce(); }); btnSwitchServer.SetListener(() => { GameNetSystem.Instance.LoginOut(); }); btnRedemptionCode.SetListener(() => { UIManager.Instance.OpenWindow<ExchangeCodeWin>(); }); btnCopy.SetListener(() => { UIHelper.CopyToClipboard(PlayerDatas.Instance.baseData.PlayerID.ToString()); SysNotifyMgr.Instance.ShowTip("CopySuccess"); }); btnChangeName.SetListener(() => { UIManager.Instance.OpenWindow<RenameWin>(); }); btnText1.SetListener(() => { GameAgeWarnWin.data = 1; UIManager.Instance.OpenWindow<GameAgeWarnWin>(); }); btnText2.SetListener(() => { GameAgeWarnWin.data = 2; UIManager.Instance.OpenWindow<GameAgeWarnWin>(); }); } protected override void OnPreOpen() { base.OnPreOpen(); RenameManager.Instance.OnUpdatePlayerNameCountEvent += OnUpdatePlayerNameCount; RenameManager.Instance.OnUpdateRenameResultEvent += OnUpdateRenameResultEvent; Display(); } protected override void OnPreClose() { base.OnPreClose(); RenameManager.Instance.OnUpdatePlayerNameCountEvent -= OnUpdatePlayerNameCount; RenameManager.Instance.OnUpdateRenameResultEvent -= OnUpdateRenameResultEvent; } private void OnUpdateRenameResultEvent() { Display(); } private void OnUpdatePlayerNameCount() { Display(); } void Display() { txtPlayerName.text = PlayerDatas.Instance.baseData.PlayerName; txtFightPoint.text = UIHelper.ReplaceLargeArtNum(PlayerDatas.Instance.baseData.FightPower); txtPlayerID.text = Language.Get("PlayerProfile10", PlayerDatas.Instance.baseData.PlayerID.ToString()); txtServerName.text = Language.Get("PlayerProfile11", ServerListCenter.Instance.GetServerName(UIHelper.GetServerIDByAccount(PlayerDatas.Instance.baseData.AccID))); txtFamilyName.text = Language.Get("PlayerProfile12", PlayerDatas.Instance.fairyData.HasFairy ? PlayerDatas.Instance.baseData.FamilyName : Language.Get("PlayerProfile14")); avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)PlayerDatas.Instance.baseData.PlayerID, PlayerDatas.Instance.baseData.face, PlayerDatas.Instance.baseData.facePic)); officialTitleCell.InitUI(PlayerDatas.Instance.baseData.realmLevel, PlayerDatas.Instance.baseData.TitleID); } } Main/System/PlayerProfile/PlayerProfileWin.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: ea72bcc95f8931247844dde3088e0440 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/PlayerProfile/RenameManager.cs
New file @@ -0,0 +1,145 @@ using System; using System.Text; public class RenameManager : GameSystemManager<RenameManager> { public int moneyType; public int moneyNeed; public override void Init() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent; FuncConfigConfig config = FuncConfigConfig.Get("PlayerRename"); int[] arr = ConfigParse.GetMultipleStr<int>(config.Numerical3); moneyType = arr[0]; moneyNeed = arr[1]; } public override void Release() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent; } private void OnBeforePlayerDataInitializeEvent() { RenameManagerCount = 0; } public event Action OnUpdateRenameResultEvent; public void UpdateRenameResult(HA921_tagSCRenameResult vNetData) { if (vNetData == null) return; PlayerDatas.Instance.baseData.PlayerName = UIHelper.ServerStringTrim(vNetData.PlayerName); SysNotifyMgr.Instance.ShowTip("RenameSuccess"); OnUpdateRenameResultEvent?.Invoke(); } int RenameManagerCount = 0; // 改名次数 为1 代表已经首次改名过,未改过上线不会收到该封包 public event Action OnUpdatePlayerNameCountEvent; public void UpdatePlayerNameCount(HA123_tagUpdatePlayerNameCount vNetData) { if (vNetData == null) return; RenameManagerCount = (int)vNetData.Count; OnUpdatePlayerNameCountEvent?.Invoke(); } public void SendRenamePack(string name) { CA122_tagUpdatePlayerName pack = new CA122_tagUpdatePlayerName(); pack.NewName = name; pack.NewNameLen = (byte)GetUTF8InfoLen(name); GameNetSystem.Instance.SendInfo(pack); } public bool IsFirstRename() { return RenameManagerCount == 0; } public string GetRondomNameByJob(int job) { if (!RandomNameConfig.TryGetRandomName1ByJob(job, out var randomNameList1)) return string.Empty; if (!RandomNameConfig.TryGetRandomName2ByJob(job, out var randomNameList2)) return string.Empty; int randomNameIndex1 = UnityEngine.Random.Range(0, randomNameList1.Count - 1); int randomNameIndex2 = UnityEngine.Random.Range(0, randomNameList2.Count - 1); return StringUtility.Contact(randomNameList1[randomNameIndex1], randomNameList2[randomNameIndex2]); } public bool CheckNameLimit(string name, out int errorCode) { errorCode = 0; if (string.IsNullOrEmpty(name)) { errorCode = 0; return false; } if (!UIHelper.SatisfyNameLength(name, out errorCode)) { return false; } if (DirtyWordConfig.IsDirtWord(name) || UIHelper.HasSpecialCharac(name) || DirtyNameConfig.IsDirtName(name)) { errorCode = 3; return false; } if (name == PlayerDatas.Instance.baseData.PlayerName) { errorCode = 4; return false; } return true; } public void ShowNameErrorTip(int _errorCode) { switch (_errorCode) { case 0: //空 SysNotifyMgr.Instance.ShowTip("FamilyNameChangeNoNull"); break; case 1: // 名字长度过长 SysNotifyMgr.Instance.ShowTip("NameError2", 7); break; case 2: // 名字长度过短 SysNotifyMgr.Instance.ShowTip("NameError1", 2); break; case 3: // 脏字 SysNotifyMgr.Instance.ShowTip("NameSensitive"); break; case 4: // 名字已存在 SysNotifyMgr.Instance.ShowTip("NameExists"); break; } } public string GetSafeRandomName() { int job = PlayerDatas.Instance.baseData.Job; for (int i = 0; i < 9999; i++) { string name = GetRondomNameByJob(job); if (CheckNameLimit(name, out int errorCode)) return name; } return string.Empty; } public static int GetUTF8InfoLen(string msg) { return Encoding.UTF8.GetBytes(msg).Length; } } Main/System/PlayerProfile/RenameManager.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: b180558cd4c7e69429210cc1750a4789 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/PlayerProfile/RenameWin.cs
New file @@ -0,0 +1,93 @@ using System; using UnityEngine; using UnityEngine.UI; public class RenameWin : UIBase { [SerializeField] InputField input; [SerializeField] Button btnOk; [SerializeField] Button btnRandom; [SerializeField] TextEx txtFirst; [SerializeField] TextEx txtMoney; [SerializeField] ImageEx imgMoney; RenameManager manager { get { return RenameManager.Instance; } } protected override void InitComponent() { base.InitComponent(); btnRandom.SetListener(() => { input.text = manager.GetSafeRandomName(); }); btnOk.SetListener(() => { bool isFirstRename = manager.IsFirstRename(); if (!isFirstRename && !UIHelper.CheckMoneyCount(manager.moneyType, manager.moneyNeed)) { string title = Language.Get("Mail101"); string info = Language.Get("PlayerProfile22"); ConfirmCancel.ShowPopConfirm(title, info, (bool isOk) => { if (isOk) { } else { CloseWindow(); } }); return; } if (!manager.CheckNameLimit(input.text, out var errorCode)) { manager.ShowNameErrorTip(errorCode); return; } manager.SendRenamePack(input.text); }); } protected override void OnPreOpen() { base.OnPreOpen(); manager.OnUpdatePlayerNameCountEvent += OnUpdatePlayerNameCount; manager.OnUpdateRenameResultEvent += OnUpdateRenameResultEvent; PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh; Display(); } protected override void OnPreClose() { base.OnPreClose(); manager.OnUpdatePlayerNameCountEvent -= OnUpdatePlayerNameCount; manager.OnUpdateRenameResultEvent -= OnUpdateRenameResultEvent; PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; } private void PlayerDataRefresh(PlayerDataType type) { Display(); } private void OnUpdateRenameResultEvent() { Display(); } private void OnUpdatePlayerNameCount() { Display(); } void Display() { bool isFirstRename = manager.IsFirstRename(); txtFirst.SetActive(isFirstRename); txtMoney.SetActive(!isFirstRename); imgMoney.SetIconWithMoneyType(manager.moneyType); txtMoney.text = UIHelper.ShowUseMoney(manager.moneyType, manager.moneyNeed); } } Main/System/PlayerProfile/RenameWin.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 31a79aad128b21e449af2a82bd367cfe MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/PlayerProfile/SystemSetWin.cs
New file @@ -0,0 +1,40 @@ using UnityEngine; using UnityEngine.UI; public class SystemSetWin : UIBase { [SerializeField] Slider musicSlider; [SerializeField] Slider soundEffectSlider; protected override void InitComponent() { base.InitComponent(); } protected override void OnPreOpen() { base.OnPreOpen(); musicSlider.onValueChanged.RemoveListener(OnSliderBgMusic); musicSlider.onValueChanged.AddListener(OnSliderBgMusic); soundEffectSlider.onValueChanged.RemoveListener(OnSliderSoundEffect); soundEffectSlider.onValueChanged.AddListener(OnSliderSoundEffect); musicSlider.value = SystemSetting.Instance.GetSoundVolume(); soundEffectSlider.value = SystemSetting.Instance.GetSoundEffect(); } protected override void OnPreClose() { base.OnPreClose(); } private void OnSliderSoundEffect(float arg0) { SystemSetting.Instance.SetSoundEffect(arg0); } private void OnSliderBgMusic(float arg0) { SystemSetting.Instance.SetSoundVolume(arg0); } } Main/System/PlayerProfile/SystemSetWin.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 30dc70a9e7b94c34a8a1ea801f59837f MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/SystemSetting/SystemSetting.cs
@@ -42,7 +42,7 @@ public float GetSoundVolume() { return LocalSave.GetFloat(SOUND_VOLUME_KEY, .55f); return LocalSave.GetFloat(SOUND_VOLUME_KEY, 1.0f); } public void SetSoundEffect(float value) @@ -52,7 +52,7 @@ public float GetSoundEffect() { return LocalSave.GetFloat(SOUND_EFFECT_KEY, .8f); return LocalSave.GetFloat(SOUND_EFFECT_KEY, 1.0f); } public void SetGameFps(GameFps _frame) 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; } 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> /// 解析并计算数学表达式 /// 解析并计算数学表达式(优化版本,减少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)); } } Main/Utility/UIHelper.cs
@@ -66,6 +66,8 @@ #region UI通用 //默认货币图片用高清的,富文本的可以用小图标利于排版显示 public static void SetIconWithMoneyType(this Image _image, int moneyType) { if (_image == null) return; @@ -1308,7 +1310,7 @@ //bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$"); //var chsCount = GetChsCount(name); int length = Encoding.Default.GetBytes(name).Length; var maxlength = 14; //纯中文不建议超过7个字 var maxlength = 21; //纯中文不建议超过7个字 var minlength = 3; if (length > maxlength) {