【F11窗口】增加探照灯调试功能
parent
700345a348
commit
50cbe58bea
|
|
@ -4,7 +4,9 @@ using System.Collections.Generic;
|
|||
using cfg.BuffCfg;
|
||||
using Gameplay.Area;
|
||||
using Gameplay.Buff;
|
||||
using Gameplay.Building;
|
||||
using Gameplay.Character;
|
||||
using GamePlay.Building.Fight.Impl.Builds;
|
||||
using GamePlay.Fight.Weapon;
|
||||
using Gameplay.Level;
|
||||
using Gameplay.Unit;
|
||||
|
|
@ -12,6 +14,7 @@ using Gameplay.Unit.Data;
|
|||
using Gameplay.Skill;
|
||||
using Gameplay.Vehicle;
|
||||
using Gameplay.Vehicle.Impl;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
|
@ -22,11 +25,15 @@ namespace FightDebug
|
|||
private Vector2 _scrollPos1;
|
||||
private GameUnit _targetUnit;
|
||||
private int _pureDamageValue = 100;
|
||||
private int _searchLightTargetCellIndex = -1;
|
||||
private string _searchLightTargetError = "";
|
||||
|
||||
public static void ShowWindow(GameUnit unit)
|
||||
{
|
||||
var win = GetWindow<SingleUnitWindow>("单位:" + unit.GetDescString());
|
||||
win._targetUnit = unit;
|
||||
win._searchLightTargetCellIndex = -1;
|
||||
win._searchLightTargetError = "";
|
||||
win.Show();
|
||||
win.Focus();
|
||||
}
|
||||
|
|
@ -432,12 +439,190 @@ namespace FightDebug
|
|||
{
|
||||
switch (_targetUnit.gameunitType)
|
||||
{
|
||||
case EGameUnitType.Building:
|
||||
_ShowBuildExt();
|
||||
break;
|
||||
case EGameUnitType.Vehicle:
|
||||
_ShowVehicleExt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void _ShowBuildExt()
|
||||
{
|
||||
var searchLight = _targetUnit as UnitBuildSearchLight;
|
||||
if (searchLight != null)
|
||||
{
|
||||
_ShowSearchLightExt(searchLight);
|
||||
}
|
||||
}
|
||||
|
||||
private void _ShowSearchLightExt(UnitBuildSearchLight searchLight)
|
||||
{
|
||||
GUILayout.BeginVertical("box");
|
||||
GUILayout.Label("探照灯调试", EditorStyles.boldLabel);
|
||||
|
||||
var enterUnit = searchLight.enterUnit;
|
||||
var canControl = enterUnit != null && enterUnit.commonData.troopId == ETroopsId.Self;
|
||||
var cellIndexes = searchLight.DebugLightUpCellIndexes;
|
||||
var cellIndexListText = _BuildCellIndexListText(cellIndexes);
|
||||
|
||||
_ShowLabel("建筑阵营:", _GetTroopName(searchLight.commonData.troopId));
|
||||
_ShowLabel("进驻单位:", enterUnit != null ? enterUnit.GetDescString() : "无");
|
||||
if (enterUnit != null)
|
||||
{
|
||||
_ShowLabel("进驻单位ID:", enterUnit.GetID() + "", true);
|
||||
_ShowLabel("进驻单位阵营:", _GetTroopName(enterUnit.commonData.troopId));
|
||||
}
|
||||
|
||||
_ShowLabel("允许调试控制:", canControl ? "是" : "否");
|
||||
_ShowLabel("中心格子数量:", searchLight.DebugLightUpCellCount + "");
|
||||
_ShowLabel("中心格子列表:", cellIndexListText, true);
|
||||
_ShowLabel("当前中心格子:", searchLight.nowLookCellIndex + "", true);
|
||||
_ShowLabel("当前索引:", searchLight.DebugCurrentIndex + "");
|
||||
_ShowLabel("上一个中心格子:", searchLight.DebugLastLightUpCellIndex + "");
|
||||
_ShowLabel("待目标格子:", searchLight.DebugControlTargetCellIndex + "", true);
|
||||
_ShowLabel("照亮范围:", searchLight.lightUpDistance + "格");
|
||||
_ShowLabel("停留时间:", searchLight.DebugPosStayTime.ToString("F2") + "秒");
|
||||
_ShowLabel("当前停留计时:", searchLight.DebugNowStayTime.ToString("F2") + "秒");
|
||||
_ShowLabel("循环模式:", _GetSearchLightLoopTypeName(searchLight.DebugLoopType));
|
||||
_ShowLabel("当前旋转方向:", _GetSearchLightRotateDirName(searchLight.DebugNowRotateDir));
|
||||
|
||||
if (_searchLightTargetCellIndex < 0 && searchLight.nowLookCellIndex >= 0)
|
||||
{
|
||||
_searchLightTargetCellIndex = searchLight.nowLookCellIndex;
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("目标中心格子:", GUILayout.Width(140));
|
||||
_searchLightTargetCellIndex = EditorGUILayout.IntField(_searchLightTargetCellIndex);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!canControl);
|
||||
if (GUILayout.Button("设置目标位置"))
|
||||
{
|
||||
_TrySetSearchLightTarget(searchLight);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (!canControl)
|
||||
{
|
||||
EditorGUILayout.HelpBox("仅当探照灯内部进驻己方单位时允许设置目标位置。", MessageType.Info);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_searchLightTargetError))
|
||||
{
|
||||
EditorGUILayout.HelpBox(_searchLightTargetError, MessageType.Warning);
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void _TrySetSearchLightTarget(UnitBuildSearchLight searchLight)
|
||||
{
|
||||
_searchLightTargetError = "";
|
||||
var enterUnit = searchLight.enterUnit;
|
||||
if (enterUnit == null)
|
||||
{
|
||||
_searchLightTargetError = "探照灯内部没有进驻单位,无法设置目标位置。";
|
||||
return;
|
||||
}
|
||||
|
||||
if (enterUnit.commonData.troopId != ETroopsId.Self)
|
||||
{
|
||||
_searchLightTargetError = "探照灯内部不是己方单位,无法设置目标位置。";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_ContainsCellIndex(searchLight.DebugLightUpCellIndexes, _searchLightTargetCellIndex))
|
||||
{
|
||||
_searchLightTargetError = "目标格子不在探照灯可照亮中心格子列表内。";
|
||||
return;
|
||||
}
|
||||
|
||||
searchLight.SetLightUpCellIndex(_searchLightTargetCellIndex);
|
||||
}
|
||||
|
||||
private bool _ContainsCellIndex(IReadOnlyList<int> cellIndexes, int cellIndex)
|
||||
{
|
||||
if (cellIndexes == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cellIndexes.Count; i++)
|
||||
{
|
||||
if (cellIndexes[i] == cellIndex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private string _BuildCellIndexListText(IReadOnlyList<int> cellIndexes)
|
||||
{
|
||||
if (cellIndexes == null || cellIndexes.Count <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
var builder = new StringBuilder(cellIndexes.Count * 4);
|
||||
for (int i = 0; i < cellIndexes.Count; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
builder.Append(",");
|
||||
}
|
||||
|
||||
builder.Append(cellIndexes[i]);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private string _GetTroopName(int troopId)
|
||||
{
|
||||
switch (troopId)
|
||||
{
|
||||
case ETroopsId.Self:
|
||||
return "己方";
|
||||
case ETroopsId.Enemy:
|
||||
return "敌方";
|
||||
case ETroopsId.Neutral:
|
||||
return "中立";
|
||||
default:
|
||||
return "未知(" + troopId + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private string _GetSearchLightLoopTypeName(int loopType)
|
||||
{
|
||||
switch (loopType)
|
||||
{
|
||||
case 0:
|
||||
return "循环";
|
||||
case 1:
|
||||
return "折返";
|
||||
default:
|
||||
return "未知(" + loopType + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private string _GetSearchLightRotateDirName(UnitBuildSearchLight.ERotateDir rotateDir)
|
||||
{
|
||||
switch (rotateDir)
|
||||
{
|
||||
case UnitBuildSearchLight.ERotateDir.Left:
|
||||
return "左";
|
||||
case UnitBuildSearchLight.ERotateDir.Right:
|
||||
return "右";
|
||||
default:
|
||||
return rotateDir.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void _ShowVehicleExt()
|
||||
{
|
||||
var normalVehicle = _targetUnit as NormalVehicle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue