排行榜按钮UI提交、任务刷新失败修复、卡牌碎片与钻石接口。
This commit is contained in:
@@ -241,6 +241,7 @@ namespace TcgEngine
|
||||
if (res.success)
|
||||
{
|
||||
udata = ApiTool.JsonToObject<UserData>(res.data);
|
||||
Debug.Log($"获取玩家数据:{res.data}");
|
||||
}
|
||||
|
||||
return udata;
|
||||
|
||||
@@ -26,10 +26,12 @@ namespace TcgEngine
|
||||
public int coins;
|
||||
public int xp;
|
||||
public int elo;
|
||||
public int cardfragments;
|
||||
|
||||
public int matches;
|
||||
public int victories;
|
||||
public int defeats;
|
||||
public int crystal;
|
||||
|
||||
public UserCardData[] cards;
|
||||
public UserCardData[] packs;
|
||||
@@ -51,6 +53,7 @@ namespace TcgEngine
|
||||
permission_level = 1;
|
||||
coins = 10000;
|
||||
elo = 1000;
|
||||
cardfragments = 1000;// 碎片
|
||||
}
|
||||
|
||||
public int GetLevel()
|
||||
|
||||
@@ -23,42 +23,36 @@ namespace TcgEngine.Client
|
||||
|
||||
private GameClient client;
|
||||
private TaskPanel taskPanel;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 在游戏客户端启动时初始化任务系统
|
||||
client = FindFirstObjectByType<GameClient>();
|
||||
client = GameClient.Get();
|
||||
if (client != null)
|
||||
{
|
||||
// 玩家连接到游戏服务器时触发任务检查
|
||||
client.onConnectServer += OnConnectToServer;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"---{client}为空----");
|
||||
}
|
||||
|
||||
if (TaskManager.Instance != null)
|
||||
{
|
||||
TaskManager.Instance.refreshTaskUI += OnRefreshTaskPanel;
|
||||
TaskManager.Instance.ResetUIPanel();
|
||||
}
|
||||
|
||||
// 找 UI 面板
|
||||
private void Awake()
|
||||
{
|
||||
taskPanel = GetComponent<TaskPanel>();
|
||||
if (taskPanel == null)
|
||||
{
|
||||
taskPanel = FindObjectOfType<TaskPanel>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
private void OnEnable()
|
||||
{
|
||||
client.onConnectServer -= OnConnectToServer;
|
||||
TaskManager.Instance.refreshTaskUI -= OnRefreshTaskPanel;
|
||||
|
||||
client = GameClient.Get();
|
||||
if (client != null)
|
||||
client.onConnectServer += OnConnectToServer;
|
||||
|
||||
if (TaskManager.Instance != null)
|
||||
{
|
||||
TaskManager.Instance.refreshTaskUI += OnRefreshTaskPanel;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (client != null)
|
||||
client.onConnectServer -= OnConnectToServer;
|
||||
|
||||
if (TaskManager.Instance != null)
|
||||
TaskManager.Instance.refreshTaskUI -= OnRefreshTaskPanel;
|
||||
}
|
||||
|
||||
private void OnConnectToServer()
|
||||
@@ -68,7 +62,6 @@ namespace TcgEngine.Client
|
||||
if (taskManager != null)
|
||||
{
|
||||
taskManager.OnPlayerLogin();
|
||||
// 强制第一次刷新
|
||||
OnRefreshTaskPanel(TaskManager.Instance.GetAllTasks());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,17 +38,13 @@ namespace TcgEngine.Gameplay
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -69,6 +69,8 @@ namespace TcgEngine.UI
|
||||
|
||||
private List<UserCardData> deck_cards = new List<UserCardData>();
|
||||
|
||||
[SerializeField] private Text cardFragmentsText;
|
||||
|
||||
private static CollectionPanel instance;
|
||||
|
||||
protected override void Awake()
|
||||
@@ -115,7 +117,11 @@ namespace TcgEngine.UI
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (ApiClient.Get() != null)
|
||||
{
|
||||
UserData udata = ApiClient.Get().UserData;
|
||||
cardFragmentsText.text = udata.cardfragments.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace TcgEngine.UI
|
||||
[Header("Player UI")]
|
||||
public Text username_txt;
|
||||
public Text credits_txt;
|
||||
public Text crystalText;
|
||||
public AvatarUI avatar;
|
||||
public GameObject loader;
|
||||
|
||||
@@ -43,7 +44,6 @@ namespace TcgEngine.UI
|
||||
//Set default settings
|
||||
Application.targetFrameRate = 120;
|
||||
GameClient.game_settings = GameSettings.Default;
|
||||
Debug.Log("WOWO_Awake");
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -64,7 +64,6 @@ namespace TcgEngine.UI
|
||||
AfterLogin();
|
||||
else
|
||||
RefreshLogin();
|
||||
// TaskManager.Instance.SavePlayerData();
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -73,6 +72,7 @@ namespace TcgEngine.UI
|
||||
if (udata != null)
|
||||
{
|
||||
credits_txt.text = GameUI.FormatNumber(udata.coins);
|
||||
crystalText.text = GameUI.FormatNumber(udata.crystal);
|
||||
}
|
||||
|
||||
bool matchmaking = GameClientMatchmaker.Get().IsMatchmaking();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TcgEngine.Client;
|
||||
using TcgEngine.Gameplay;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine.UI
|
||||
@@ -23,6 +24,9 @@ namespace TcgEngine.UI
|
||||
{
|
||||
base.Start();
|
||||
Show();
|
||||
// UI 准备好后自己请求刷新
|
||||
if (TaskManager.Instance != null)
|
||||
TaskManager.Instance.ResetUIPanel();
|
||||
}
|
||||
|
||||
public void RefreshTasks(List<PlayerTask> playerTasks)
|
||||
|
||||
Reference in New Issue
Block a user