Browse Source

1. Editor文件夹中新增了一个删除数据的按钮
2. 修复了保存数据的bug

lcn 4 months ago
parent
commit
85f2f0523f

+ 14 - 0
Assets/Editor/GameRuntimeConfig.asset

@@ -0,0 +1,14 @@
+%YAML 1.1
+%TAG !u! tag:yousandi.cn,2023:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 18b6889e9e2ff420b8f9de8fb48fd8ae, type: 3}
+  m_Name: GameRuntimeConfig
+  m_EditorClassIdentifier: 

+ 8 - 0
Assets/Editor/GameRuntimeConfig.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: Cywb4yj7AnM8swYB8kOPX9RjPX/IZXjkDRxy6Tjcln86Yrb5IfYznkg=
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 11400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 53 - 0
Assets/Editor/GameRuntimeConfigInspector.cs

@@ -0,0 +1,53 @@
+using Fort23.Common;
+using Fort23.Mono;
+using Fort23.UTool;
+using UnityEditor;
+using UnityEngine;
+
+namespace Fort23.Editor
+{
+    [CustomEditor(typeof(GameRuntimeConfig))]
+    public class GameRuntimeConfigInspector : UnityEditor.Editor
+    {
+        public override void OnInspectorGUI()
+        {
+            // GameRuntimeConfig runtimeConfig = target as GameRuntimeConfig;
+            // runtimeConfig.isUpdateAsset = EditorGUILayout.Toggle("是否开启更新资源", runtimeConfig.isUpdateAsset);
+            // runtimeConfig.version = EditorGUILayout.IntField("当前大版本", runtimeConfig.version);
+            // runtimeConfig.buildVer = EditorGUILayout.IntField("当前小版本", runtimeConfig.buildVer);
+            // runtimeConfig.assetVer = EditorGUILayout.IntField("当前资源版本", runtimeConfig.assetVer);
+            // runtimeConfig.serverVer = EditorGUILayout.IntField("当前服务器版本", runtimeConfig.serverVer);
+            // // runtimeConfig.authen = EditorGUILayout.Toggle("是否开启防沉谜", runtimeConfig.authen);
+            // runtimeConfig.unLockAll = EditorGUILayout.Toggle("是否解锁全部系统", runtimeConfig.unLockAll);
+            //
+            //
+            // EditorGUILayout.Space(20);
+            // EditorGUILayout.LabelField("引导相关");
+            //
+            // runtimeConfig.isSkip = EditorGUILayout.Toggle("是否跳过", runtimeConfig.isSkip);
+            // runtimeConfig.isUnlockAll = EditorGUILayout.Toggle("是否全部解锁", runtimeConfig.isUnlockAll);
+            // runtimeConfig.IsUseServerData = EditorGUILayout.Toggle("是否使用服务器引导数据", runtimeConfig.IsUseServerData);
+            // runtimeConfig.isDebug = EditorGUILayout.Toggle("是否开启调试模式", runtimeConfig.isDebug);
+            //
+            //
+            //
+            // runtimeConfig.debugPhase = EditorGUILayout.Vector4Field("指定调试新手引导", runtimeConfig.debugPhase);
+            //
+            //
+            // runtimeConfig.ClearGuideData = EditorGUILayout.Toggle("是否清除新手引导数据", runtimeConfig.ClearGuideData);
+            //
+            // runtimeConfig.isSaveCombat = EditorGUILayout.Toggle("开始战斗日志保存", runtimeConfig.isSaveCombat);
+            // runtimeConfig.isAllLog = EditorGUILayout.Toggle("开始战斗日志记录", runtimeConfig.isAllLog);
+            
+            if (GUILayout.Button("清理本地储存"))
+            {
+                PlayerPrefs.DeleteAll();
+                PlayerPrefs.Save();
+                LogTool.Log("清理本地储存成功.");
+                AccountFileInfo.Instance.DeleteFile(AccountFileInfo.Instance.persistentDataPath);
+            }
+
+            // EditorUtility.SetDirty(runtimeConfig);
+        }
+    }
+}

+ 11 - 0
Assets/Editor/GameRuntimeConfigInspector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: CCgY4SOtAi5Vi1igRJfTMHjTRhj7C80TpB4LByaYiwgZb6qmiHjjllc=
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 172 - 0
Assets/Scripts/Core/Utility/GameRuntimeConfig.cs

