From 29ba23403b97117c4bc65d380ec6502c5920477d Mon Sep 17 00:00:00 2001 From: YiHan0621 <2857295085@qq.com> Date: Mon, 8 Sep 2025 16:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BC=8F=E4=B8=8A=E4=BC=A0=EF=BC=8C=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TcgEngine/Prefabs/UI/DeckDisplay.prefab | 87 ++++++++++--------- Assets/TcgEngine/Scenes/Menu/Menu.unity | 6 +- Assets/TcgEngine/Scripts/Api/UserData.cs | 11 +++ Assets/TcgEngine/Scripts/Data/TaskData.cs | 25 ++++-- .../Scripts/GameLogic/TaskManager.cs | 3 +- Assets/TcgEngine/Scripts/Menu/MainMenu.cs | 11 +++ 6 files changed, 90 insertions(+), 53 deletions(-) diff --git a/Assets/TcgEngine/Prefabs/UI/DeckDisplay.prefab b/Assets/TcgEngine/Prefabs/UI/DeckDisplay.prefab index 74ab24b..0b82d24 100644 --- a/Assets/TcgEngine/Prefabs/UI/DeckDisplay.prefab +++ b/Assets/TcgEngine/Prefabs/UI/DeckDisplay.prefab @@ -28,6 +28,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 7582229092490914042} m_RootOrder: 0 @@ -107,6 +108,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 7582229092490914042} m_RootOrder: 1 @@ -185,6 +187,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 3371345542103985239} - {fileID: 7582229092255187381} @@ -359,12 +362,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059157995478947 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091098844522} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545803479578 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -377,6 +374,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059157995478947 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091098844522} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091224270575 PrefabInstance: m_ObjectHideFlags: 0 @@ -511,12 +514,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158925947942 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091224270575} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545675968927 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -529,6 +526,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158925947942 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091224270575} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091286495002 PrefabInstance: m_ObjectHideFlags: 0 @@ -663,12 +666,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158988172755 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091286495002} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545722398826 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -681,6 +678,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158988172755 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091286495002} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091326638487 PrefabInstance: m_ObjectHideFlags: 0 @@ -815,12 +818,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158890167134 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091326638487} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545505971943 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -833,6 +830,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158890167134 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091326638487} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091411733964 PrefabInstance: m_ObjectHideFlags: 0 @@ -967,12 +970,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158840782597 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091411733964} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545590737596 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -985,6 +982,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158840782597 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091411733964} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091563924092 PrefabInstance: m_ObjectHideFlags: 0 @@ -1119,12 +1122,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158594775221 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091563924092} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545210481932 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -1137,6 +1134,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158594775221 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091563924092} + m_PrefabAsset: {fileID: 0} --- !u!1001 &7582229091617377000 PrefabInstance: m_ObjectHideFlags: 0 @@ -1271,12 +1274,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 90f1aa482afcc9c4f87470c4d4557bc4, type: 3} ---- !u!224 &6672059158644033569 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, - type: 3} - m_PrefabInstance: {fileID: 7582229091617377000} - m_PrefabAsset: {fileID: 0} --- !u!114 &2521591545259773336 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 5460336411350321008, guid: 90f1aa482afcc9c4f87470c4d4557bc4, @@ -1289,3 +1286,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 943be08264f3555448cac48ac16c1e8c, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &6672059158644033569 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3868195550748869321, guid: 90f1aa482afcc9c4f87470c4d4557bc4, + type: 3} + m_PrefabInstance: {fileID: 7582229091617377000} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/TcgEngine/Scenes/Menu/Menu.unity b/Assets/TcgEngine/Scenes/Menu/Menu.unity index 5658b33..fc28f33 100644 --- a/Assets/TcgEngine/Scenes/Menu/Menu.unity +++ b/Assets/TcgEngine/Scenes/Menu/Menu.unity @@ -9438,7 +9438,7 @@ GameObject: m_Component: - component: {fileID: 634882798} m_Layer: 5 - m_Name: "\u7ECF\u9A8C" + m_Name: LevelProgress m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -31020,7 +31020,7 @@ MonoBehaviour: m_MinValue: 0 m_MaxValue: 1 m_WholeNumbers: 0 - m_Value: 0.561 + m_Value: 0.1 m_OnValueChanged: m_PersistentCalls: m_Calls: [] @@ -32516,6 +32516,8 @@ MonoBehaviour: credits_txt: {fileID: 1317959218} avatar: {fileID: 1120415714} loader: {fileID: 295344790} + level_text: {fileID: 217392228} + level_slider: {fileID: 1958182121} version_text: {fileID: 1975599770} deck_selector: {fileID: 1611943003454912994} deck_preview: {fileID: 1940984899} diff --git a/Assets/TcgEngine/Scripts/Api/UserData.cs b/Assets/TcgEngine/Scripts/Api/UserData.cs index 19a15ee..93f0953 100644 --- a/Assets/TcgEngine/Scripts/Api/UserData.cs +++ b/Assets/TcgEngine/Scripts/Api/UserData.cs @@ -58,6 +58,17 @@ namespace TcgEngine return Mathf.FloorToInt(xp / 1000) + 1; } + public float GetLevelProgress() + { + int currentLeve = GetLevel(); + int baseXp = (currentLeve - 1) * 1000; + Debug.LogError(xp); + // 距离下一级还需多少经验值 + int xpIntoCurrentLevel = xp - baseXp; + return (float)xpIntoCurrentLevel / 1000f; + + } + public string GetAvatar() { if (avatar != null) diff --git a/Assets/TcgEngine/Scripts/Data/TaskData.cs b/Assets/TcgEngine/Scripts/Data/TaskData.cs index 7fc4eb0..57a222c 100644 --- a/Assets/TcgEngine/Scripts/Data/TaskData.cs +++ b/Assets/TcgEngine/Scripts/Data/TaskData.cs @@ -69,26 +69,35 @@ namespace TcgEngine public class PlayerTask { public string taskId; - public DateTime assignedTime; - public DateTime expireTime; + public long assignedTime; + public long expireTime; public TaskStatus status; public int progress; // 当前进度 public PlayerTask(TaskData taskConfig) { taskId = taskConfig.id; - assignedTime = DateTime.Now; - expireTime = assignedTime.AddHours(taskConfig.durationHours); + assignedTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + expireTime = DateTimeOffset.UtcNow.AddHours(taskConfig.durationHours).ToUnixTimeSeconds(); + Debug.Log($"" + + $"任务获取时间=={assignedTime}" + + $"任务结束时间=={expireTime}" + + $""); status = TaskStatus.Active; progress = 0; } + // 从服务器响应数据创建玩家任务 public PlayerTask(PlayerTaskResponse response) { taskId = response.taskId; - assignedTime = new DateTime(response.assignedTime); - expireTime = new DateTime(response.expireTime); + assignedTime = response.assignedTime; + expireTime = response.expireTime; + Debug.Log($"" + + $"任务获取时间=={assignedTime}" + + $"任务结束时间=={expireTime}" + + $""); status = (TaskStatus)response.status; progress = response.progress; } @@ -98,8 +107,8 @@ namespace TcgEngine { PlayerTaskResponse response = new PlayerTaskResponse(); response.taskId = taskId; - response.assignedTime = assignedTime.Ticks; - response.expireTime = expireTime.Ticks; + response.assignedTime = assignedTime; + response.expireTime = expireTime; response.status = (int)status; response.progress = progress; return response; diff --git a/Assets/TcgEngine/Scripts/GameLogic/TaskManager.cs b/Assets/TcgEngine/Scripts/GameLogic/TaskManager.cs index a630f39..bb6c94d 100644 --- a/Assets/TcgEngine/Scripts/GameLogic/TaskManager.cs +++ b/Assets/TcgEngine/Scripts/GameLogic/TaskManager.cs @@ -136,7 +136,8 @@ namespace TcgEngine.Gameplay // 从服务器API获取任务配置 string url = ApiClient.ServerURL + "/api/tasks"; WebResponse res = await ApiClient.Get().SendGetRequest(url); - Debug.LogError("从服务器API获取任务配置" + res.data); + Debug.LogError("从服务器API获取任务配置" + res.data + res.status); + Debug.LogError(res.success); if (res.success) { // 解析任务配置数据 diff --git a/Assets/TcgEngine/Scripts/Menu/MainMenu.cs b/Assets/TcgEngine/Scripts/Menu/MainMenu.cs index ca5498b..bd05350 100644 --- a/Assets/TcgEngine/Scripts/Menu/MainMenu.cs +++ b/Assets/TcgEngine/Scripts/Menu/MainMenu.cs @@ -21,6 +21,10 @@ namespace TcgEngine.UI public Text credits_txt; public AvatarUI avatar; public GameObject loader; + + [Header("xp")] + public Text level_text; + public Slider level_slider; [Header("UI")] public Text version_text; @@ -51,6 +55,9 @@ namespace TcgEngine.UI version_text.text = "Version " + Application.version; deck_selector.onChange += OnChangeDeck; + level_text.text = ""; + level_slider.value = 0f; + if (Authenticator.Get().IsConnected()) AfterLogin(); else @@ -108,6 +115,10 @@ namespace TcgEngine.UI username_txt.text = user.username; credits_txt.text = GameUI.FormatNumber(user.coins); + // xp + level_text.text = user.GetLevel().ToString(); + level_slider.value = user.GetLevelProgress(); + AvatarData avatar = AvatarData.Get(user.avatar); this.avatar.SetAvatar(avatar);