This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-01-29 02:28:42 +08:00
parent 68c4d5e811
commit 01a4312761
73 changed files with 13939 additions and 42231 deletions

View File

@@ -1,4 +1,5 @@
using Plugins.JNGame.System;
using Plugins.JNGame.Util;
using Script.AppImpl;
namespace Script
@@ -8,6 +9,7 @@ namespace Script
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 SystemBase[] System()
{

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Plugins.JNGame.Network;

View File

@@ -1,4 +1,6 @@
using Plugins.JNGame.Sync.Frame;
using Cysharp.Threading.Tasks;
using Plugins.JNGame.Sync.Frame;
using UnityEngine;
namespace Script.AppImpl
{
@@ -8,5 +10,18 @@ namespace Script.AppImpl
{
throw new System.NotImplementedException();
}
protected override async UniTask<JNFrameInfos> OnServerData(int start, int end)
{
var data = (await App.Api.GetByte($"/sync/frame?start={start}"));
if (data is { Length: > 0 })
{
return JNFrameInfos.Parser.ParseFrom(data);
}
else
{
return new JNFrameInfos();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using Google.Protobuf;
using Plugins.JNGame;
using Plugins.JNGame.Network.Action;
using Script.battle;
@@ -24,7 +25,7 @@ namespace Script
//初始化模式类
await GBattleModeManager.Instance.Open(GBattleMode.Default);
App.Socket.AddListener<NActionDemo>(3,OnNActionDemo);
App.Socket.AddListener(3,OnNActionDemo);
App.Socket.AddListener<JNFrameInfo>((int)NActionEnum.NSyncFrameBack,OnNSyncFrameBack);
//加载成功向服务器发送帧同步消息
@@ -38,14 +39,15 @@ namespace Script
}
public void OnNActionDemo(NActionDemo demo)
public void OnNActionDemo()
{
Debug.Log(demo.Message);
Debug.Log("OnNActionDemo");
}
public void OnNSyncFrameBack(JNFrameInfo info)
{
Debug.Log(info.Index);
App.Sync.AddInput(info);
}
private void Update()

View File

@@ -42,6 +42,8 @@ namespace Script.battle
await Close();
_current = mode;
await LoadScene(mode);
//开始同步
App.Sync.onStart();
}
@@ -50,6 +52,7 @@ namespace Script.battle
{
await UnloadScene(_current);
App.Sync.onStop();
_current = GBattleMode.Not;
}