86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
using GamePlay.Building.Fight.Impl.Builds;
|
|
using Gameplay.Common;
|
|
using Gameplay.Character;
|
|
using Gameplay.Unit;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace FightDebug
|
|
{
|
|
public class SingleUnitRadarDebugPanel
|
|
{
|
|
public void Reset()
|
|
{
|
|
}
|
|
|
|
public void Draw(GameUnit unit)
|
|
{
|
|
var radar = unit as UnitBuildRadar;
|
|
if (radar == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_DrawRadar(radar);
|
|
}
|
|
|
|
private void _DrawRadar(UnitBuildRadar radar)
|
|
{
|
|
GUILayout.BeginVertical("box");
|
|
GUILayout.Label("雷达调试", EditorStyles.boldLabel);
|
|
|
|
_ShowLabel("建筑阵营:", _GetTroopName(radar.commonData.troopId));
|
|
_ShowLabel("建筑ID:", radar.GetID() + "", true);
|
|
_ShowLabel("LocalId:", radar.unitLevelData != null ? radar.unitLevelData.LocalId + "" : "无", true);
|
|
_ShowLabel("当前格子:", radar.transData.cellIndex + "", true);
|
|
_ShowLabel("世界坐标:", _FormatVector3(radar.transData.pos));
|
|
_ShowLabel("当前逻辑角度:", radar.nowAngle.ToString("F2") + "°");
|
|
_ShowLabel("当前表现角度:", radar.DebugViewAngle.ToString("F2") + "°");
|
|
_ShowLabel("当前范围:", radar.scanDistance.ToString("F2"));
|
|
_ShowLabel("扫描格数:", radar.scanCellCount + "格");
|
|
_ShowLabel("单格直径:", (CodeDefine.Fight.Cell.CELL_MIN_RADIUS * 2F).ToString("F2"));
|
|
_ShowLabel("中心半径修正:", "-" + CodeDefine.Fight.Cell.CELL_MIN_RADIUS.ToString("F2"));
|
|
_ShowLabel("扫描扇形角:", radar.scanAngle.ToString("F2") + "°");
|
|
_ShowLabel("扫描速度:", radar.scanSpeed.ToString("F2") + "°/s");
|
|
|
|
GUILayout.EndVertical();
|
|
}
|
|
|
|
private void _ShowLabel(string label, string value, bool showCopy = false)
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Label(label, GUILayout.Width(140));
|
|
GUILayout.Label(value);
|
|
if (showCopy)
|
|
{
|
|
if (GUILayout.Button("复制", GUILayout.Width(60)))
|
|
{
|
|
EditorGUIUtility.systemCopyBuffer = value;
|
|
}
|
|
}
|
|
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
private string _FormatVector3(Vector3 pos)
|
|
{
|
|
return $"({pos.x:F2}, {pos.y:F2}, {pos.z:F2})";
|
|
}
|
|
|
|
private string _GetTroopName(int troopId)
|
|
{
|
|
switch (troopId)
|
|
{
|
|
case ETroopsId.Self:
|
|
return "己方";
|
|
case ETroopsId.Enemy:
|
|
return "敌方";
|
|
case ETroopsId.Neutral:
|
|
return "中立";
|
|
default:
|
|
return "未知(" + troopId + ")";
|
|
}
|
|
}
|
|
}
|
|
}
|