62 lines
1.5 KiB
C#
Raw Permalink Normal View History

2024-01-26 19:15:07 +08:00
using System;
2024-02-20 18:39:12 +08:00
using Cysharp.Threading.Tasks;
2024-02-01 19:06:51 +08:00
using Game.Plugins.App;
2024-01-29 02:28:42 +08:00
using Google.Protobuf;
2024-01-26 19:15:07 +08:00
using Plugins.JNGame;
using Plugins.JNGame.Network.Action;
using Script.battle;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
//游戏主入口
namespace Script
{
public class Main : MonoBehaviour
{
2024-01-30 19:22:27 +08:00
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
2024-01-26 19:15:07 +08:00
async void Start()
{
2024-02-20 18:39:12 +08:00
Application.targetFrameRate = 120;
2024-01-26 19:15:07 +08:00
//创建UI
SceneManager.LoadScene("UIScene", LoadSceneMode.Additive);
//加载框架
await JNGame.Init(App.System());
//初始化模式类
await GBattleModeManager.Instance.Open(GBattleMode.Default);
2024-01-29 02:28:42 +08:00
App.Socket.AddListener(3,OnNActionDemo);
2024-01-26 19:15:07 +08:00
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);
}
2024-01-29 02:28:42 +08:00
public void OnNActionDemo()
2024-01-26 19:15:07 +08:00
{
2024-01-29 02:28:42 +08:00
Debug.Log("OnNActionDemo");
2024-01-26 19:15:07 +08:00
}
public void OnNSyncFrameBack(JNFrameInfo info)
{
2024-01-29 02:28:42 +08:00
App.Sync.AddInput(info);
2024-01-26 19:15:07 +08:00
}
2024-03-20 14:22:36 +08:00
2024-01-26 19:15:07 +08:00
}
}