@@ -0,0 +1,172 @@
+using System;
+using UnityEngine;
+using UnityEngine.Serialization;
+
+namespace Fort23.Mono
+{
+    [CreateAssetMenu(fileName = "Assets/GameRuntimeConfig", menuName = "GameRuntimeConfig", order = 0)]
+    public class GameRuntimeConfig : ScriptableObject
+    {
+        // // 大版本号
+        // public int version;
+        //
+        // // 发布版本号
+        // public int buildVer;
+        //
+        // // 资源版本号
+        // public int assetVer;
+        //
+        // // 服务器版本号
+        // public int serverVer;
+        //
+        // // 发送给服务器的资源版本号,与服务器对比,用于客户端资源强更
+        // public int sendAssetVer;
+        //
+        // /// <summary>
+        // /// 解锁所有系统
+        // /// </summary>
+        // public bool unLockAll;
+        //
+        // public bool isUpdateAsset;
+        //
+        //
+        // public bool isSkip;
+        //
+        // public bool isUnlockAll;
+        //
+        // public bool isDebug;
+        //
+        // public bool IsUseServerData;
+        //
+        // public Vector4 debugPhase;
+        //
+        // public bool ClearGuideData;
+        //
+        //
+        // public Area area;
+        // public CDN cdn;
+        // public LoginServer loginServer;
+        // public bool isSaveCombat = false;
+        // public bool isAllLog = false;
+        //
+        // public string AppVer
+        // {
+        //     get { return version + "." + buildVer; }
+        // }
+    }
+
+
+    // [Flags]
+    // public enum Area
+    // {
+    //     [EnumLabel("无", "")] None = 0,
+    //     [EnumLabel("国际", "AREA_ABROAD")] Abroad = 2,
+    //     [EnumLabel("越南", "AREA_VIETNAM")] Vietnam = 4,
+    //     [EnumLabel("韩国", "AREA_KOREA")] Korea = 8,
+    //     [EnumLabel("国内", "AREA_CHINA")] China = 16,
+    //     [EnumLabel("香港", "AREA_HK")] HongKang = 32,
+    // }
+    //
+    // public enum CDN
+    // {
+    //     [EnumLabel("华为云(备用)", "http://121.36.145.47/TestAsset/")]
+    //     HuaWei,
+    //
+    //     [EnumLabel("国际正式", "http://autoheros.test.233i.com/data/007asset/")]
+    //     HaiWai,
+    //
+    //     [EnumLabel("国际测试", "http://121.36.145.47/GuoJi/")]
+    //     HaiWaiTest,
+    //
+    //     [EnumLabel("国内正式", "http://cn-autoheros.233i.com/data/007asset/")]
+    //     GuoNei,
+    //
+    //     [EnumLabel("国内测试", "http://121.36.145.47/GuoNei/")]
+    //     GuoNeiTest,
+    //
+    //     [EnumLabel("韩国正式", "http://autoheros.test.233i.com/data/007asset/fort23Test/")]
+    //     HanGuo,
+    //
+    //     [EnumLabel("韩国测试", "http://121.36.145.47/HanGuo/")]
+    //     HanGuoTest,
+    //
+    //     [EnumLabel("越南正式", "http://121.36.145.47/TestAsset/")]
+    //     YueNan,
+    //
+    //     [EnumLabel("越南测试", "http://121.36.145.47/YueNan/")]
+    //     YueNanTest,
+    //
+    //     [EnumLabel("港澳台正式", "http://121.36.145.47/GAT/")]
+    //     HK,
+    //
+    //     [EnumLabel("港澳台测试", "http://121.36.145.47/YueNan/")]
+    //     KHTest,
+    //
+    //     [EnumLabel("本地(192.168.123.xxx:8080)", "http://192.168.123.216:8080/res/")]
+    //     Other,
+    // }
+    //
+    // public enum LoginServer
+    // {
+    //     [EnumLabel("国际测试(华为)", data: "http://121.36.145.47:998")]
+    //     HuaWei,
+    //
+    //     [EnumLabel("国际正式(腾讯)", "http://autoheros.login.233i.com:1000")]
+    //     HaiWai,
+    //
+    //     [EnumLabel("国内正式", "http://cn-autoheros.login.233i.com:999")]
+    //     GuoNei,
+    //
+    //     [EnumLabel("国内审核测试", "http://autoheros_cn_test.login.233i.com:1000")]
+    //     GuoNeiTest,
+    //
+    //     [EnumLabel("韩国", "http://101.33.66.62:1000")]
+    //     HanGuo,
+    //
+    //     [EnumLabel("越南", "http://103.124.94.73:1000")]
+    //     YueNan,
+    //
+    //     [EnumLabel("港澳台", "http://175.97.134.167:10001")]
+    //     HK,
+    //
+    //     [EnumLabel("海外测试(华为997)", data: "http://121.36.145.47:997")]
+    //     HuaWei_997,
+    //
+    //     //[EnumLabel("其他(192.168.123.xxx:1000)", "http://192.168.123.216:1000")]
+    //     [EnumLabel("其他(192.168.123.xxx:1000)", "http://127.0.0.1:1000")]
+    //     Other
+    // }
+    //
+    // public enum AnaroidPackNameServer
+    // {
+    //     [EnumLabel("海外", data = "com.axe233i.autoheroes.oversea.andriod")]
+    //     A_Google,
+    //
+    //     [EnumLabel("国内", data = "com.shiguangniuniu.autoheroes.domestic.android")]
+    //     A_GuoNei,
+    //
+    //     [EnumLabel("韩国", data = "com.youloft.autoheroes")]
+    //     A_HaiGuo,
+    //
+    //     [EnumLabel("越南", data = "com.mobileevosaigon.starvearena")] // com.misaigon.starvearena
+    //     A_YueNan,
+    //
+    //     [EnumLabel("港澳台", data = "com.luckyfun.aedzj")]
+    //     A_GangAoTai,
+    // }
+    //
+    // public enum IosPackNameServer
+    // {
+    //     [EnumLabel("海外", data = "com.axe233i.autoheroes.oversea.ios")]
+    //     iOS_haiwai,
+    //
+    //     [EnumLabel("国内", data = "com.shiguangniuniu.autoheroes.domestic.ios")]
+    //     iOS_GuoNei,
+    //
+    //     [EnumLabel("越南", data = "com.mobileevosaigon.starvearena.ios")]
+    //     iOS_YueNan,
+    //
+    //     [EnumLabel("港澳台", data = "com.cyh.aedzj")]
+    //     ioS_GangAoTai,
+    // }
+}

