style : Code text indent format
This commit is contained in:
+42
-42
@@ -6,52 +6,52 @@ using YooAsset;
|
||||
|
||||
public class GameManager
|
||||
{
|
||||
private static GameManager _instance;
|
||||
public static GameManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new GameManager();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
private static GameManager _instance;
|
||||
public static GameManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new GameManager();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly EventGroup _eventGroup = new EventGroup();
|
||||
private readonly EventGroup _eventGroup = new EventGroup();
|
||||
|
||||
/// <summary>
|
||||
/// 协程启动器
|
||||
/// </summary>
|
||||
public MonoBehaviour Behaviour;
|
||||
/// <summary>
|
||||
/// 协程启动器
|
||||
/// </summary>
|
||||
public MonoBehaviour Behaviour;
|
||||
|
||||
|
||||
private GameManager()
|
||||
{
|
||||
// 注册监听事件
|
||||
_eventGroup.AddListener<SceneEventDefine.ChangeToHomeScene>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<SceneEventDefine.ChangeToBattleScene>(OnHandleEventMessage);
|
||||
}
|
||||
private GameManager()
|
||||
{
|
||||
// 注册监听事件
|
||||
_eventGroup.AddListener<SceneEventDefine.ChangeToHomeScene>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<SceneEventDefine.ChangeToBattleScene>(OnHandleEventMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启一个协程
|
||||
/// </summary>
|
||||
public void StartCoroutine(IEnumerator enumerator)
|
||||
{
|
||||
Behaviour.StartCoroutine(enumerator);
|
||||
}
|
||||
/// <summary>
|
||||
/// 开启一个协程
|
||||
/// </summary>
|
||||
public void StartCoroutine(IEnumerator enumerator)
|
||||
{
|
||||
Behaviour.StartCoroutine(enumerator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收事件
|
||||
/// </summary>
|
||||
private void OnHandleEventMessage(IEventMessage message)
|
||||
{
|
||||
if (message is SceneEventDefine.ChangeToHomeScene)
|
||||
{
|
||||
YooAssets.LoadSceneAsync("scene_home");
|
||||
}
|
||||
else if (message is SceneEventDefine.ChangeToBattleScene)
|
||||
{
|
||||
YooAssets.LoadSceneAsync("scene_battle");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收事件
|
||||
/// </summary>
|
||||
private void OnHandleEventMessage(IEventMessage message)
|
||||
{
|
||||
if (message is SceneEventDefine.ChangeToHomeScene)
|
||||
{
|
||||
YooAssets.LoadSceneAsync("scene_home");
|
||||
}
|
||||
else if (message is SceneEventDefine.ChangeToBattleScene)
|
||||
{
|
||||
YooAssets.LoadSceneAsync("scene_battle");
|
||||
}
|
||||
}
|
||||
}
|
||||
+51
-51
@@ -8,63 +8,63 @@ using YooAsset;
|
||||
|
||||
internal class SceneBattle : MonoBehaviour
|
||||
{
|
||||
public GameObject CanvasDesktop;
|
||||
public GameObject CanvasDesktop;
|
||||
|
||||
private AssetHandle _windowHandle;
|
||||
private AssetHandle _musicHandle;
|
||||
private BattleRoom _battleRoom;
|
||||
private AssetHandle _windowHandle;
|
||||
private AssetHandle _musicHandle;
|
||||
private BattleRoom _battleRoom;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// 加载战斗页面
|
||||
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIBattle");
|
||||
yield return _windowHandle;
|
||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// 加载战斗页面
|
||||
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIBattle");
|
||||
yield return _windowHandle;
|
||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||
|
||||
// 加载背景音乐
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
_musicHandle = package.LoadAssetAsync<AudioClip>("music_background");
|
||||
yield return _musicHandle;
|
||||
// 加载背景音乐
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
_musicHandle = package.LoadAssetAsync<AudioClip>("music_background");
|
||||
yield return _musicHandle;
|
||||
|
||||
// 播放背景音乐
|
||||
var audioSource = this.gameObject.AddComponent<AudioSource>();
|
||||
audioSource.loop = true;
|
||||
audioSource.clip = _musicHandle.AssetObject as AudioClip;
|
||||
audioSource.Play();
|
||||
// 播放背景音乐
|
||||
var audioSource = this.gameObject.AddComponent<AudioSource>();
|
||||
audioSource.loop = true;
|
||||
audioSource.clip = _musicHandle.AssetObject as AudioClip;
|
||||
audioSource.Play();
|
||||
|
||||
_battleRoom = new BattleRoom();
|
||||
_battleRoom.IntRoom();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_windowHandle != null)
|
||||
{
|
||||
_windowHandle.Release();
|
||||
_windowHandle = null;
|
||||
}
|
||||
_battleRoom = new BattleRoom();
|
||||
_battleRoom.IntRoom();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_windowHandle != null)
|
||||
{
|
||||
_windowHandle.Release();
|
||||
_windowHandle = null;
|
||||
}
|
||||
|
||||
if (_musicHandle != null)
|
||||
{
|
||||
_musicHandle.Release();
|
||||
_musicHandle = null;
|
||||
}
|
||||
if (_musicHandle != null)
|
||||
{
|
||||
_musicHandle.Release();
|
||||
_musicHandle = null;
|
||||
}
|
||||
|
||||
if (_battleRoom != null)
|
||||
{
|
||||
_battleRoom.DestroyRoom();
|
||||
_battleRoom = null;
|
||||
}
|
||||
if (_battleRoom != null)
|
||||
{
|
||||
_battleRoom.DestroyRoom();
|
||||
_battleRoom = null;
|
||||
}
|
||||
|
||||
// 切换场景的时候释放资源
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (_battleRoom != null)
|
||||
_battleRoom.UpdateRoom();
|
||||
}
|
||||
// 切换场景的时候释放资源
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (_battleRoom != null)
|
||||
_battleRoom.UpdateRoom();
|
||||
}
|
||||
}
|
||||
@@ -5,30 +5,30 @@ using YooAsset;
|
||||
|
||||
public class SceneHome : MonoBehaviour
|
||||
{
|
||||
public GameObject CanvasDesktop;
|
||||
public GameObject CanvasDesktop;
|
||||
|
||||
private AssetHandle _windowHandle;
|
||||
private AssetHandle _windowHandle;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// 加载登录页面
|
||||
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIHome");
|
||||
yield return _windowHandle;
|
||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_windowHandle != null)
|
||||
{
|
||||
_windowHandle.Release();
|
||||
_windowHandle = null;
|
||||
}
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// 加载登录页面
|
||||
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIHome");
|
||||
yield return _windowHandle;
|
||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_windowHandle != null)
|
||||
{
|
||||
_windowHandle.Release();
|
||||
_windowHandle = null;
|
||||
}
|
||||
|
||||
// 切换场景的时候释放资源
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
// 切换场景的时候释放资源
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user