killapp/Assets/Scripts/UI/Pages/HomePageCtrl.cs

62 lines
1.5 KiB
C#
Raw Normal View History

2026-03-30 16:25:00 +08:00
using System.Collections;
using System.Collections.Generic;
2026-04-16 14:57:19 +08:00
using Kill.Managers;
2026-03-30 16:25:00 +08:00
using UnityEngine;
using UnityEngine.UI;
using System;
2026-04-16 14:57:19 +08:00
namespace Kill.UI.Pages
2026-03-30 16:25:00 +08:00
{
public class HomePageCtrl : MonoBehaviour
{
2026-04-24 16:57:44 +08:00
public GameObject noDevicePage;
2026-03-30 16:25:00 +08:00
// 存储待执行的UI更新操作
private List<Action> pendingUIUpdates = new List<Action>();
void Start()
{
Init();
}
void Update()
{
// 执行所有挂起的UI更新
if (pendingUIUpdates.Count > 0)
{
foreach (var update in pendingUIUpdates)
{
update?.Invoke();
}
pendingUIUpdates.Clear();
}
}
public void Init()
{
2026-04-24 16:57:44 +08:00
if(DataManager.Instance.userInfo.device_count==0)
2026-03-30 16:25:00 +08:00
{
2026-04-24 16:57:44 +08:00
noDevicePage.SetActive(true);
}
else
2026-03-30 16:25:00 +08:00
{
2026-04-24 16:57:44 +08:00
noDevicePage.SetActive(false);
}
2026-03-30 16:25:00 +08:00
}
2026-04-24 16:57:44 +08:00
public void ConnectDevice()
2026-03-30 16:25:00 +08:00
{
2026-04-24 16:57:44 +08:00
if(!CheckSafetylearning())
{
UIManager.Instance.OpenPage(UIManager.PageName.safetylearningPage);
return;
}
UIManager.Instance.OpenPage(UIManager.PageName.connectDevicePage);
2026-03-30 16:25:00 +08:00
}
2026-04-24 16:57:44 +08:00
public bool CheckSafetylearning()
2026-03-30 16:25:00 +08:00
{
2026-04-24 16:57:44 +08:00
bool isPassed=false;
isPassed=DataManager.Instance.userInfo.exam_completed;
return isPassed;
2026-03-30 16:25:00 +08:00
}
}
}