This commit is contained in:
PC-20230316NUNE\Administrator
2024-02-01 19:06:51 +08:00
parent aa4d6c3ce2
commit 877dca3b43
7518 changed files with 653768 additions and 162059 deletions

View File

@@ -0,0 +1,9 @@
using Game.Plugins.App.Sync;
namespace Script.battle
{
public abstract class GBaseMode<T> : JNGSyncFrame<T>
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 66eaac44e0ad4bf3b54c2806f86280c7
timeCreated: 1706252585

View File

@@ -0,0 +1,103 @@
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;
namespace Script.battle
{
//各种模式场景
public enum GBattleMode
{
Not = -1,
Default = 0
}
//初始化参数类
public class GBattleModeInfo
{
public List<GameObject> modes;
public GameObject root;
}
//全局战斗模式管理器
public class GBattleModeManager : SingletonScene<GBattleModeManager>
{
private static readonly string[] Worlds = { "WorldSync01", };
//当前模式
private GBattleMode _current = GBattleMode.Not;
//初始化管理器
public void Init(GBattleModeInfo info)
{
// App.Event.AddListener(JNSyncFrameEvent.CREATE,LoadScene);
// App.Event.AddListener(JNSyncFrameEvent.CLEAR,UnloadScene);
}
//打开指定模式
public async UniTask Open(GBattleMode mode)
{
//销毁之前模式
_current = mode;
await OnReset();
//开始同步
App.Sync.OnStart();
}
//重置当前模式
public async UniTask OnReset()
{
await this.UnloadScene();
await UniTask.NextFrame();
App.Sync.OnReset();
await this.LoadScene();
_current = GBattleMode.Not;
}
//获取场景名称
public string GetWorldName(GBattleMode mode)
{
return Worlds[(int)mode];
}
//加载场景
private async UniTask LoadScene()
{
GBattleMode mode = this._current;
if (mode == GBattleMode.Not) return;
Debug.Log($"[GBattleModeManager] 打开场景{GetWorldName(mode)}");
await SceneManager.LoadSceneAsync(GetWorldName(mode));
}
//销毁所有场景
private async UniTask UnloadScene()
{
Debug.Log($"[GBattleModeManager] 关闭场景");
await UniTask.NextFrame();
//
// for (int i = SceneManager.sceneCount - 1; i >= 0; i--)
// {
// try
// {
// await SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(i));
// }
// catch
// {
// // ignored
// }
// }
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 36bc28f3467d4641abb08e83398a8a30
timeCreated: 1706167381

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6b22dd710734444690a739bc582997fa
timeCreated: 1706519323

View File

@@ -0,0 +1,39 @@
using Plugins.JNGame.BepuPhysics;
using UnityEngine;
namespace Script.battle.mode
{
public class GWorldSceneModeInput
{
}
public class GWorldSceneMode:GBaseMode<GWorldSceneModeInput>
{
public GameObject[] balls = null;
private JNBepuPhysics Physics;
public override void OnSyncLoad()
{
Physics = new();
// BufferPool pool = new BufferPool();
// Simulation.Create(pool, new DemoNarrowPhaseCallbacks(), new DemoPoseIntegratorCallbacks(new System.Numerics.Vector3(0, -10, 0)), new PositionFirstTimestepper());
}
public override void OnSyncUpdate(int dt, JNFrameInfo frame, GWorldSceneModeInput input)
{
Physics.OnUpdate((float) dt / 1000);
if (frame.Index > 0)
{
var index = GetSync().nRandomInt(0, balls.Length - 1);
Debug.Log(index);
var ballNode = Instantiate(balls[index],this.transform);
var transformPosition = ballNode.transform.position;
ballNode.transform.position = new Vector3(GetSync().nRandomFloat(-6,6),transformPosition.y,GetSync().nRandomFloat(-6,6));
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e57d6502487241f9826136613eff59a2
timeCreated: 1706519435