You've already forked taptap2024_GJ_chidouren
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
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 ();
|
||
}
|
||
}
|
||
|
||
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 ()
|
||
{
|
||
}
|
||
}
|
||
} |