You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
84
Assets/Scripts/System/StateSystem/State/StateRoom.cs
Normal file
84
Assets/Scripts/System/StateSystem/State/StateRoom.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.StateSystem;
|
||||
using Framework.Asset;
|
||||
using Framework.Audio;
|
||||
using Framework.FSMLite;
|
||||
using Framework.GamePool.manager;
|
||||
using Framework.UI;
|
||||
using Game;
|
||||
using Game.Data;
|
||||
using Game.Manager;
|
||||
using Runtime.ADAggregator;
|
||||
using StateSystem.Loader;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Views;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace StateSystem.State
|
||||
{
|
||||
public class StateRoom : StateMachine<GameGlobalState>
|
||||
{
|
||||
public static string RoomGroup = "ROOM_OBJECT_GROUP";
|
||||
private SceneLoader _loader;
|
||||
|
||||
protected override void OnEnter(params object[] args)
|
||||
{
|
||||
ADManager.Instance.LoadAD (AD_Type.AwardVideo);
|
||||
//预加载资源
|
||||
Debug.Log ("Asset pre load " + AssetManager.ResRootPath + "AutoSource/");
|
||||
AssetManager.Instance.LoadAssets<Object>(AssetManager.ResRootPath + "AutoSource/");
|
||||
PoolObjectPreload ();
|
||||
GameManager.Instance.StartAutoSave ();
|
||||
LoadScene ();
|
||||
}
|
||||
|
||||
|
||||
private void LoadScene ()
|
||||
{
|
||||
var activeScene = SceneManager.GetActiveScene();
|
||||
if (activeScene.name != SceneName.GameScene.ToString())
|
||||
{
|
||||
Debug.Log("进入Home,开始加载场景:" + SceneName.GameScene);
|
||||
this._loader = new SceneLoader(SceneName.GameScene);
|
||||
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()
|
||||
{
|
||||
RoomManager.Instance.JoinGame ();
|
||||
}
|
||||
|
||||
private void PoolObjectPreload ()
|
||||
{
|
||||
GamePoolManager.Instance.LoadPoolObjects("UI/",RoomGroup , 5);
|
||||
GamePoolManager.Instance.LoadPoolObjects("Object/",RoomGroup , 5);
|
||||
}
|
||||
|
||||
protected override void OnExit()
|
||||
{
|
||||
UIManager.Instance.CloseViewWithGroup (RoomGroup);
|
||||
GamePoolManager.Instance.KillForGroup (RoomGroup);
|
||||
GameManager.Instance.EndAutoSave ();
|
||||
Account.Instance.Save();
|
||||
AssetManager.Instance.UnLoadAssets(AssetManager.ResRootPath + "AutoSource/" , false);
|
||||
SpriteLoaderMgr.Instance.Clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user