提交新概念 Tile从服务器

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-31 15:35:12 +08:00
parent 77db4d7d71
commit d67032e1de
1039 changed files with 57738 additions and 412 deletions

View File

@@ -0,0 +1,23 @@
using AppGame;
using JNGame.Map;
using JNGame.Map.DotRecast.Util;
namespace Game.Logic.System.Usual
{
/// <summary>
/// 游戏数据
/// </summary>
public class DDataSystem : DGBasisSystem
{
public StaticMapData MapData;
public MeshData MapData2;
public override void OnSyncStart()
{
base.OnSyncStart();
MapData = App.Resource.MapData;
MapData2 = App.Resource.MapData2;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5c9d6660f75144ce84276d8536a9ffc2
timeCreated: 1715158899

View File

@@ -0,0 +1,105 @@
using System.Collections.Generic;
using DotRecast.Core.Numerics;
using DotRecast.Detour;
using DotRecast.Detour.Crowd;
using JNGame.Map.DotRecast;
using JNGame.Math;
using UnityEngine;
namespace Game.Logic.System.Usual
{
/// <summary>
/// 地图
/// </summary>
public class DMapSystem : DGBasisSystem
{
public DotRecastRoot Root;
public override void OnSyncStart()
{
base.OnSyncStart();
Root = new DotRecastRoot(GetSystem<DDataSystem>().MapData2);
Debug.Log($"DemoMapService - 加载完成地图");
}
public override void OnSyncUpdate()
{
base.OnSyncUpdate();
Root.Update(new LFloat(null,Sync.DeltaTime));
}
public DtCrowdAgentParams GetAgentParams()
{
int updateFlags = DtCrowdAgentUpdateFlags.DT_CROWD_ANTICIPATE_TURNS |
DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_VIS |
DtCrowdAgentUpdateFlags.DT_CROWD_OPTIMIZE_TOPO |
DtCrowdAgentUpdateFlags.DT_CROWD_OBSTACLE_AVOIDANCE;
DtCrowdAgentParams ap = new DtCrowdAgentParams();
ap.radius = (LFloat)0.6f;
ap.height = (LFloat)2f;
ap.maxAcceleration = (LFloat)8.0f;
ap.maxSpeed = (LFloat)6f;
ap.collisionQueryRange = ap.radius * (LFloat)12f;
ap.pathOptimizationRange = ap.radius * (LFloat)30f;
ap.updateFlags = updateFlags;
ap.obstacleAvoidanceType = 0;
ap.separationWeight = (LFloat)2f;
return ap;
}
/// <summary>
/// 返回最近点
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public LVector3 GetNearbyPoints(LVector3 pos)
{
return Root.GetNearbyPoints(pos);
}
/// <summary>
/// 查询导航
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public List<DtStraightPath> FindPath(LVector3 start,LVector3 end)
{
return Root.FindPath(start,end);
}
//添加避障
public void AddAgent(ulong id,LVector3 start)
{
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z));
}
public void AddAgent(ulong id,LVector3 start,DtCrowdAgentParams agentParams)
{
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z),agentParams);
}
//删除避障
public void DelAgent(ulong id)
{
Root.DelAgent(id);
}
//移动避障
public void MoveAgent(ulong id,LVector3 move)
{
Root.MoveAgent(id,new RcVec3f(move.x,move.y,move.z));
}
//向量移动避障
public void VectorMoveAgent(ulong id,LVector2 vector)
{
Root.VectorMoveAgent(id,new RcVec3f(vector.x,0,vector.y));
}
//获取避障
public DtCrowdAgent GetAgent(ulong id)
{
return Root.GetAgent(id);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f6e62838e334b6e983b238063cc2479
timeCreated: 1715157690