43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using UnityEngine;
|
|
using TcgEngine.Client;
|
|
using TcgEngine.Gameplay;
|
|
|
|
namespace TcgEngine.Client
|
|
{
|
|
/// <summary>
|
|
/// 游戏客户端任务集成,用于将任务系统集成到游戏客户端中
|
|
/// </summary>
|
|
public class GameClientTaskIntegration : MonoBehaviour
|
|
{
|
|
private void Start()
|
|
{
|
|
// 在游戏客户端启动时初始化任务系统
|
|
GameClient client = GameClient.Get();
|
|
if (client != null)
|
|
{
|
|
// 玩家连接到游戏服务器时触发任务检查
|
|
client.onConnectServer += OnConnectToServer;
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
// 取消订阅事件
|
|
GameClient client = GameClient.Get();
|
|
if (client != null)
|
|
{
|
|
client.onConnectServer -= OnConnectToServer;
|
|
}
|
|
}
|
|
|
|
private void OnConnectToServer()
|
|
{
|
|
// 玩家登录时检查任务
|
|
TaskManager taskManager = TaskManager.Instance;
|
|
if (taskManager != null)
|
|
{
|
|
taskManager.OnPlayerLogin();
|
|
}
|
|
}
|
|
}
|
|
} |