This commit is contained in:
PC-20230316NUNE\Administrator
2024-03-20 14:22:36 +08:00
parent 8f2fb1010c
commit 98bead1a7c
52 changed files with 4112 additions and 4446 deletions

View File

@@ -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));
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9fe2022df60c658429cbf569a7f748d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec3e2e6eab7953640bd070cd7240d964
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: