using cfg.MonsterCfg; using Cysharp.Threading.Tasks; using Framework; using Gameplay.Character; using Gameplay.Level; using UnityEditor; using UnityEngine; namespace FightDebug.Impl { public class Debug_AddEnemy : BaseSubDebugPanel { private int _monsterId; private DataMonster _monsterConfig; private int _addCellIndex; public Debug_AddEnemy() : base("动态增加敌人") { } protected override void _OnDrawUI() { base._OnDrawUI(); var newMonsterId = EditorGUILayout.IntField("MonsterID", _monsterId); if (newMonsterId != _monsterId) { _monsterId = newMonsterId; _monsterConfig = EditorTableManager.instance.tables.Monster.GetOrDefault(_monsterId); } if (_monsterConfig == null) { EditorGUILayout.HelpBox("MonsterID不存在", MessageType.Error); } _addCellIndex = EditorGUILayout.IntField("CellIndex", _addCellIndex); if (GUILayout.Button("添加", GUILayout.Height(40))) { if (_monsterConfig == null) { // 弹窗提示 EditorUtility.DisplayDialog("错误", "MonsterID不存在", "确定"); return; } _AddEnemy(); } } private void _AddEnemy() { if (!Application.isPlaying) { EditorUtility.DisplayDialog("错误", "需要先运行游戏", "确定"); return; } if (!LevelManager.Instance.IsInLevel) { EditorUtility.DisplayDialog("错误", "需要在关卡中", "确定"); return; } var fakeNpcInfo = new LevelData.NPCInfo() { id = _monsterId, position = LevelManager.Instance.CurrentLevel.Map.TGSCellIndex2BlockPosition(_addCellIndex), shield = 1f, ph = 1f, morale = 1f, defensiveDistance = 10, configName = "AIbaseEnemy", troopId = ETroopsId.Enemy, }; LevelManager.Instance.CurrentLevel.ForceCreateEnemyNpc(fakeNpcInfo).Forget(); } } }