mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -7,9 +7,10 @@ namespace Script
|
||||
public static class App
|
||||
{
|
||||
|
||||
public static JNGSocket Socket = new JNGSocket();
|
||||
public static JNGSyncFrame Sync = new JNGSyncFrame();
|
||||
public static JAPI Api = new(new JAPIConfig(){BaseURL = "http://localhost:8080"});
|
||||
public static readonly JNGSocket Socket = new JNGSocket();
|
||||
public static readonly JNGSyncFrame Sync = new JNGSyncFrame();
|
||||
public static readonly JAPI Api = new(new JAPIConfig(){BaseURL = "http://localhost:8080"});
|
||||
public static readonly EventDispatcher Event = EventDispatcher.Event;
|
||||
|
||||
public static SystemBase[] System()
|
||||
{
|
||||
|
3
JNFrame/Assets/Script/AppImpl/Sync.meta
Normal file
3
JNFrame/Assets/Script/AppImpl/Sync.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f844bda03d4d0c8dae20659066ca67
|
||||
timeCreated: 1706519193
|
16
JNFrame/Assets/Script/AppImpl/Sync/JNGSyncFrame.cs
Normal file
16
JNFrame/Assets/Script/AppImpl/Sync/JNGSyncFrame.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Plugins.JNGame.Sync.Frame;
|
||||
using Plugins.JNGame.Sync.Frame.game;
|
||||
|
||||
namespace Script.AppImpl.Sync
|
||||
{
|
||||
public abstract class JNGSyncFrame<T> : JNSyncFrameComponent<T>
|
||||
{
|
||||
protected override JNSyncFrame GetSync()
|
||||
{
|
||||
return App.Sync;
|
||||
}
|
||||
|
||||
public override void OnSyncLoad(){}
|
||||
|
||||
}
|
||||
}
|
3
JNFrame/Assets/Script/AppImpl/Sync/JNGSyncFrame.cs.meta
Normal file
3
JNFrame/Assets/Script/AppImpl/Sync/JNGSyncFrame.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54720b15a706406c974db4ac581e6dbc
|
||||
timeCreated: 1706519239
|
@@ -52,9 +52,7 @@ namespace Script
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
App.Sync.Update((int)(Time.deltaTime * 1000));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,17 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Script.battle;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
public class UIMain : MonoBehaviour
|
||||
{
|
||||
|
||||
//重置
|
||||
public void OnClickReset()
|
||||
{
|
||||
GBattleModeManager.Instance.Open(GBattleMode.Default).Forget();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
namespace Script.battle
|
||||
using Script.AppImpl.Sync;
|
||||
|
||||
namespace Script.battle
|
||||
{
|
||||
public class GBaseMode
|
||||
public abstract class GBaseMode<T> : JNGSyncFrame<T>
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Plugins.JNGame.Sync.Frame;
|
||||
using Plugins.JNGame.Util;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -22,8 +24,8 @@ namespace Script.battle
|
||||
//全局战斗模式管理器
|
||||
public class GBattleModeManager : SingletonScene<GBattleModeManager>
|
||||
{
|
||||
|
||||
public static string[] Worlds = { "WorldScene" };
|
||||
|
||||
private static readonly string[] Worlds = { "WorldSceneMode" };
|
||||
|
||||
//当前模式
|
||||
private GBattleMode _current = GBattleMode.Not;
|
||||
@@ -32,6 +34,9 @@ namespace Script.battle
|
||||
public void Init(GBattleModeInfo info)
|
||||
{
|
||||
|
||||
// App.Event.AddListener(JNSyncFrameEvent.CREATE,LoadScene);
|
||||
// App.Event.AddListener(JNSyncFrameEvent.CLEAR,UnloadScene);
|
||||
|
||||
}
|
||||
|
||||
//打开指定模式
|
||||
@@ -39,22 +44,20 @@ namespace Script.battle
|
||||
{
|
||||
|
||||
//销毁之前模式
|
||||
await Close();
|
||||
_current = mode;
|
||||
await LoadScene(mode);
|
||||
await OnReset();
|
||||
//开始同步
|
||||
App.Sync.onStart();
|
||||
App.Sync.OnStart();
|
||||
|
||||
}
|
||||
|
||||
//关闭当前模式
|
||||
public async UniTask Close()
|
||||
//重置当前模式
|
||||
public async UniTask OnReset()
|
||||
{
|
||||
|
||||
await UnloadScene(_current);
|
||||
App.Sync.onStop();
|
||||
await this.UnloadScene();
|
||||
App.Sync.OnReset();
|
||||
await this.LoadScene();
|
||||
_current = GBattleMode.Not;
|
||||
|
||||
}
|
||||
|
||||
//获取场景名称
|
||||
@@ -64,20 +67,30 @@ namespace Script.battle
|
||||
}
|
||||
|
||||
//加载场景
|
||||
private async UniTask LoadScene(GBattleMode mode)
|
||||
private async UniTask LoadScene()
|
||||
{
|
||||
GBattleMode mode = this._current;
|
||||
if (mode == GBattleMode.Not) return;
|
||||
Debug.Log($"[GBattleModeManager] 打开场景{GetWorldName(mode)}");
|
||||
await SceneManager.LoadSceneAsync(GetWorldName(mode), LoadSceneMode.Additive);
|
||||
}
|
||||
|
||||
//销毁场景
|
||||
private async UniTask UnloadScene(GBattleMode mode)
|
||||
//销毁所有场景
|
||||
private async UniTask UnloadScene()
|
||||
{
|
||||
|
||||
if (mode == GBattleMode.Not) return;
|
||||
Debug.Log($"[GBattleModeManager] 关闭场景{GetWorldName(mode)}");
|
||||
await SceneManager.UnloadSceneAsync(GetWorldName(mode));
|
||||
|
||||
Debug.Log($"[GBattleModeManager] 关闭场景");
|
||||
foreach (var world in Worlds)
|
||||
{
|
||||
try
|
||||
{
|
||||
await SceneManager.UnloadSceneAsync(world);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
3
JNFrame/Assets/Script/battle/mode.meta
Normal file
3
JNFrame/Assets/Script/battle/mode.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b22dd710734444690a739bc582997fa
|
||||
timeCreated: 1706519323
|
32
JNFrame/Assets/Script/battle/mode/GWorldSceneMode.cs
Normal file
32
JNFrame/Assets/Script/battle/mode/GWorldSceneMode.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.battle.mode
|
||||
{
|
||||
public class GWorldSceneModeInput
|
||||
{
|
||||
|
||||
}
|
||||
public class GWorldSceneMode:GBaseMode<GWorldSceneModeInput>
|
||||
{
|
||||
|
||||
public GameObject ball;
|
||||
|
||||
// public override void OnSyncLoad()
|
||||
// {
|
||||
// base.OnSyncLoad();
|
||||
// Instantiate(ball,this.transform);
|
||||
// }
|
||||
|
||||
public override void OnSyncUpdate(int dt, JNFrameInfo frame, GWorldSceneModeInput input)
|
||||
{
|
||||
if (frame.Index > 0)
|
||||
{
|
||||
var ballNode = Instantiate(ball,this.transform);
|
||||
var transformPosition = ballNode.transform.position;
|
||||
ballNode.transform.position = new Vector3(transformPosition.x,transformPosition.y,GetSync().nRandomInt(-3,3));
|
||||
}
|
||||
Debug.Log("OnSyncUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e57d6502487241f9826136613eff59a2
|
||||
timeCreated: 1706519435
|
Reference in New Issue
Block a user