mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
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()
|
|
{
|
|
|
|
Application.targetFrameRate = 120;
|
|
|
|
//创建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)
|
|
{
|
|
App.Sync.AddInput(info);
|
|
}
|
|
|
|
}
|
|
}
|