mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System;
|
|
using Game.Plugins.App;
|
|
using Google.Protobuf;
|
|
using Plugins.JNGame;
|
|
using Plugins.JNGame.Network.Action;
|
|
using Script.battle;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
//游戏主入口
|
|
namespace Script
|
|
{
|
|
public class Main : MonoBehaviour
|
|
{
|
|
private void Awake()
|
|
{
|
|
DontDestroyOnLoad(this.gameObject);
|
|
}
|
|
|
|
async void Start()
|
|
{
|
|
|
|
//创建UI
|
|
SceneManager.LoadScene("UIScene", LoadSceneMode.Additive);
|
|
|
|
//加载框架
|
|
await JNGame.Init(App.System());
|
|
|
|
//初始化模式类
|
|
await GBattleModeManager.Instance.Open(GBattleMode.Default);
|
|
|
|
App.Socket.AddListener(3,OnNActionDemo);
|
|
App.Socket.AddListener<JNFrameInfo>((int)NActionEnum.NSyncFrameBack,OnNSyncFrameBack);
|
|
|
|
//加载成功向服务器发送帧同步消息
|
|
NActionDemo message = new NActionDemo();
|
|
message.Message = "HelloWorld Unity NGame";
|
|
App.Socket.Send(2,message);
|
|
|
|
//开启帧同步
|
|
App.Socket.Send((int)NActionEnum.NSyncFrameStart);
|
|
|
|
|
|
}
|
|
|
|
public void OnNActionDemo()
|
|
{
|
|
Debug.Log("OnNActionDemo");
|
|
}
|
|
|
|
public void OnNSyncFrameBack(JNFrameInfo info)
|
|
{
|
|
Debug.Log(info.Index);
|
|
App.Sync.AddInput(info);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
App.Sync.Update((int)(Time.deltaTime * 1000));
|
|
}
|
|
}
|
|
}
|