mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交Unity 联机Pro
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.State
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态同步 [客户端]
|
||||
/// 客户端负责视图层拿数据层数据渲染
|
||||
/// 注:客户端无论如何不能有逻辑层
|
||||
/// </summary>
|
||||
public class JNSStateClientService : JNSyncDefaultService
|
||||
{
|
||||
//是否开始
|
||||
private bool _isStart = false;
|
||||
public bool IsStart => _isStart;
|
||||
public override bool IsStartGame => IsStart;
|
||||
public override int DeltaTime => 1000 / 15;
|
||||
|
||||
//累计待处理时间
|
||||
protected int dtTime;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_isStart = true;
|
||||
}
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
|
||||
if (paused) return;
|
||||
#endif
|
||||
if (!IsStart) return;
|
||||
base.Execute();
|
||||
dtTime += (int)(Time.deltaTime * 1000);
|
||||
if (DeltaTime <= dtTime)
|
||||
{
|
||||
dtTime -= DeltaTime;
|
||||
//执行逻辑
|
||||
OnRunSimulate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 客户端没有逻辑实体
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public sealed override JNContexts CreateContexts()
|
||||
{
|
||||
return base.CreateContexts();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行逻辑
|
||||
/// </summary>
|
||||
protected virtual void OnRunSimulate()
|
||||
{
|
||||
Simulate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43ab652bc3574b6e99d3db5a4828f56e
|
||||
timeCreated: 1721810431
|
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using JNGame.Sync.Frame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.State
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态同步 [服务器]
|
||||
/// 服务器负责逻辑层执行并且推送信息到数据层
|
||||
/// 注:服务器可以有视图层 一般用于debug 发布后没必要有视图层
|
||||
/// </summary>
|
||||
public class JNSStateServerService : JNSyncDefaultService
|
||||
{
|
||||
|
||||
//累计待处理时间
|
||||
protected int dtTime;
|
||||
|
||||
//服务器每帧时间
|
||||
public override int DeltaTime => 1000 / 15;
|
||||
|
||||
//是否开始
|
||||
private bool _isStart = false;
|
||||
public bool IsStart => _isStart;
|
||||
|
||||
public override bool IsStartGame => _isStart;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_isStart = true;
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
|
||||
if (paused) return;
|
||||
#endif
|
||||
if (!IsStart) return;
|
||||
base.Execute();
|
||||
dtTime += (int)(Time.deltaTime * 1000);
|
||||
if (DeltaTime <= dtTime)
|
||||
{
|
||||
dtTime -= DeltaTime;
|
||||
//执行逻辑
|
||||
OnRunSimulate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行逻辑
|
||||
/// </summary>
|
||||
protected virtual void OnRunSimulate()
|
||||
{
|
||||
Simulate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f339d578d3d4c4d9b060962aa7acd60
|
||||
timeCreated: 1721810407
|
Reference in New Issue
Block a user