+ 11 - 0
Assets/Scripts/Core/Utility/GameRuntimeConfig.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: DnJNsyKlWi6AcCrpXzevhZ8StBgzn664gnvILQvirqcPkvJYD9VhOFM=
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 14 - 1
Assets/Scripts/GameLogic/Player/AccountFileInfo.cs

@@ -8,7 +8,7 @@ using Utility;
 public class AccountFileInfo : Singleton<AccountFileInfo>
 {
     
-    private string persistentDataPath = Application.persistentDataPath + "/playerData.txt";
+    public string persistentDataPath = Application.persistentDataPath + "/playerData.txt";
     public PlayerData playerData = new PlayerData();
     
     [System.Serializable]
@@ -57,6 +57,19 @@ public class AccountFileInfo : Singleton<AccountFileInfo>
             File.WriteAllText(persistentDataPath, playerSettingJson);
         }
     }
+    
+    public void DeleteFile(string filePath)
+    {
+        if (File.Exists(filePath))
+        {
+            File.Delete(filePath); // 删除文件
+            LogTool.Log($"文件已删除:{filePath}");
+        }
+        else
+        {
+            LogTool.Log($"文件不存在:{filePath}");
+        }
+    }
 
     /// <summary>
     /// 不要服务器的话,这里初始化玩家的起始数据

+ 8 - 0
Assets/Scripts/GameLogic/Player/PlayerManager.cs

@@ -15,6 +15,8 @@ public class PlayerManager : Singleton<PlayerManager>
     public List<HeroInfo> heroListInLead = new List<HeroInfo>();
 
     public GameConstantConfig gameConstantConfig;
+    
+    public HeroInfo lastHeroInfo;
 
     public void Init()
     {
@@ -82,6 +84,11 @@ public class PlayerManager : Singleton<PlayerManager>
 
     public CombatHeroInfo GetHeroInfo(int modelID)
     {
+        if (lastHeroInfo != null && lastHeroInfo.modelID == modelID)
+        {
+            return lastHeroInfo;
+        }
+        
         for (int i = 0; i < heroListInLead.Count; i++)
         {
             HeroInfo info = heroListInLead[i];
@@ -132,6 +139,7 @@ public class PlayerManager : Singleton<PlayerManager>
                     AccountFileInfo.Instance.playerData.HeroListInLeadDatas[i] = heroInfo.ToHeroData();
                     //存下来,用于快速查找
                     leadHeroIdx = i;
+                    AccountFileInfo.Instance.SavePlayerData();
                     return;
                 }
             }

+ 1 - 1
Assets/Scripts/GameUI/GameApplction.cs

@@ -53,7 +53,7 @@ public class GameApplction : MonoBehaviour
         CustomTweenManager.Init();
 
         PlayerManager.Instance.Init();
-        PlayerManager.Instance.InitTestHero();
+        // PlayerManager.Instance.InitTestHero();
         //主UI加载
         MainSceneController.Instance.Init();
 

+ 2 - 0
Assets/Scripts/GameUI/UI/Hero/HeroDetailPanel.cs

@@ -43,6 +43,8 @@ namespace Fort23.Mono
             UpdateAttributeUI();
             HeroLvUpgradeEventData data = new HeroLvUpgradeEventData();
             data.heroModelID = heroInfo.modelID;
+            
+            PlayerManager.Instance.lastHeroInfo = heroInfo;
             EventManager.Instance.Dispatch(CustomEventType.HeroUpgrade, data);
         }
         private void OnClickClose()

