174 lines
6.6 KiB
C#
174 lines
6.6 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description: 成就 编辑器
|
|
* @Date: 2025年04月22日 星期二 15:04:14
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Logic.Achievement;
|
|
using Logic.HeroTask;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Logic.HeroTask;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Logic.Editor
|
|
{
|
|
public class HeroTaskEditorWindow : EditorWindow
|
|
{
|
|
// 滑条
|
|
private Vector2 _barPosition;
|
|
|
|
// 背景
|
|
private GUIStyle _redBoxStyle;
|
|
private GUIStyle _whiteBoxStyle;
|
|
|
|
private HeroTaskAsset _asset;
|
|
private HeroTaskData _data;
|
|
private UnitType _unitType;
|
|
private GiantType _giantType;
|
|
private uint _level;
|
|
|
|
|
|
[MenuItem("Tools/英雄任务编辑器")]
|
|
private static void ShowWindow()
|
|
{
|
|
var window = CreateWindow<HeroTaskEditorWindow>();
|
|
window.titleContent = new GUIContent("英雄任务编辑器");
|
|
window.Show();
|
|
window.minSize = new Vector2(500, 600);
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
if (!_asset)
|
|
{
|
|
var path = $"Assets/BundleResources/DataAssets/HeroTask.asset";
|
|
_asset = AssetDatabase.LoadAssetAtPath<HeroTaskAsset>(path);
|
|
if (!_asset)
|
|
{
|
|
_asset = CreateInstance<HeroTaskAsset>();
|
|
AssetDatabase.CreateAsset(_asset, path);
|
|
AssetDatabase.SaveAssets();
|
|
AssetDatabase.Refresh();
|
|
}
|
|
}
|
|
|
|
if (_data == null && _asset.Data != null && _asset.Data.Length > 0)
|
|
{
|
|
_data = MemoryPack.MemoryPackSerializer.Deserialize<HeroTaskData>(_asset.Data);
|
|
}
|
|
if (_data == null) _data = new HeroTaskData();
|
|
if (_redBoxStyle == null)
|
|
{
|
|
_redBoxStyle = InspectorUtils.GetHelpBoxStyle();
|
|
InspectorUtils.AddBorder(_redBoxStyle, new Color(0.5f, 0.4f, 0.4f, 0.6f));
|
|
}
|
|
if (_whiteBoxStyle == null)
|
|
{
|
|
_whiteBoxStyle = InspectorUtils.GetHelpBoxStyle();
|
|
InspectorUtils.AddBorder(_whiteBoxStyle, new Color(1f, 1f, 1f, 0.2f));
|
|
}
|
|
|
|
GUI.skin.button.wordWrap = true;
|
|
_barPosition = EditorGUILayout.BeginScrollView(_barPosition);
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
if (InspectorUtils.InspectorButtonWithTextWidth("保存"))
|
|
{
|
|
_asset.Data = MemoryPack.MemoryPackSerializer.Serialize(_data);
|
|
EditorUtility.SetDirty(_asset);
|
|
AssetDatabase.SaveAssets();
|
|
AssetDatabase.Refresh();
|
|
}
|
|
var item = _data.Items.Find(a => a.UnitType == _unitType && a.GiantType == _giantType && a.Level == _level);
|
|
if ((item == null || item.Content == null) && InspectorUtils.InspectorButtonWithTextWidth("添加任务"))
|
|
{
|
|
if (item == null)
|
|
{
|
|
item = new HeroTaskItem();
|
|
item.UnitType = _unitType;
|
|
item.GiantType = _giantType;
|
|
item.Level = _level;
|
|
_data.Items.Add(item);
|
|
}
|
|
item.Content = new HeroTaskContentAccumulateDamageTaken();
|
|
}
|
|
if (item != null && InspectorUtils.InspectorButtonWithTextWidth("删除任务"))
|
|
{
|
|
_data.Items.Remove(item);
|
|
}
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
InspectorUtils.InspectorTextWidthRich($"<b>Unit:</b>");
|
|
_unitType = (UnitType)EditorGUILayout.EnumPopup(_unitType, GUILayout.Width(100));
|
|
InspectorUtils.InspectorTextWidthRich($"<b>Giant:</b>");
|
|
_giantType = (GiantType)EditorGUILayout.EnumPopup(_giantType, GUILayout.Width(100));
|
|
InspectorUtils.InspectorTextWidthRich($"<b>Level:</b>");
|
|
_level = (uint)EditorGUILayout.IntField((int)_level, GUILayout.Width(20));
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
if (item == null) InspectorUtils.InspectorTextWidthRich($"<b>此英雄暂无配置任务</b>");
|
|
else OnGUIHeroTaskItem(item);
|
|
EditorGUILayout.EndScrollView();
|
|
}
|
|
|
|
private void OnGUIHeroTaskItem(HeroTaskItem item)
|
|
{
|
|
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
var contentType = item.Content.GetContentType();
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 条件类型 </b>");
|
|
contentType = (HeroTaskContentType) EditorGUILayout.EnumPopup(contentType, GUILayout.Width(150));
|
|
if (contentType != item.Content.GetContentType())
|
|
item.Content = HeroTaskFactory.GetHeroTaskContentBase(contentType);
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
InspectorUtils.InspectorTextWidthRich($"<b>{HeroTaskFactory.GetHeroTaskContentName(contentType)}</b>");
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 目标值 n </b>");
|
|
item.Content.TargetLevel = (uint)EditorGUILayout.IntField((int)item.Content.TargetLevel, GUILayout.Width(20));
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
if (contentType == HeroTaskContentType.AddSkillStacks)
|
|
{
|
|
var content = item.Content as HeroTaskContentAddSkillStacks;
|
|
EditorGUILayout.BeginHorizontal();
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 技能类型 </b>");
|
|
content.SkillType = (SkillType) EditorGUILayout.EnumPopup(content.SkillType, GUILayout.Width(150));
|
|
EditorGUILayout.EndHorizontal();
|
|
}
|
|
|
|
if (contentType == HeroTaskContentType.SkillActivation)
|
|
{
|
|
var content = item.Content as HeroTaskContentSkillActivation;
|
|
EditorGUILayout.BeginHorizontal();
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 技能类型 </b>");
|
|
content.SkillType = (SkillType) EditorGUILayout.EnumPopup(content.SkillType, GUILayout.Width(150));
|
|
EditorGUILayout.EndHorizontal();
|
|
}
|
|
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
}
|
|
} |