using cfg.CharacterCfg; using Cysharp.Threading.Tasks; using Framework; using Gameplay.Level; using UnityEditor; using UnityEngine; namespace FightDebug.Impl { public class Debug_AddSelfCharacter : BaseSubDebugPanel { private int _characterRoleId; private int _level = 1; private int _breakLevel = 0; private int _awakeLevel = 0; private int _skillLevel = 1; private DataCharacterAttri _characterConfig; private int _addCellIndex; public Debug_AddSelfCharacter() : base("动态添加角色") { } protected override void _OnDrawUI() { base._OnDrawUI(); var newRoleId = EditorGUILayout.IntField("角色ID", _characterRoleId); if (_characterRoleId != newRoleId) { _characterRoleId = newRoleId; _characterConfig = EditorTableManager.instance.tables.CharacterAttri.GetOrDefault(_characterRoleId); } if (_characterConfig == null) { EditorGUILayout.HelpBox("角色ID不存在", MessageType.Error); } _level = EditorGUILayout.IntField("角色等级", _level); _breakLevel = EditorGUILayout.IntField("角色突破等级", _breakLevel); _awakeLevel = EditorGUILayout.IntField("角色觉醒等级", _awakeLevel); _skillLevel = EditorGUILayout.IntField("角色技能等级", _skillLevel); _addCellIndex = EditorGUILayout.IntField("CellIndex", _addCellIndex); if (GUILayout.Button("添加角色", GUILayout.Height(40))) { if (_characterConfig == null) { EditorUtility.DisplayDialog("错误", "角色ID不存在", "确定"); return; } _AddCharacter(); } } private void _AddCharacter() { if (!Application.isPlaying) { EditorUtility.DisplayDialog("错误", "需要先运行游戏", "确定"); return; } if (!LevelManager.Instance.IsInLevel) { EditorUtility.DisplayDialog("错误", "需要在关卡中", "确定"); return; } var characterInfo = new CharacterDataInfo((uint)_characterRoleId, (uint)_level, (uint)_breakLevel, (uint)_awakeLevel); characterInfo.UltraSkillLevel = (uint)_skillLevel; characterInfo.SkillLevels = new uint[] { (uint)_skillLevel }; LevelManager.Instance.CurrentLevel.ForceCreateSelfCharacter(characterInfo, _addCellIndex).Forget(); } } }