Files
taptap2024_GJ_chidouren/Assets/Scripts/System/StateSystem/State/StateHome.cs
2024-10-21 22:29:53 +08:00

68 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.StateSystem;
using Framework.Audio;
using Framework.FSMLite;
using Framework.Timer;
using Framework.UI;
using StateSystem.Loader;
using UnityEngine;
using UnityEngine.SceneManagement;
using Views;
using AudioType = Framework.Audio.AudioType;
namespace StateSystem.State
{
public class StateHome : StateMachine<GameGlobalState>
{
private SceneLoader _loader;
public int _lastCatLevel = -1; //记录上一次的猫的等级,用于判断是否升级
protected override async void OnEnter (params object[] args)
{
AudioManager.Instance.PlayBGM (BgmAudio.LobbyBgm);
GameUpdateMgr.Instance.AddUpdater (DoUpdate);
// var activeScene = SceneManager.GetActiveScene ();
// if (activeScene.name != SceneName.MainScene.ToString ())
// {
// Debug.Log ("进入Home开始加载场景" + SceneName.MainScene.ToString ());
// this._loader = new SceneLoader (SceneName.MainScene);
// this._loader.BeginLoad (OnLoading, OnActived);
// }
// else
// {
// OnActived ();
// }
OnActived ();
}
private void OnLoading (float obj)
{
Debug.Log ("加载进度: " + obj);
if (obj >= 1)
{
// Debug.Log("加载完成");
this._loader.Active ();
}
}
private void OnActived ()
{
UIManager.Instance.OpenView (UIPanel.HomePanel);
UIManager.Instance.CloseLoading (null);
}
protected override void OnExit ()
{
GameUpdateMgr.Instance.RemoveUpdater (DoUpdate);
// this._loader.Kill ();
}
private void DoUpdate ()
{
}
}
}