+ 15 - 4
Assets/Scripts/GameUI/UI/Hero/WidgetHero.cs

@@ -47,7 +47,7 @@ namespace Fort23.Mono
         }
 
 
-        private HeroInfo heroInfo;
+        public HeroInfo heroInfo;
         
         /// <summary>
         /// 
@@ -56,14 +56,25 @@ namespace Fort23.Mono
         public void InitHero(HeroInfo heroInfo)
         {
             this.heroInfo = heroInfo;
-            lv.text = heroInfo.level.Value.ToString();
+            // lv.text = heroInfo.level.Value.ToString();
             iconHero.icon_name = heroInfo.modelConfig.headicon;
             iconHero.SetNativeSize();
             iconZhiYe.icon_name = heroInfo.iconZhiYe;
             
+            // HeroUITools.SetStarShow(stars, heroInfo.star.Value);
+            SetDynamicData();
+        }
+
+        public void UpdateHero(HeroInfo heroInfo)
+        {
+            this.heroInfo = heroInfo;
+            SetDynamicData();
+        }
+
+        public void SetDynamicData()
+        {
+            lv.text = heroInfo.level.Value.ToString();
             HeroUITools.SetStarShow(stars, heroInfo.star.Value);
-            
-            
         }
         
     }

+ 25 - 0
Assets/Scripts/GameUI/UI/MainUIPanel.cs

@@ -1,3 +1,4 @@
+using System.Collections.Generic;
 using System.Threading.Tasks;
 using Common.Utility.CombatEvent;
 using Fort23.Core;
@@ -13,17 +14,20 @@ namespace Fort23.Mono
     {
         private void Init()
         {
+            
             InitBattleHero();
         }
 
         protected override void AddEvent()
         {
             CombatEventManager.Instance.AddEventListener(CombatEventType.CombatExpAlter, CombatExpAlter);
+            EventManager.Instance.AddEventListener(CustomEventType.HeroUpgrade, OnHeroUpgrade);
         }
 
         protected override void DelEvent()
         {
             CombatEventManager.Instance.RemoveEventListener(CombatEventType.CombatExpAlter, CombatExpAlter);
+            EventManager.Instance.RemoveEventListener(CustomEventType.HeroUpgrade, OnHeroUpgrade);
         }
 
         public override void AddButtonEvent()
@@ -49,14 +53,35 @@ namespace Fort23.Mono
             TextExp.text = levelBattleCombatType.exp + "/" + levelBattleCombatType.CurrMaxExp;
         }
 
+        private void OnHeroUpgrade(IEventData eventData) 
+        {
+            HeroLvUpgradeEventData data = eventData as HeroLvUpgradeEventData;
+            HeroInfo heroInfo = (HeroInfo)PlayerManager.Instance.GetHeroInfo(data.heroModelID);
+
+            foreach (WidgetHero widgetHero in widgetHeroes)
+            {
+                if (widgetHero.heroInfo.modelID == heroInfo.modelID)
+                {
+                    widgetHero.UpdateHero(heroInfo);
+                    break;
+                }
+            }
+        }
+
+        
+        private List<WidgetHero> widgetHeroes = new List<WidgetHero>(); 
+            
         private async void InitBattleHero()
         {
+            widgetHeroes.Clear();
             for (int i = 0; i < PlayerManager.Instance.heroListInLead.Count; i++)
             {
                 RectTransform rectTransform = hero_battle[i] as RectTransform;
                 WidgetHero itemHero = await UIManager.Instance.CreateGComponent<WidgetHero>(null,
                     poolName: "WidgetHero", root: rectTransform);
                 itemHero.InitHero(PlayerManager.Instance.heroListInLead[i]);
+                
+                widgetHeroes.Add(itemHero);
             }
         }
     }

File diff suppressed because it is too large
+ 0 - 0
Assets/StreamingAssets/assetConfig.txt


File diff suppressed because it is too large
+ 183 - 699
UserSettings/Layouts/CurrentMaximizeLayout.dwlt


Some files were not shown because too many files changed in this diff