This commit is contained in:
PC-20230316NUNE\Administrator
2024-10-16 20:41:40 +08:00
parent 44c3ea001a
commit 6da2f9e691
1866 changed files with 36068 additions and 25732 deletions

View File

@@ -0,0 +1,76 @@
using System.Collections.Generic;
using DotRecast.Core.Collections;
using JNGame.Math;
using JNGame.Sync.State.Tile;
using UnityEngine;
namespace JNGame.Sync.Debuger
{
public class JNTileServerDebuger : SingletonScene<JNTileServerDebuger>
{
private List<JNSSTileServerService> _services = new List<JNSSTileServerService>();
public void Add(JNSSTileServerService service)
{
_services.Add(service);
}
public void Remove(JNSSTileServerService service)
{
_services.Remove(service);
}
private void OnDrawGizmos()
{
_services.ForEach(DebugService);
}
private void DebugService(JNSSTileServerService service)
{
if (!(service.IsStart)) return;
//绘制权限区块
DrawContains(service.MaxContains,service.MinContains,Color.red);
//绘制连接区域
service.GetLinkTiles().ForEach(index =>
{
(LVector2 max, LVector2 min) = service.GetTileContains(index);
DrawContains(max,min,Color.cyan);
});
}
/// <summary>
/// 绘制区域
/// </summary>
/// <param name="MaxContains"></param>
/// <param name="MinContains"></param>
private void DrawContains(LVector2 MaxContains,LVector2 MinContains,Color color)
{
// 绘制正方形
// 计算正方形的四个角点
Vector3 topLeft = new Vector3(MaxContains.x,0, MaxContains.y);
Vector3 topRight = new Vector3(MinContains.x,0, MaxContains.y);
Vector3 bottomLeft = new Vector3(MaxContains.x,0, MinContains.y);
Vector3 bottomRight = new Vector3(MinContains.x,0, MinContains.y);
// 使用Gizmos.DrawLine来绘制正方形的四条边
Gizmos.color = color; // 设置Gizmos的颜色
// 顶部边
Gizmos.DrawLine(topLeft, topRight);
// 底部边
Gizmos.DrawLine(bottomLeft, bottomRight);
// 左侧边
Gizmos.DrawLine(topLeft, bottomLeft);
// 右侧边
Gizmos.DrawLine(topRight, bottomRight);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3af567e286384e418dc55e261f8e31c8
timeCreated: 1723694204