You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
74
Assets/Scripts/System/StateSystem/State/StateLoading.cs
Normal file
74
Assets/Scripts/System/StateSystem/State/StateLoading.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.StateSystem;
|
||||
using Framework.Audio;
|
||||
using Framework.FSMLite;
|
||||
using Framework.Timer;
|
||||
using Framework.UI;
|
||||
using Framework.Utils.Extend;
|
||||
using StateSystem.Loader;
|
||||
using UnityEngine;
|
||||
using Views;
|
||||
using AudioType = Framework.Audio.AudioType;
|
||||
|
||||
namespace StateSystem.State
|
||||
{
|
||||
public class StateLoading : StateMachine<GameGlobalState>
|
||||
{
|
||||
private GameGlobalState _targetGlobalState;
|
||||
private object[] _targetParams;
|
||||
private ILoader _loader;
|
||||
|
||||
protected override void OnEnter(params object[] args)
|
||||
{
|
||||
// AudioManager.Instance.StopPlayers (AudioType.BGM , 0.5f);
|
||||
// UIManager.Instance.OpenView(UIPanel.LoadingPanel);
|
||||
if (args[0] is GameGlobalState)
|
||||
{
|
||||
this._targetGlobalState = (GameGlobalState) args[0];
|
||||
GameUpdateMgr.Instance.CreateTimer((float) args[1],
|
||||
() => { this.stateMachineRunner.OpenState(this._targetGlobalState); });
|
||||
}
|
||||
else
|
||||
{
|
||||
this._loader = (ILoader) args[0];
|
||||
this._targetGlobalState = (GameGlobalState) args[1];
|
||||
// this._targetParams = args[2];
|
||||
if (args.Length > 2)
|
||||
{
|
||||
this._targetParams = new object[args.Length - 2];
|
||||
for (int i = 2; i < args.Length; i++)
|
||||
{
|
||||
this._targetParams[i - 2] = args[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._targetParams = null;
|
||||
}
|
||||
this._loader.BeginLoad(OnLoading, OnLoadComplete);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoading(float progress)
|
||||
{
|
||||
Debug.Log("加载中: " + progress);
|
||||
if (progress.Compare(1))
|
||||
{
|
||||
// GameUpdateMgr.Instance.CreateTimer(2.6f,
|
||||
// () => { UIManager.Instance.CloseView(UIPanel.LoadingPanel);});
|
||||
GameUpdateMgr.Instance.CreateTimer(2.5f,
|
||||
() => { this._loader.Active(); });
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoadComplete()
|
||||
{
|
||||
this.stateMachineRunner.OpenState(this._targetGlobalState , this._targetParams);
|
||||
}
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user