mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Game.Plugins.App;
|
||||
using Plugins.JNGame.Sync.Frame;
|
||||
using Plugins.JNGame.Util;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Script.battle
|
||||
{
|
||||
@@ -26,14 +28,17 @@ namespace Script.battle
|
||||
public class GBattleModeManager : SingletonScene<GBattleModeManager>
|
||||
{
|
||||
|
||||
private static readonly string[] Worlds = { "NavDemo1", };
|
||||
private static readonly string[] Worlds = { "WorldSceneMode", };
|
||||
|
||||
//当前模式
|
||||
private GBattleMode _current = GBattleMode.Not;
|
||||
private GBattleMode _current = GBattleMode.Default;
|
||||
|
||||
//当前模式实体
|
||||
public Object root;
|
||||
|
||||
//是否本地模式
|
||||
public Boolean isLocalMode = false;
|
||||
|
||||
//获取当前模式
|
||||
public T GetMode<T>() where T : class
|
||||
{
|
||||
@@ -48,26 +53,25 @@ namespace Script.battle
|
||||
}
|
||||
|
||||
//打开指定模式
|
||||
public async UniTask Open(GBattleMode mode)
|
||||
public async UniTask Open(GBattleMode mode, Boolean isLocalMode = false)
|
||||
{
|
||||
|
||||
//销毁之前模式
|
||||
_current = mode;
|
||||
await OnReset();
|
||||
await OnReset(mode);
|
||||
//是否单机模式
|
||||
this.isLocalMode = isLocalMode;
|
||||
//开始同步
|
||||
App.Sync.OnStart();
|
||||
|
||||
}
|
||||
|
||||
//重置当前模式
|
||||
public async UniTask OnReset()
|
||||
public async UniTask OnReset(GBattleMode mode)
|
||||
{
|
||||
await this.UnloadScene();
|
||||
await UniTask.NextFrame();
|
||||
await this.UnloadScene(mode);
|
||||
App.Sync.OnReset();
|
||||
await UniTask.NextFrame();
|
||||
_current = mode;
|
||||
await this.LoadScene();
|
||||
_current = GBattleMode.Not;
|
||||
}
|
||||
|
||||
//获取场景名称
|
||||
@@ -83,29 +87,24 @@ namespace Script.battle
|
||||
if (mode == GBattleMode.Not) return;
|
||||
Debug.Log($"[GBattleModeManager] 打开场景{GetWorldName(mode)}");
|
||||
await SceneManager.LoadSceneAsync(GetWorldName(mode));
|
||||
await UniTask.NextFrame();
|
||||
}
|
||||
|
||||
//销毁所有场景
|
||||
private async UniTask UnloadScene()
|
||||
private async UniTask UnloadScene(GBattleMode mode)
|
||||
{
|
||||
|
||||
Debug.Log($"[GBattleModeManager] 关闭场景");
|
||||
await SceneManager.UnloadSceneAsync(GetWorldName(mode));
|
||||
await UniTask.NextFrame();
|
||||
//
|
||||
// for (int i = SceneManager.sceneCount - 1; i >= 0; i--)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(i));
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
//刷新模式
|
||||
private void Update()
|
||||
{
|
||||
App.Sync.Update((int)(Time.deltaTime * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
8
JNFrame/Assets/Game/Script/battle/mode/Demo.meta
Normal file
8
JNFrame/Assets/Game/Script/battle/mode/Demo.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fe2022df60c658429cbf569a7f748d0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
JNFrame/Assets/Game/Script/battle/mode/Demo/GameDemo1Mode.cs
Normal file
18
JNFrame/Assets/Game/Script/battle/mode/Demo/GameDemo1Mode.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameDemo1Mode : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec3e2e6eab7953640bd070cd7240d964
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user