完善Task的UI数据传递和刷新。

This commit is contained in:
YiHan0621
2025-09-10 17:34:28 +08:00
parent bf13498f86
commit d894d16884
5 changed files with 175 additions and 95 deletions

View File

@@ -150,16 +150,16 @@ namespace TcgEngine.Gameplay
foreach (var item in taskResponses)
{
Debug.Log($"缓存ID处<color=pink>{item.id}</color>");
// Debug.Log($"缓存ID处<color=pink>{item.id}</color>");
taskConfigs[item.id] =
TaskData.CreateFromResponse(item);
}
Debug.Log("共储存:" + taskConfigs.Count + "条信息");
// Debug.Log("共储存:" + taskConfigs.Count + "条信息");
foreach (var kvp in taskConfigs)
{
TaskData task = kvp.Value;
Debug.Log($"分别为 <color=red>{task.id}</color>");
// Debug.Log($"分别为 <color=red>{task.id}</color>");
}
}
catch (Exception e)
@@ -268,6 +268,7 @@ namespace TcgEngine.Gameplay
if (res.success)
{
Debug.Log("玩家任务已保存到服务器");
ResetUIPanel();
}
else
{
@@ -285,6 +286,7 @@ namespace TcgEngine.Gameplay
if (Input.GetKeyDown(KeyCode.S))
{
CheckExpiredTasks(playerTasks);
SavePlayerData();
}
}
@@ -425,6 +427,7 @@ namespace TcgEngine.Gameplay
}
task.status = TaskStatus.Claimed;
SavePlayerData();
return true;
}
@@ -470,7 +473,6 @@ namespace TcgEngine.Gameplay
private void UpdateTaskProgress(TaskConditionType conditionType, string parameter1 = null, string parameter2 = null)
{
bool progressUpdated = false;
refreshTaskUI?.Invoke(playerTasks);
foreach (var task in playerTasks)
{
if (task.status != TaskStatus.Active)
@@ -632,11 +634,6 @@ namespace TcgEngine.Gameplay
// 如过有就随机分配一个新任务
AssignDailyTaskIfNeeded();
}
// 登录任务完成
UpdateTaskProgress(TaskConditionType.LoginGame);
}
/// <summary>
@@ -663,6 +660,8 @@ namespace TcgEngine.Gameplay
lastDailyTaskAssigned = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
SavePlayerData();
Debug.Log($"分配登录任务: {loginTask.name}");
// 登录任务完成
UpdateTaskProgress(TaskConditionType.LoginGame);
}
else
{
@@ -688,5 +687,13 @@ namespace TcgEngine.Gameplay
{
return playerTasks;
}
/// <summary>
/// 重置面板
/// </summary>
private void ResetUIPanel()
{
refreshTaskUI?.Invoke(playerTasks);
}
}
}