重做物品系统
This commit is contained in:
@@ -1,33 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &-9179132900460120086
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e49882beb2bb280438028a6a8a591abf, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
type: 0
|
|
||||||
minValue: 0
|
|
||||||
maxValue: 9999
|
|
||||||
baseValue: 0
|
|
||||||
container: {fileID: 11400000}
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 11c3d0ab6f395eb41bcf0e66676f68a3, type: 3}
|
|
||||||
m_Name: New Value Container Const
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
instances:
|
|
||||||
- {fileID: -9179132900460120086}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 533df5779dbd0d94198fc1659c24f228
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 23403840a9d12654f8f15c6188728498, type: 3}
|
|
||||||
m_Name: "\u7269\u54C1\u5C5E\u6027"
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
instances:
|
|
||||||
- {fileID: 6610366098165316818}
|
|
||||||
- {fileID: 2362838488679916709}
|
|
||||||
- {fileID: 4633682211995004289}
|
|
||||||
--- !u!114 &2362838488679916709
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
|
||||||
m_Name: "\u9632\u5FA1"
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
type: 0
|
|
||||||
defaultValue: 5
|
|
||||||
minValue: 0
|
|
||||||
maxValue: 9999
|
|
||||||
container: {fileID: 11400000}
|
|
||||||
--- !u!114 &4633682211995004289
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
|
||||||
m_Name: "\u9B54\u6CD5\u503C"
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
type: 3
|
|
||||||
defaultValue: 0
|
|
||||||
minValue: 0
|
|
||||||
maxValue: 100
|
|
||||||
container: {fileID: 11400000}
|
|
||||||
--- !u!114 &6610366098165316818
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
|
||||||
m_Name: "\u653B\u51FB"
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
type: 0
|
|
||||||
defaultValue: 0
|
|
||||||
minValue: 0
|
|
||||||
maxValue: 9999
|
|
||||||
container: {fileID: 11400000}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d07fad53a94189c42bcebe454bc4dde0
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6a2d6badedf74af4a8e4faffb6130a48
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace MuHuaEditor {
|
|
||||||
/// <summary>
|
|
||||||
/// 属性容器 - 自定义编辑器
|
|
||||||
/// </summary>
|
|
||||||
[CustomEditor(typeof(AttributeContainerConst))]
|
|
||||||
public class AttributeContainerConstEditor : ModuleUIEditor<AttributeContainerConst> {
|
|
||||||
|
|
||||||
public VisualTreeAsset AttributeTemplate = default;
|
|
||||||
|
|
||||||
private UIAttributeList attributeList;
|
|
||||||
|
|
||||||
public VisualElement AttributeList => Q<VisualElement>("AttributeList");
|
|
||||||
public Button Button1 => Q<Button>("Button1");// 创建属性
|
|
||||||
public Button Button2 => Q<Button>("Button2");// 删除全部
|
|
||||||
|
|
||||||
public override void Initial() {
|
|
||||||
attributeList = new UIAttributeList(AttributeList, AttributeTemplate);
|
|
||||||
attributeList.Initial(value);
|
|
||||||
AddControl(attributeList);
|
|
||||||
|
|
||||||
Button1.clicked += GenerateAttribute;
|
|
||||||
Button2.clicked += DeleteInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 创建属性实例 </summary>
|
|
||||||
private void GenerateAttribute() {
|
|
||||||
AttributeInstanceConst instance = CreateInstance<AttributeInstanceConst>();
|
|
||||||
instance.container = value;
|
|
||||||
// 加入容器
|
|
||||||
value.instances.Add(instance);
|
|
||||||
AssetDatabase.AddObjectToAsset(instance, value);
|
|
||||||
EditorUtility.SetDirty(instance);
|
|
||||||
EditorUtility.SetDirty(value);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
/// <summary> 删除全部实例 </summary>
|
|
||||||
private void DeleteInstance() {
|
|
||||||
for (int i = value.instances.Count; i-- > 0;) {
|
|
||||||
AttributeInstanceConst instance = value.instances[i];
|
|
||||||
value.instances.Remove(instance);
|
|
||||||
Undo.DestroyObjectImmediate(instance);
|
|
||||||
}
|
|
||||||
EditorUtility.SetDirty(value);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d8ae6bbae674e19448216fd6b41cd012
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences:
|
|
||||||
- VisualTreeAsset: {fileID: 9197481963319205126, guid: 95527f76fc8930d4ab47213114a5952b, type: 3}
|
|
||||||
- AttributeTemplate: {fileID: 9197481963319205126, guid: 1749a10e5ffdea045b442dfa323e4028, type: 3}
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEditor;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
namespace MuHuaEditor {
|
|
||||||
/// <summary>
|
|
||||||
/// 属性实例 - 自定义编辑器
|
|
||||||
/// </summary>
|
|
||||||
[CustomEditor(typeof(AttributeInstanceConst))]
|
|
||||||
public class AttributeInstanceConstEditor : ModuleUIEditor<AttributeInstanceConst> {
|
|
||||||
|
|
||||||
public UIAttributePanel attributePanel;
|
|
||||||
|
|
||||||
public VisualElement AttributePanel => Q<VisualElement>("AttributePanel");
|
|
||||||
public FloatField Min => Q<FloatField>("Min");
|
|
||||||
public FloatField Max => Q<FloatField>("Max");
|
|
||||||
public Button button => Q<Button>("Button");
|
|
||||||
|
|
||||||
public override void Initial() {
|
|
||||||
attributePanel = new UIAttributePanel(value, AttributePanel);
|
|
||||||
|
|
||||||
Min.SetValueWithoutNotify(value.minValue);
|
|
||||||
Max.SetValueWithoutNotify(value.maxValue);
|
|
||||||
|
|
||||||
Min.RegisterCallback<FocusOutEvent>(evt => ModifyMin());
|
|
||||||
Max.RegisterCallback<FocusOutEvent>(evt => ModifyMax());
|
|
||||||
|
|
||||||
button.clicked += DeleteInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 修改最小值 </summary>
|
|
||||||
private void ModifyMin() { value.minValue = Min.value; Dirty(); }
|
|
||||||
/// <summary> 修改最大值 </summary>
|
|
||||||
private void ModifyMax() { value.maxValue = Max.value; Dirty(); }
|
|
||||||
|
|
||||||
/// <summary> 保存资源 </summary>
|
|
||||||
private void Dirty() {
|
|
||||||
EditorUtility.SetDirty(value);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 删除实例 </summary>
|
|
||||||
private void DeleteInstance() {
|
|
||||||
AttributeContainerConst container = value.container;
|
|
||||||
container.instances.Remove(value);
|
|
||||||
EditorUtility.SetDirty(container);
|
|
||||||
Undo.DestroyObjectImmediate(value);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1e2db82f02928494990b89396707863b
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences:
|
|
||||||
- VisualTreeAsset: {fileID: 9197481963319205126, guid: 01bc614c0c779d148afa254dbde22ec8, type: 3}
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEditor;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
namespace MuHuaEditor {
|
|
||||||
/// <summary>
|
|
||||||
/// 属性 - UI列表
|
|
||||||
/// </summary>
|
|
||||||
public class UIAttributeList : ModuleUIPanel, UIControl {
|
|
||||||
/// <summary> 模板资源 </summary>
|
|
||||||
public VisualTreeAsset templateAsset;
|
|
||||||
/// <summary> 移动目标 </summary>
|
|
||||||
public VisualElement moving;
|
|
||||||
/// <summary> 拖拽预览 </summary>
|
|
||||||
public VisualElement preview;
|
|
||||||
/// <summary> 项目预览 </summary>
|
|
||||||
public UIItem previewItem;
|
|
||||||
/// <summary> 鼠标偏移 </summary>
|
|
||||||
public Vector2 mousePosition;
|
|
||||||
/// <summary> 位置偏移 </summary>
|
|
||||||
public Vector2 positionOffset;
|
|
||||||
/// <summary> 偏移位置 </summary>
|
|
||||||
public Vector2 mouseOffset;
|
|
||||||
/// <summary> 属性列表 </summary>
|
|
||||||
public AttributeContainerConst container;
|
|
||||||
/// <summary> 项目列表 </summary>
|
|
||||||
public ModuleUIItems<UIItem, AttributeInstanceConst> items;
|
|
||||||
|
|
||||||
public UIAttributeList(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
|
||||||
this.templateAsset = templateAsset;
|
|
||||||
items = new ModuleUIItems<UIItem, AttributeInstanceConst>(element, templateAsset,
|
|
||||||
(data, element) => new UIItem(data, element, this));
|
|
||||||
|
|
||||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
|
||||||
element.RegisterCallback<MouseMoveEvent>(FloatingFunc);
|
|
||||||
}
|
|
||||||
private void MouseUpEvent(MouseUpEvent evt) {
|
|
||||||
if (preview == null) { return; }
|
|
||||||
preview.parent.Remove(preview);
|
|
||||||
preview = null;
|
|
||||||
moving.EnableInClassList("acce-hide", false);
|
|
||||||
if (previewItem == null) { return; }
|
|
||||||
previewItem.Dispose();
|
|
||||||
|
|
||||||
EditorUtility.SetDirty(container);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
private void FloatingFunc(MouseMoveEvent evt) {
|
|
||||||
mousePosition = evt.mousePosition;
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
if (preview == null) { return; }
|
|
||||||
preview.transform.position = positionOffset + mousePosition - mouseOffset;
|
|
||||||
int insertIndex = GetInsertIndex(element, preview);
|
|
||||||
int oldIndex = element.IndexOf(moving);
|
|
||||||
// 修正插入索引
|
|
||||||
// Debug.Log($"{insertIndex} , {oldIndex}");
|
|
||||||
if (insertIndex > oldIndex) insertIndex--;
|
|
||||||
if (oldIndex != insertIndex) { MovePreviewElement(oldIndex, insertIndex); }
|
|
||||||
}
|
|
||||||
public void Dispose() => items.Release();
|
|
||||||
|
|
||||||
/// <summary> 初始化 </summary>
|
|
||||||
public void Initial(AttributeContainerConst container) {
|
|
||||||
this.container = container;
|
|
||||||
items.Create(container.instances);
|
|
||||||
}
|
|
||||||
/// <summary> 设置值 </summary>
|
|
||||||
public void Settings(VisualElement moving, AttributeInstanceConst value) {
|
|
||||||
this.moving = moving;
|
|
||||||
moving.EnableInClassList("acce-hide", true);
|
|
||||||
|
|
||||||
preview = templateAsset.Instantiate();
|
|
||||||
previewItem = new UIItem(value, preview);
|
|
||||||
items.element.Add(preview);
|
|
||||||
|
|
||||||
preview.EnableInClassList("acce-preview", true);
|
|
||||||
// Debug.Log($"{preview.transform.position} , {preview.worldBound.position} , {moving.worldBound.position}");
|
|
||||||
mouseOffset = mousePosition;
|
|
||||||
// preview.transform.position的默认值
|
|
||||||
positionOffset = moving.worldBound.position - preview.worldBound.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 获取插入索引 </summary>
|
|
||||||
private int GetInsertIndex(VisualElement parent, VisualElement preview) {
|
|
||||||
Vector2 previewCenter = preview.worldBound.center;
|
|
||||||
int insertIndex = 0;
|
|
||||||
for (int i = 0; i < parent.childCount - 1; i++) {
|
|
||||||
VisualElement child = parent[i];
|
|
||||||
if (child == preview) continue;
|
|
||||||
if (previewCenter.y - 10 < child.worldBound.center.y) { insertIndex = i; break; }
|
|
||||||
insertIndex = i + 1;
|
|
||||||
}
|
|
||||||
return insertIndex;
|
|
||||||
}
|
|
||||||
/// <summary> 移动预览元素到新位置 </summary>
|
|
||||||
private void MovePreviewElement(int oldIndex, int newIndex) {
|
|
||||||
VisualElement temp = element[oldIndex];
|
|
||||||
element.Insert(newIndex, temp);
|
|
||||||
|
|
||||||
AttributeInstanceConst instanceConst = container.instances[oldIndex];
|
|
||||||
container.instances.RemoveAt(oldIndex);
|
|
||||||
container.instances.Insert(newIndex, instanceConst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> UI项 </summary>
|
|
||||||
public class UIItem : ModuleUIItem<AttributeInstanceConst> {
|
|
||||||
public readonly UIAttributeList parent;
|
|
||||||
public UIAttributePanel attributePanel;
|
|
||||||
|
|
||||||
public UIItem(AttributeInstanceConst value, VisualElement element) : base(value, element) {
|
|
||||||
attributePanel = new UIAttributePanel(value, element);
|
|
||||||
}
|
|
||||||
public UIItem(AttributeInstanceConst value, VisualElement element, UIAttributeList parent) : base(value, element) {
|
|
||||||
this.parent = parent;
|
|
||||||
attributePanel = new UIAttributePanel(value, element);
|
|
||||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
|
||||||
}
|
|
||||||
public override void DefaultState() {
|
|
||||||
// Button.EnableInClassList("button-s", false);
|
|
||||||
}
|
|
||||||
public override void SelectState() {
|
|
||||||
// parent.Settings(value);
|
|
||||||
// Button.EnableInClassList("button-s", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MouseDownEvent(MouseDownEvent evt) => parent.Settings(element, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 82adca68fa56cb14382ebd547a8bf044
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEditor;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性面板
|
|
||||||
/// </summary>
|
|
||||||
public class UIAttributePanel : ModuleUIPanel {
|
|
||||||
|
|
||||||
private AttributeInstanceConst value;
|
|
||||||
|
|
||||||
public Label Range => Q<Label>("Range");
|
|
||||||
public TextField Name => Q<TextField>("Name");
|
|
||||||
public EnumField Type => Q<EnumField>("Type");
|
|
||||||
public FloatField Value => Q<FloatField>("Value");
|
|
||||||
public Toggle Boolean => Q<Toggle>("Boolean");
|
|
||||||
|
|
||||||
public UIAttributePanel(AttributeInstanceConst value, VisualElement element) : base(element) {
|
|
||||||
this.value = value;
|
|
||||||
Initial();
|
|
||||||
Name.RegisterCallback<FocusOutEvent>(evt => ModifyName());
|
|
||||||
Type.RegisterValueChangedCallback(evt => ModifyType((AttributeType)evt.newValue));
|
|
||||||
Value.RegisterCallback<FocusOutEvent>(evt => ModifyValue());
|
|
||||||
Boolean.RegisterValueChangedCallback(evt => ModifyBoolean());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initial() {
|
|
||||||
Name.SetValueWithoutNotify(value.name);
|
|
||||||
Type.Init(value.type);
|
|
||||||
Value.SetValueWithoutNotify(value.defaultValue);
|
|
||||||
Boolean.value = value.defaultValue > 0;
|
|
||||||
|
|
||||||
if (value.type == AttributeType.Boolean) {
|
|
||||||
Value.style.display = DisplayStyle.None;
|
|
||||||
}
|
|
||||||
else { Boolean.style.display = DisplayStyle.None; }
|
|
||||||
|
|
||||||
if (value.type == AttributeType.Percentage) {
|
|
||||||
Range.text = $"{value.minValue}% ~ {value.maxValue}%";
|
|
||||||
}
|
|
||||||
else { Range.text = $"{value.minValue} ~ {value.maxValue}"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 修改名字 </summary>
|
|
||||||
private void ModifyName() { value.name = Name.value; Dirty(); }
|
|
||||||
/// <summary> 修改类型 </summary>
|
|
||||||
private void ModifyType(AttributeType type) {
|
|
||||||
if (type == AttributeType.Float) { value.InitialFloat(); }
|
|
||||||
if (type == AttributeType.Integer) { value.InitialInteger(); }
|
|
||||||
if (type == AttributeType.Boolean) { value.InitialBoolean(); }
|
|
||||||
if (type == AttributeType.Percentage) { value.InitialPercentage(); }
|
|
||||||
if (value.type == AttributeType.Boolean) {
|
|
||||||
Value.style.display = DisplayStyle.None;
|
|
||||||
}
|
|
||||||
else { Boolean.style.display = DisplayStyle.None; }
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
/// <summary> 修改默认值 </summary>
|
|
||||||
private void ModifyValue() { value.defaultValue = Value.value; Dirty(); }
|
|
||||||
/// <summary> 修改布尔值 </summary>
|
|
||||||
private void ModifyBoolean() { value.defaultValue = Boolean.value ? 1 : 0; Dirty(); }
|
|
||||||
|
|
||||||
/// <summary> 保存资源 </summary>
|
|
||||||
private void Dirty() {
|
|
||||||
EditorUtility.SetDirty(value);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4aeb4c96a0ef14c4f9cb2b8afdfc091c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性容器
|
|
||||||
/// </summary>
|
|
||||||
public class AttributeContainer {
|
|
||||||
/// <summary> 属性字典 </summary>
|
|
||||||
public Dictionary<string, AttributeInstance> dictionary = new Dictionary<string, AttributeInstance>();
|
|
||||||
|
|
||||||
/// <summary> 添加属性 </summary>
|
|
||||||
public void AddInstance(string attributeID, AttributeInstance instance) {
|
|
||||||
if (dictionary.ContainsKey(attributeID)) { return; }
|
|
||||||
dictionary.Add(attributeID, instance);
|
|
||||||
}
|
|
||||||
/// <summary> 添加修改器 </summary>
|
|
||||||
public void AddModifier(string attributeID, AttributeModifier mod, bool isUpdate) {
|
|
||||||
if (!dictionary.ContainsKey(attributeID)) { return; }
|
|
||||||
dictionary[attributeID].AddModifier(mod, isUpdate);
|
|
||||||
}
|
|
||||||
/// <summary> 重新计算值 </summary>
|
|
||||||
public void RecalculateValue() {
|
|
||||||
foreach (var item in dictionary) { item.Value.RecalculateValue(); }
|
|
||||||
}
|
|
||||||
/// <summary> 循环属性集合 </summary>
|
|
||||||
public void ForEach(Action<string, AttributeInstance> action) {
|
|
||||||
foreach (var item in dictionary) { action?.Invoke(item.Key, item.Value); }
|
|
||||||
}
|
|
||||||
/// <summary> 查询值 </summary>
|
|
||||||
public float FindValue(string attributeID) {
|
|
||||||
if (!dictionary.ContainsKey(attributeID)) { return 0; }
|
|
||||||
return dictionary[attributeID].currentValue;
|
|
||||||
}
|
|
||||||
/// <summary> 查询修改器 </summary>
|
|
||||||
public List<AttributeModifier> FindModifier(string attributeID) {
|
|
||||||
if (!dictionary.ContainsKey(attributeID)) { return new(); }
|
|
||||||
return dictionary[attributeID].modifiers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 112a5ce9d53f8d2408d0f882a639982c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性容器 - 常量
|
|
||||||
/// </summary>
|
|
||||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性容器")]
|
|
||||||
public class AttributeContainerConst : ScriptableObject {
|
|
||||||
/// <summary> 属性列表 </summary>
|
|
||||||
[HideInInspector]
|
|
||||||
public List<AttributeInstanceConst> instances = new List<AttributeInstanceConst>();
|
|
||||||
|
|
||||||
/// <summary> 转换数据 </summary>
|
|
||||||
public AttributeContainer To() {
|
|
||||||
AttributeContainer container = new AttributeContainer();
|
|
||||||
instances.ForEach(obj => container.AddInstance(obj.name, obj.To()));
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性实例
|
|
||||||
/// </summary>
|
|
||||||
public class AttributeInstance {
|
|
||||||
/// <summary> 属性名称 </summary>
|
|
||||||
public string name;
|
|
||||||
/// <summary> 基础值 </summary>
|
|
||||||
public float baseValue;
|
|
||||||
/// <summary> 当前值 </summary>
|
|
||||||
public float currentValue;
|
|
||||||
/// <summary> 附加值% </summary>
|
|
||||||
public float additionValue;
|
|
||||||
/// <summary> 最小值 </summary>
|
|
||||||
public float minValue;
|
|
||||||
/// <summary> 最大值 </summary>
|
|
||||||
public float maxValue = float.MaxValue;
|
|
||||||
/// <summary> 属性类型 </summary>
|
|
||||||
public AttributeType type;
|
|
||||||
/// <summary> 修改器列表 </summary>
|
|
||||||
public List<AttributeModifier> modifiers = new List<AttributeModifier>();
|
|
||||||
|
|
||||||
/// <summary> 添加修改器 </summary>
|
|
||||||
public void AddModifier(AttributeModifier mod, bool isUpdate) {
|
|
||||||
modifiers.Add(mod);
|
|
||||||
if (isUpdate) { RecalculateValue(); }
|
|
||||||
}
|
|
||||||
/// <summary> 添加修改器 </summary>
|
|
||||||
public void AddModifier(List<AttributeModifier> mods, bool isUpdate) {
|
|
||||||
modifiers.AddRange(mods);
|
|
||||||
if (isUpdate) { RecalculateValue(); }
|
|
||||||
}
|
|
||||||
/// <summary> 重新计算值 </summary>
|
|
||||||
public void RecalculateValue() {
|
|
||||||
currentValue = baseValue;
|
|
||||||
modifiers.ForEach(mod => currentValue = mod.Fixed(currentValue));
|
|
||||||
additionValue = 1;
|
|
||||||
modifiers.ForEach(mod => additionValue = mod.Addition(additionValue));
|
|
||||||
currentValue = currentValue * additionValue;
|
|
||||||
currentValue = Mathf.Clamp(currentValue, minValue, maxValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3552e7ce95869d341adbe3a4b2a98851
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性实例 - 常量
|
|
||||||
/// </summary>
|
|
||||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性实例")]
|
|
||||||
public class AttributeInstanceConst : ScriptableObject {
|
|
||||||
/// <summary> 属性类型 </summary>
|
|
||||||
public AttributeType type;
|
|
||||||
/// <summary> 默认值 </summary>
|
|
||||||
public float defaultValue;
|
|
||||||
/// <summary> 最小值 </summary>
|
|
||||||
public float minValue;
|
|
||||||
/// <summary> 最大值 </summary>
|
|
||||||
public float maxValue = 9999;
|
|
||||||
|
|
||||||
/// <summary> 属性容器 </summary>
|
|
||||||
[HideInInspector]
|
|
||||||
public AttributeContainerConst container;
|
|
||||||
|
|
||||||
public void InitialFloat() {
|
|
||||||
type = AttributeType.Float;
|
|
||||||
defaultValue = 0;
|
|
||||||
minValue = 0;
|
|
||||||
maxValue = 9999;
|
|
||||||
}
|
|
||||||
public void InitialInteger() {
|
|
||||||
type = AttributeType.Integer;
|
|
||||||
defaultValue = 0;
|
|
||||||
minValue = 0;
|
|
||||||
maxValue = 9999;
|
|
||||||
}
|
|
||||||
public void InitialBoolean() {
|
|
||||||
type = AttributeType.Boolean;
|
|
||||||
defaultValue = 0;
|
|
||||||
minValue = 0;
|
|
||||||
maxValue = 1;
|
|
||||||
}
|
|
||||||
public void InitialPercentage() {
|
|
||||||
type = AttributeType.Percentage;
|
|
||||||
defaultValue = 0;
|
|
||||||
minValue = 0;
|
|
||||||
maxValue = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 转换数据 </summary>
|
|
||||||
public AttributeInstance To() {
|
|
||||||
AttributeInstance instance = new AttributeInstance();
|
|
||||||
instance.type = type;
|
|
||||||
instance.name = name;
|
|
||||||
instance.baseValue = defaultValue;
|
|
||||||
instance.currentValue = defaultValue;
|
|
||||||
instance.minValue = minValue;
|
|
||||||
instance.maxValue = maxValue;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e891e45f4230ee04d8d329520fd39cbc
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性调整
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AttributeModifier {
|
|
||||||
/// <summary> 固定值 </summary>
|
|
||||||
public abstract float Fixed(float input);
|
|
||||||
/// <summary> 附加值% </summary>
|
|
||||||
public abstract float Addition(float input);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2a544851e744f1540b431f2506157f18
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性附加
|
|
||||||
/// </summary>
|
|
||||||
public class AttributeSystem : Module<AttributeSystem> {
|
|
||||||
/// <summary> 修改事件 </summary>
|
|
||||||
public static event Action<AttributeSystem> OnChange;
|
|
||||||
/// <summary> 附加字典 </summary>
|
|
||||||
public Dictionary<string, AttributeContainer> dictionary = new Dictionary<string, AttributeContainer>();
|
|
||||||
|
|
||||||
/// <summary> 应用修改 </summary>
|
|
||||||
public void Apply() => OnChange?.Invoke(this);
|
|
||||||
/// <summary> 添加容器 </summary>
|
|
||||||
public void AddInstance(string containerID, AttributeContainer container) {
|
|
||||||
if (dictionary.ContainsKey(containerID)) { return; }
|
|
||||||
dictionary.Add(containerID, container);
|
|
||||||
OnChange?.Invoke(this);
|
|
||||||
}
|
|
||||||
/// <summary> 添加修改器 </summary>
|
|
||||||
public void AddModifier(string containerID, string attributeID, AttributeModifier mod, bool isUpdate) {
|
|
||||||
if (!dictionary.ContainsKey(containerID)) { return; }
|
|
||||||
dictionary[containerID].AddModifier(attributeID, mod, isUpdate);
|
|
||||||
OnChange?.Invoke(this);
|
|
||||||
}
|
|
||||||
/// <summary> 重新计算值 </summary>
|
|
||||||
public void RecalculateValue() {
|
|
||||||
foreach (var item in dictionary) { item.Value.RecalculateValue(); }
|
|
||||||
}
|
|
||||||
/// <summary> 查询容器 </summary>
|
|
||||||
public AttributeContainer FindContainer(string containerID) {
|
|
||||||
if (!dictionary.ContainsKey(containerID)) { return new(); }
|
|
||||||
return dictionary[containerID];
|
|
||||||
}
|
|
||||||
/// <summary> 查询容器 </summary>
|
|
||||||
public bool TryContainer(string containerID, out AttributeContainer container) {
|
|
||||||
container = null;
|
|
||||||
if (!dictionary.ContainsKey(containerID)) { return false; }
|
|
||||||
container = dictionary[containerID];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 828a59f9caabfb340aa07273f42ccfa4
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 属性类型
|
|
||||||
/// </summary>
|
|
||||||
public enum AttributeType {
|
|
||||||
/// <summary> 浮点数值 </summary>
|
|
||||||
Float,
|
|
||||||
/// <summary> 整数值 </summary>
|
|
||||||
Integer,
|
|
||||||
/// <summary> 布尔值 </summary>
|
|
||||||
Boolean,
|
|
||||||
/// <summary> 百分比值 </summary>
|
|
||||||
Percentage
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: bdb0856dce49d2a4cae5b351eed7ef48
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
.acce-preview {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.acce-hide {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6f6de86e3bf3ec348a2cfde1e36e77bd
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
disableValidation: 0
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
|
||||||
<ui:Template name="AttributeTemplate" src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeTemplate.uxml?fileID=9197481963319205126&guid=1749a10e5ffdea045b442dfa323e4028&type=3#AttributeTemplate" />
|
|
||||||
<Style src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeContainerConstEditor.uss?fileID=7433441132597879392&guid=6f6de86e3bf3ec348a2cfde1e36e77bd&type=3#AttributeContainerConstEditor" />
|
|
||||||
<ui:VisualElement name="AttributeList" style="flex-grow: 1;">
|
|
||||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" class="acce-preview" />
|
|
||||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
|
||||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" class="acce-hide" />
|
|
||||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
<ui:VisualElement name="ButtonGroup" style="flex-direction: row; justify-content: space-between;">
|
|
||||||
<ui:Button text="创建属性" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button1" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
|
||||||
<ui:Button text="删除全部属性" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button2" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 95527f76fc8930d4ab47213114a5952b
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
|
||||||
<Style src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeContainerConstEditor.uss?fileID=7433441132597879392&guid=6f6de86e3bf3ec348a2cfde1e36e77bd&type=3#AttributeContainerConstEditor" />
|
|
||||||
<ui:VisualElement style="flex-direction: row; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; background-color: rgb(51, 51, 51); margin-top: 1px; margin-right: 1px; margin-bottom: 1px; margin-left: 1px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;">
|
|
||||||
<ui:TextField picking-mode="Ignore" value="filler text" keyboard-type="Default" name="Name" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
|
||||||
<ui:EnumField type="UnityEngine.TextAlignment, UnityEngine.TextRenderingModule" value="Center" name="Type" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
|
||||||
<ui:Toggle name="Boolean" style="flex-grow: 1;" />
|
|
||||||
<ui:FloatField value="42.2" name="Value" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
|
||||||
<ui:Label tabindex="-1" text="0-9999" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Range" style="width: 100px; -unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1749a10e5ffdea045b442dfa323e4028
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b88d603d14ca15f4e9bbd6ebc99e332f
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 51817b5555c3c584f846b2c05b877f72
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
disableValidation: 0
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
|
||||||
<Style src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeInstanceConstEditor/AttributeInstanceConstEditor.uss?fileID=7433441132597879392&guid=51817b5555c3c584f846b2c05b877f72&type=3#AttributeInstanceConstEditor" />
|
|
||||||
<ui:VisualElement name="AttributePanel" style="flex-direction: row; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; background-color: rgb(51, 51, 51); margin-top: 1px; margin-right: 1px; margin-bottom: 1px; margin-left: 1px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;">
|
|
||||||
<ui:TextField picking-mode="Ignore" value="filler text" keyboard-type="Default" name="Name" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
|
||||||
<ui:EnumField type="UnityEngine.TextAlignment, UnityEngine.TextRenderingModule" value="Center" name="Type" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
|
||||||
<ui:Toggle name="Boolean" style="flex-grow: 1;" />
|
|
||||||
<ui:FloatField value="42.2" name="Value" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
|
||||||
<ui:Label tabindex="-1" text="0-9999" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Range" style="width: 100px; -unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
<ui:VisualElement style="flex-direction: row; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; background-color: rgb(51, 51, 51); margin-top: 1px; margin-right: 1px; margin-bottom: 1px; margin-left: 1px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;">
|
|
||||||
<ui:FloatField value="42.2" name="Min" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
|
||||||
<ui:Label tabindex="-1" text="min ~ max" parse-escape-sequences="true" display-tooltip-when-elided="true" style="width: 100px; -unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
|
|
||||||
<ui:FloatField value="42.2" name="Max" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
<ui:Button text="删除" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
|
||||||
</ui:UXML>
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 01bc614c0c779d148afa254dbde22ec8
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 材料 - 物品常量
|
|
||||||
/// </summary>
|
|
||||||
[CreateAssetMenu(menuName = "MuHua/物品系统/材料")]
|
|
||||||
public class ConstMaterial : InventoryItemConst {
|
|
||||||
/// <summary> 最大堆叠数 </summary>
|
|
||||||
public int maxStack = 99;
|
|
||||||
|
|
||||||
public override InventoryItem To() {
|
|
||||||
DataMaterial item = new DataMaterial();
|
|
||||||
item.name = name;
|
|
||||||
item.sprite = sprite;
|
|
||||||
item.maxStack = maxStack;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5592cd11563474d42a1f6805b66f7a1f
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -15,5 +15,5 @@ public class EquipmentAffix {
|
|||||||
/// <summary> 最小值 </summary>
|
/// <summary> 最小值 </summary>
|
||||||
public float maxValue = float.MaxValue;
|
public float maxValue = float.MaxValue;
|
||||||
/// <summary> 属性类型 </summary>
|
/// <summary> 属性类型 </summary>
|
||||||
public AttributeType attributeType;
|
public ValueType attributeType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 装备栏
|
||||||
|
/// </summary>
|
||||||
|
public class EquipmentColumn {
|
||||||
|
/// <summary> 插槽字典 </summary>
|
||||||
|
public Dictionary<string, EquipmentSlot> dictionary = new Dictionary<string, EquipmentSlot>();
|
||||||
|
|
||||||
|
/// <summary> 索引器 </summary>
|
||||||
|
public EquipmentSlot this[string key] => dictionary[key];
|
||||||
|
|
||||||
|
public EquipmentColumn() {
|
||||||
|
// AddSlot(WeaponSlot());
|
||||||
|
// AddSlot(DeputySlot());
|
||||||
|
|
||||||
|
// AddSlot(ArmorSlot(EquipmentSlotType.上衣, ArmorType.上衣));
|
||||||
|
// AddSlot(ArmorSlot(EquipmentSlotType.头盔, ArmorType.头盔));
|
||||||
|
// AddSlot(ArmorSlot(EquipmentSlotType.手套, ArmorType.手套));
|
||||||
|
// AddSlot(ArmorSlot(EquipmentSlotType.腰带, ArmorType.腰带));
|
||||||
|
// AddSlot(ArmorSlot(EquipmentSlotType.鞋子, ArmorType.鞋子));
|
||||||
|
|
||||||
|
// AddSlot(AccessorySlot(EquipmentSlotType.项链, AccessoryType.项链));
|
||||||
|
// AddSlot(AccessorySlot(EquipmentSlotType.戒指1, AccessoryType.戒指));
|
||||||
|
// AddSlot(AccessorySlot(EquipmentSlotType.戒指2, AccessoryType.戒指));
|
||||||
|
// AddSlot(AccessorySlot(EquipmentSlotType.手镯1, AccessoryType.手镯));
|
||||||
|
// AddSlot(AccessorySlot(EquipmentSlotType.手镯2, AccessoryType.手镯));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string key) => dictionary.ContainsKey(key);
|
||||||
|
/// <summary> 添加插槽 </summary>
|
||||||
|
public void AddSlot(EquipmentSlot slot) => dictionary.Add(slot.name, slot);
|
||||||
|
|
||||||
|
// /// <summary> 武器插槽 </summary>
|
||||||
|
// public EquipmentSlot WeaponSlot() {
|
||||||
|
// return new EquipmentSlot(EquipmentSlotType.主手, VerifyWeapon);
|
||||||
|
// }
|
||||||
|
// /// <summary> 副手插槽 </summary>
|
||||||
|
// public EquipmentSlot DeputySlot() {
|
||||||
|
// return new EquipmentSlot(EquipmentSlotType.副手, VerifyDeputy);
|
||||||
|
// }
|
||||||
|
// /// <summary> 护甲插槽 </summary>
|
||||||
|
// public EquipmentSlot ArmorSlot(EquipmentSlotType type, ArmorType armor) {
|
||||||
|
// return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, armor.ToString()));
|
||||||
|
// }
|
||||||
|
// /// <summary> 饰品插槽 </summary>
|
||||||
|
// public EquipmentSlot AccessorySlot(EquipmentSlotType type, AccessoryType accessory) {
|
||||||
|
// return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, accessory.ToString()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
/// <summary> 通用校验 </summary>
|
||||||
|
// public static bool VerifyCommon(Equipment equipment, string type) {
|
||||||
|
// string[] types = equipment.type.Split("/");
|
||||||
|
// if (types[0] == type) { return true; }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
/// <summary> 主手校验 </summary>
|
||||||
|
// public static bool VerifyWeapon(Equipment equipment) {
|
||||||
|
// string[] type = equipment.type.Split("/");
|
||||||
|
// if (type[0] == WeaponType.单手.ToString()) { return true; }
|
||||||
|
// if (type[0] == WeaponType.双手.ToString()) { return true; }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
/// <summary> 副手校验 </summary>
|
||||||
|
// public static bool VerifyDeputy(Equipment equipment) {
|
||||||
|
// string[] type = equipment.type.Split("/");
|
||||||
|
// if (type[0] == WeaponType.副手.ToString()) { return true; }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -10,11 +10,11 @@ public class AccessoryConst : EquipmentConst {
|
|||||||
/// <summary> 饰品类型 </summary>
|
/// <summary> 饰品类型 </summary>
|
||||||
public AccessoryType type;
|
public AccessoryType type;
|
||||||
|
|
||||||
public override InventoryItem To() {
|
// public override InventoryItem To() {
|
||||||
Equipment item = new Equipment();
|
// Equipment item = new Equipment();
|
||||||
item.name = name;
|
// item.name = name;
|
||||||
item.sprite = sprite;
|
// item.sprite = sprite;
|
||||||
item.type = type.ToString();
|
// item.type = type.ToString();
|
||||||
return item;
|
// return item;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ public class ArmorConst : EquipmentConst {
|
|||||||
/// <summary> 护甲类型 </summary>
|
/// <summary> 护甲类型 </summary>
|
||||||
public ArmorType type;
|
public ArmorType type;
|
||||||
|
|
||||||
public override InventoryItem To() {
|
// public override InventoryItem To() {
|
||||||
Equipment item = new Equipment();
|
// Equipment item = new Equipment();
|
||||||
item.name = name;
|
// item.name = name;
|
||||||
item.sprite = sprite;
|
// item.sprite = sprite;
|
||||||
item.type = type.ToString();
|
// item.type = type.ToString();
|
||||||
return item;
|
// return item;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ public class WeaponConst : EquipmentConst {
|
|||||||
/// <summary> 武器类型 </summary>
|
/// <summary> 武器类型 </summary>
|
||||||
public WeaponCategory category;
|
public WeaponCategory category;
|
||||||
|
|
||||||
public override InventoryItem To() {
|
// public override InventoryItem To() {
|
||||||
Equipment item = new Equipment();
|
// Equipment item = new Equipment();
|
||||||
item.name = name;
|
// item.name = name;
|
||||||
item.sprite = sprite;
|
// item.sprite = sprite;
|
||||||
item.type = $"{type}/{category}";
|
// item.type = $"{type}/{category}";
|
||||||
return item;
|
// return item;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
-unity-font-style: bold;
|
-unity-font-style: bold;
|
||||||
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
||||||
-unity-font-definition: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF");
|
-unity-font-definition: url('project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF');
|
||||||
}
|
}
|
||||||
|
|
||||||
.ep-separate-label {
|
.ep-separate-label {
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
padding-left: 2px;
|
padding-left: 2px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
||||||
-unity-font-definition: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF");
|
-unity-font-definition: url('project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF');
|
||||||
-unity-font-style: normal;
|
-unity-font-style: normal;
|
||||||
|
-unity-background-image-tint-color: rgb(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d3a7044b333aacb4286fef636118cfec
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 装备
|
|
||||||
/// </summary>
|
|
||||||
public class Equipment : InventoryItem {
|
|
||||||
/// <summary>
|
|
||||||
/// 装备类型:稀有度/装备类型/次级类型/种类
|
|
||||||
/// <br/>稀有度:普通,精良,稀有,史诗,传奇,神话
|
|
||||||
/// <br/>装备类型:武器,护甲,饰品
|
|
||||||
/// <br/>次级类型:单手,副手,双手,上衣,头盔,手套,腰带,鞋子,项链,戒指,手镯
|
|
||||||
/// <br/>装备种类:剑,锤,枪,弓,斧头,盾牌,法杖,魔杖
|
|
||||||
/// </summary>
|
|
||||||
public string type;
|
|
||||||
/// <summary> 词缀列表 </summary>
|
|
||||||
public List<EquipmentAffix> affixes = new List<EquipmentAffix>();
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 装备栏
|
|
||||||
/// </summary>
|
|
||||||
public class EquipmentColumn {
|
|
||||||
/// <summary> 插槽字典 </summary>
|
|
||||||
public Dictionary<string, EquipmentSlot> dictionary = new Dictionary<string, EquipmentSlot>();
|
|
||||||
|
|
||||||
/// <summary> 索引器 </summary>
|
|
||||||
public EquipmentSlot this[string key] => dictionary[key];
|
|
||||||
|
|
||||||
public EquipmentColumn() {
|
|
||||||
AddSlot(WeaponSlot());
|
|
||||||
AddSlot(DeputySlot());
|
|
||||||
|
|
||||||
AddSlot(ArmorSlot(EquipmentSlotType.上衣, ArmorType.上衣));
|
|
||||||
AddSlot(ArmorSlot(EquipmentSlotType.头盔, ArmorType.头盔));
|
|
||||||
AddSlot(ArmorSlot(EquipmentSlotType.手套, ArmorType.手套));
|
|
||||||
AddSlot(ArmorSlot(EquipmentSlotType.腰带, ArmorType.腰带));
|
|
||||||
AddSlot(ArmorSlot(EquipmentSlotType.鞋子, ArmorType.鞋子));
|
|
||||||
|
|
||||||
AddSlot(AccessorySlot(EquipmentSlotType.项链, AccessoryType.项链));
|
|
||||||
AddSlot(AccessorySlot(EquipmentSlotType.戒指1, AccessoryType.戒指));
|
|
||||||
AddSlot(AccessorySlot(EquipmentSlotType.戒指2, AccessoryType.戒指));
|
|
||||||
AddSlot(AccessorySlot(EquipmentSlotType.手镯1, AccessoryType.手镯));
|
|
||||||
AddSlot(AccessorySlot(EquipmentSlotType.手镯2, AccessoryType.手镯));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ContainsKey(string key) => dictionary.ContainsKey(key);
|
|
||||||
/// <summary> 添加插槽 </summary>
|
|
||||||
public void AddSlot(EquipmentSlot slot) => dictionary.Add(slot.name, slot);
|
|
||||||
|
|
||||||
/// <summary> 武器插槽 </summary>
|
|
||||||
public EquipmentSlot WeaponSlot() {
|
|
||||||
return new EquipmentSlot(EquipmentSlotType.主手, VerifyWeapon);
|
|
||||||
}
|
|
||||||
/// <summary> 副手插槽 </summary>
|
|
||||||
public EquipmentSlot DeputySlot() {
|
|
||||||
return new EquipmentSlot(EquipmentSlotType.副手, VerifyDeputy);
|
|
||||||
}
|
|
||||||
/// <summary> 护甲插槽 </summary>
|
|
||||||
public EquipmentSlot ArmorSlot(EquipmentSlotType type, ArmorType armor) {
|
|
||||||
return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, armor.ToString()));
|
|
||||||
}
|
|
||||||
/// <summary> 饰品插槽 </summary>
|
|
||||||
public EquipmentSlot AccessorySlot(EquipmentSlotType type, AccessoryType accessory) {
|
|
||||||
return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, accessory.ToString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 通用校验 </summary>
|
|
||||||
public static bool VerifyCommon(Equipment equipment, string type) {
|
|
||||||
string[] types = equipment.type.Split("/");
|
|
||||||
if (types[0] == type) { return true; }
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/// <summary> 主手校验 </summary>
|
|
||||||
public static bool VerifyWeapon(Equipment equipment) {
|
|
||||||
string[] type = equipment.type.Split("/");
|
|
||||||
if (type[0] == WeaponType.单手.ToString()) { return true; }
|
|
||||||
if (type[0] == WeaponType.双手.ToString()) { return true; }
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/// <summary> 副手校验 </summary>
|
|
||||||
public static bool VerifyDeputy(Equipment equipment) {
|
|
||||||
string[] type = equipment.type.Split("/");
|
|
||||||
if (type[0] == WeaponType.副手.ToString()) { return true; }
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 装备插槽
|
|
||||||
/// </summary>
|
|
||||||
public class EquipmentSlot {
|
|
||||||
/// <summary> 名字 </summary>
|
|
||||||
public string name;
|
|
||||||
/// <summary> 物品 </summary>
|
|
||||||
public Equipment item;
|
|
||||||
/// <summary> 装备验证 </summary>
|
|
||||||
public Func<Equipment, bool> verify;
|
|
||||||
|
|
||||||
public EquipmentSlot(EquipmentSlotType slot, Func<Equipment, bool> verify) {
|
|
||||||
name = slot.ToString();
|
|
||||||
this.verify = verify;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 设置 </summary>
|
|
||||||
public void Settings(InventoryItem item) {
|
|
||||||
if (item is Equipment equipment) { this.item = equipment; }
|
|
||||||
else { this.item = null; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 材料 - 物品
|
|
||||||
/// </summary>
|
|
||||||
public class DataMaterial : InventoryItem {
|
|
||||||
/// <summary> 最大堆叠数 </summary>
|
|
||||||
public int maxStack;
|
|
||||||
|
|
||||||
public override int MaxStack => maxStack;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fc5511946a6586b42a9a026b078f6736
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物品
|
|
||||||
/// </summary>
|
|
||||||
public class InventoryItem {
|
|
||||||
/// <summary> 名字 </summary>
|
|
||||||
public string name;
|
|
||||||
/// <summary> 图片 </summary>
|
|
||||||
public Sprite sprite;
|
|
||||||
|
|
||||||
/// <summary> 堆叠数量 </summary>
|
|
||||||
public virtual int MaxStack => 1;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 库存插槽
|
|
||||||
/// </summary>
|
|
||||||
public class InventorySlot {
|
|
||||||
/// <summary> 数量 </summary>
|
|
||||||
public int count;
|
|
||||||
/// <summary> 物品 </summary>
|
|
||||||
public InventoryItem item;
|
|
||||||
|
|
||||||
// /// <summary> 图片 </summary>
|
|
||||||
public Sprite Sprite => item != null ? item.sprite : null;
|
|
||||||
// /// <summary> 堆叠数量 </summary>
|
|
||||||
public int MaxStack => item != null ? item.MaxStack : 0;
|
|
||||||
|
|
||||||
public InventorySlot() { }
|
|
||||||
|
|
||||||
public InventorySlot(InventoryItem item, int count) {
|
|
||||||
this.item = item;
|
|
||||||
this.count = count;
|
|
||||||
}
|
|
||||||
/// <summary> 设置 </summary>
|
|
||||||
public void Settings(InventoryItem item, int count) {
|
|
||||||
this.item = item;
|
|
||||||
this.count = count;
|
|
||||||
}
|
|
||||||
/// <summary> 是否相同 </summary>
|
|
||||||
public bool Same(InventoryItem obj) {
|
|
||||||
return item != null && item.name == obj.name && count < MaxStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 253123fa56cb88f4e969b587327d3f7f
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c87e8c5e71a81ec459fc58f79c0ab960
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -22,8 +22,7 @@ public class ValueContainer {
|
|||||||
|
|
||||||
/// <summary> 添加数值 </summary>
|
/// <summary> 添加数值 </summary>
|
||||||
public void AddInstance(ValueType type, Enum name) {
|
public void AddInstance(ValueType type, Enum name) {
|
||||||
var instance = ValueInstance.Create(type, name);
|
AddInstance(type, name.ToString());
|
||||||
AddInstance(instance);
|
|
||||||
}
|
}
|
||||||
/// <summary> 添加数值 </summary>
|
/// <summary> 添加数值 </summary>
|
||||||
public void AddInstance(ValueType type, string name) {
|
public void AddInstance(ValueType type, string name) {
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ public class ValueInstance {
|
|||||||
/// <summary> 是布尔值 </summary>
|
/// <summary> 是布尔值 </summary>
|
||||||
public bool IsBoolean => type == ValueType.Boolean && CurrentValue == MaxValue;
|
public bool IsBoolean => type == ValueType.Boolean && CurrentValue == MaxValue;
|
||||||
|
|
||||||
/// <summary> 创建数值(用枚举命名) </summary>
|
|
||||||
public static ValueInstance Create(ValueType type, Enum name) {
|
|
||||||
return Create(type, name.ToString());
|
|
||||||
}
|
|
||||||
/// <summary> 创建数值 </summary>
|
/// <summary> 创建数值 </summary>
|
||||||
public static ValueInstance Create(ValueType type, string name) {
|
public static ValueInstance Create(ValueType type, string name) {
|
||||||
ValueInstance instance = new ValueInstance(type, name);
|
ValueInstance instance = new ValueInstance(type, name);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: c3fd76fa2f8dd174cbb580a5890fd90d
|
guid: 0da8a4dca50a74f44849401c83183656
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d96c081aa34edfb4d9197a0bfb23858c
|
guid: 72ef5f444f08d9944aa8697f79587742
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 51b8c6d3c0b5b3d459dca741e39b455e
|
guid: 433dad305e9f6a04192df8cb02823338
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0d2605ccaa6985d4e9296b749694fc1d
|
guid: 208e1f401d398674c8ee21270c8a4870
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 装备栏
|
||||||
|
/// 装备类型:稀有度/装备类型/次级类型/种类
|
||||||
|
/// <br/>稀有度:普通,精良,稀有,史诗,传奇,神话
|
||||||
|
/// <br/>装备类型:武器,护甲,饰品
|
||||||
|
/// <br/>次级类型:单手,副手,双手,上衣,头盔,手套,腰带,鞋子,项链,戒指,手镯
|
||||||
|
/// <br/>装备种类:剑,锤,枪,弓,斧头,盾牌,法杖,魔杖
|
||||||
|
/// </summary>
|
||||||
|
public class Equipment {
|
||||||
|
/// <summary> 插槽字典 </summary>
|
||||||
|
public Dictionary<string, InventorySlot> dictionary = new Dictionary<string, InventorySlot>();
|
||||||
|
|
||||||
|
/// <summary> 索引器 </summary>
|
||||||
|
public InventorySlot this[string key] => dictionary[key];
|
||||||
|
/// <summary> 索引器(枚举) </summary>
|
||||||
|
public InventorySlot this[Enum key] => dictionary[key.ToString()];
|
||||||
|
|
||||||
|
/// <summary> 遍历数组 </summary>
|
||||||
|
public void ForEach(Action<string, InventorySlot> action) {
|
||||||
|
foreach (var item in dictionary) { action?.Invoke(item.Key, item.Value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 添加插槽 </summary>
|
||||||
|
public void AddSlot(Enum name, string type) {
|
||||||
|
AddSlot(name.ToString(), type);
|
||||||
|
}
|
||||||
|
/// <summary> 添加插槽 </summary>
|
||||||
|
public void AddSlot(string name, string type) {
|
||||||
|
var slot = new InventorySlot();
|
||||||
|
slot.name = name;
|
||||||
|
slot.limits = new List<string>(type.Split("/"));
|
||||||
|
AddSlot(slot);
|
||||||
|
}
|
||||||
|
/// <summary> 添加插槽 </summary>
|
||||||
|
public void AddSlot(InventorySlot slot) {
|
||||||
|
if (dictionary.ContainsKey(slot.name)) { return; }
|
||||||
|
dictionary.Add(slot.name, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 装备物品
|
||||||
|
/// </summary>
|
||||||
|
public class EquipmentItem : InventoryItem {
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 23403840a9d12654f8f15c6188728498
|
guid: d13e432b42e13064e867855fc64ed2fb
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 装备插槽
|
||||||
|
/// </summary>
|
||||||
|
public class EquipmentSlot {
|
||||||
|
/// <summary> 数量 </summary>
|
||||||
|
public int count;
|
||||||
|
/// <summary> 名字 </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary> 物品 </summary>
|
||||||
|
public InventoryItem item;
|
||||||
|
/// <summary> 限制类型 </summary>
|
||||||
|
public List<string> limits = new List<string>();
|
||||||
|
|
||||||
|
/// <summary> 堆叠数量 </summary>
|
||||||
|
public int MaxStack => item != null ? item.stack : 0;
|
||||||
|
/// <summary> 图片 </summary>
|
||||||
|
public Sprite Sprite => item != null ? item.sprite : null;
|
||||||
|
|
||||||
|
/// <summary> 验证类型 </summary>
|
||||||
|
public bool Verify(InventoryItem item) {
|
||||||
|
string[] types = item.type.Split("/");
|
||||||
|
return limits.All(item => types.Contains(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 替换 </summary>
|
||||||
|
public (InventoryItem, int) Replace(InventoryItem newItem, int count) {
|
||||||
|
int remain = this.count;
|
||||||
|
InventoryItem old = item;
|
||||||
|
item = newItem;
|
||||||
|
this.count = count;
|
||||||
|
return (old, remain);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: ccf9ef6e831628349a83b354e196e98d
|
guid: 2028616bbe0eeae49b4ee5091cd2b903
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: dbe28b450df84584cb523a09c813e59b
|
guid: f209f33e3d6c87d438a800a2929261c6
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+26
-25
@@ -18,51 +18,52 @@ public class Inventory {
|
|||||||
/// <summary> 物品库存 </summary>
|
/// <summary> 物品库存 </summary>
|
||||||
public Inventory(int capacity) {
|
public Inventory(int capacity) {
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
slots = new List<InventorySlot>();
|
IEnumerable<int> enumerable = Enumerable.Range(0, capacity);
|
||||||
for (int i = 0; i < capacity; i++) { slots.Add(new InventorySlot()); }
|
slots = enumerable.Select(_ => new InventorySlot()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> 应用修改 </summary>
|
/// <summary> 应用修改 </summary>
|
||||||
public void Apply() => OnChange?.Invoke(this);
|
public void Apply() => OnChange?.Invoke(this);
|
||||||
/// <summary> 遍历数组 </summary>
|
/// <summary> 遍历数组 </summary>
|
||||||
public void ForEach(Action<InventorySlot> action) => slots.ForEach(action);
|
public void ForEach(Action<InventorySlot> action) => slots.ForEach(action);
|
||||||
|
/// <summary> 获取一个空插槽 </summary>
|
||||||
|
public InventorySlot Empty() => slots.FirstOrDefault(s => s.item == null);
|
||||||
|
/// <summary> 相同堆叠插槽 </summary>
|
||||||
|
public List<InventorySlot> Stackable(InventoryItem item) => slots.Where(slot => slot.IsStackable(item)).ToList();
|
||||||
|
|
||||||
/// <summary> 添加物品 </summary>
|
/// <summary> 添加物品 </summary>
|
||||||
public void AddItem(InventoryItem item, int count) {
|
public void AddItem(InventoryItem item, int count) {
|
||||||
|
// 合并重复可堆叠
|
||||||
int remain = MergeToSlots(item, count);
|
int remain = MergeToSlots(item, count);
|
||||||
// 如果还有剩余,按照MaxStack分批放入空位
|
// 如果还有剩余,按照MaxStack分批放入空位
|
||||||
if (remain > 0) { AddToSlots(item, remain, true); }
|
if (remain > 0) { AddToSlots(item, remain, true); }
|
||||||
OnChange?.Invoke(this);
|
OnChange?.Invoke(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> 添加物品 </summary>
|
|
||||||
public void AddToSlots(InventoryItem item, int count, bool isWhile) {
|
|
||||||
(bool isComplete, int remain) = AddToSlots(item, count);
|
|
||||||
if (!isComplete || remain == 0 || !isWhile) { return; }
|
|
||||||
AddToSlots(item, remain, isWhile);
|
|
||||||
}
|
|
||||||
/// <summary> 添加到插槽 bool = 是否添加成功,int = 余量 </summary>
|
|
||||||
public (bool, int) AddToSlots(InventoryItem item, int count) {
|
|
||||||
InventorySlot emptySlot = slots.FirstOrDefault(s => s.item == null);
|
|
||||||
if (emptySlot == null) { return (false, count); }
|
|
||||||
int addCount = Mathf.Min(count, item.MaxStack);
|
|
||||||
emptySlot.Settings(item, addCount);
|
|
||||||
return (true, count - addCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 合并到插槽 </summary>
|
/// <summary> 合并到插槽 </summary>
|
||||||
public int MergeToSlots(InventoryItem item, int count) {
|
public int MergeToSlots(InventoryItem item, int count) {
|
||||||
// 查询所有可合并的插槽
|
// 查询所有可合并的插槽
|
||||||
List<InventorySlot> sameSlots = slots.Where(slot => slot.Same(item)).ToList();
|
var sameSlots = Stackable(item);
|
||||||
// 合并到已有插槽
|
// 合并到已有插槽
|
||||||
sameSlots.ForEach(obj => MergeToSlots(obj, ref count));
|
sameSlots.ForEach(obj => obj.Settings(ref count));
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
/// <summary> 合并到插槽 </summary>
|
|
||||||
public void MergeToSlots(InventorySlot slot, ref int count) {
|
/// <summary> 添加物品 </summary>
|
||||||
int canAdd = slot.MaxStack - slot.count;
|
public void AddToSlots(InventoryItem item, int count, bool isWhile) {
|
||||||
int addCount = Mathf.Min(canAdd, count);
|
// 取一个空插槽
|
||||||
slot.count += addCount;
|
InventorySlot emptySlot = Empty();
|
||||||
count -= addCount;
|
// 没有空插槽则退出
|
||||||
|
if (emptySlot == null) { return; }
|
||||||
|
// 堆叠数量 = Min(物品数量 , 最大堆叠数量)
|
||||||
|
int addCount = Mathf.Min(count, item.stack);
|
||||||
|
// 计算剩余物品数量
|
||||||
|
int remain = count - addCount;
|
||||||
|
// 填充进空插槽
|
||||||
|
emptySlot.Settings(item, addCount);
|
||||||
|
// 没有剩余或者不循环则退出
|
||||||
|
if (remain == 0 || !isWhile) { return; }
|
||||||
|
// 还有余量循环执行添加
|
||||||
|
AddToSlots(item, remain, isWhile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存物品
|
||||||
|
/// </summary>
|
||||||
|
public class InventoryItem {
|
||||||
|
/// <summary> 堆叠数量 </summary>
|
||||||
|
public int stack = 1;
|
||||||
|
/// <summary> 名字 </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary> 类型 </summary>
|
||||||
|
public string type;
|
||||||
|
/// <summary> 图片 </summary>
|
||||||
|
public Sprite sprite;
|
||||||
|
/// <summary> 预制件 </summary>
|
||||||
|
public Transform prefabs;
|
||||||
|
|
||||||
|
/// <summary> 是否可堆叠 </summary>
|
||||||
|
public virtual bool IsStackable(InventoryItem item) {
|
||||||
|
return name == item.name && type == item.type && stack > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存插槽
|
||||||
|
/// </summary>
|
||||||
|
public class InventorySlot {
|
||||||
|
/// <summary> 数量 </summary>
|
||||||
|
public int count;
|
||||||
|
/// <summary> 名字 </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary> 物品 </summary>
|
||||||
|
public InventoryItem item;
|
||||||
|
/// <summary> 限制类型 </summary>
|
||||||
|
public List<string> limits = new List<string>();
|
||||||
|
|
||||||
|
/// <summary> 图片 </summary>
|
||||||
|
public Sprite Sprite => item != null ? item.sprite : null;
|
||||||
|
/// <summary> 堆叠数量 </summary>
|
||||||
|
public int MaxStack => item != null ? item.stack : 0;
|
||||||
|
|
||||||
|
/// <summary> 添加物品数量 </summary>
|
||||||
|
public virtual void Settings(ref int count) {
|
||||||
|
// 剩余容量
|
||||||
|
int canAdd = MaxStack - count;
|
||||||
|
// 剩余容量和余数取最小值
|
||||||
|
int addCount = Mathf.Min(canAdd, count);
|
||||||
|
this.count += addCount;
|
||||||
|
count -= addCount;
|
||||||
|
}
|
||||||
|
/// <summary> 设置物品 </summary>
|
||||||
|
public virtual void Settings(InventoryItem item, int count) {
|
||||||
|
this.item = item;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
/// <summary> 替换物品 </summary>
|
||||||
|
public virtual (InventoryItem, int) Replace(InventoryItem item, int count) {
|
||||||
|
int remain = this.count; this.count = count;
|
||||||
|
InventoryItem old = this.item; this.item = item;
|
||||||
|
return (old, remain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 验证类型 </summary>
|
||||||
|
public bool Verify(InventoryItem item) {
|
||||||
|
string[] types = item.type.Split("/");
|
||||||
|
return limits.All(item => types.Contains(item));
|
||||||
|
}
|
||||||
|
/// <summary> 是否可堆叠 </summary>
|
||||||
|
public virtual bool IsStackable(InventoryItem obj) {
|
||||||
|
return item != null && item.IsStackable(obj) && count < MaxStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 535afb79004b58e43a958d46e4f3eb20
|
guid: fe0baa2925c37174b9ef2beaaf767a87
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -7,8 +7,6 @@ using MuHua;
|
|||||||
/// 物品 - 管理器
|
/// 物品 - 管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ManagerItem : ModuleSingle<ManagerItem> {
|
public class ManagerItem : ModuleSingle<ManagerItem> {
|
||||||
/// <summary> 材料列表 </summary>
|
|
||||||
public List<ConstMaterial> materials;
|
|
||||||
/// <summary> 装备列表 </summary>
|
/// <summary> 装备列表 </summary>
|
||||||
public List<EquipmentConst> equipments;
|
public List<EquipmentConst> equipments;
|
||||||
|
|
||||||
+4
-4
@@ -9,7 +9,7 @@ using MuHua;
|
|||||||
public class SingleManager : ModuleSingle<SingleManager> {
|
public class SingleManager : ModuleSingle<SingleManager> {
|
||||||
|
|
||||||
public Inventory inventory;
|
public Inventory inventory;
|
||||||
public EquipmentColumn equipment;
|
public Equipment equipment;
|
||||||
|
|
||||||
public ItemReward materialReward;
|
public ItemReward materialReward;
|
||||||
public ItemReward equipmentReward;
|
public ItemReward equipmentReward;
|
||||||
@@ -18,10 +18,10 @@ public class SingleManager : ModuleSingle<SingleManager> {
|
|||||||
|
|
||||||
private void Start() {
|
private void Start() {
|
||||||
inventory = new Inventory(40);
|
inventory = new Inventory(40);
|
||||||
equipment = new EquipmentColumn();
|
equipment = new Equipment();
|
||||||
|
|
||||||
materialReward = new ItemReward();
|
// materialReward = new ItemReward();
|
||||||
materialReward.Settings(ManagerItem.I.materials);
|
// materialReward.Settings(ManagerItem.I.materials);
|
||||||
equipmentReward = new ItemReward();
|
equipmentReward = new ItemReward();
|
||||||
equipmentReward.Settings(ManagerItem.I.equipments);
|
equipmentReward.Settings(ManagerItem.I.equipments);
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 34e0f6e731b56d54db838c594430c73b
|
guid: d463f9d3a18472e4a8b1ae848efb4354
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+9
-9
@@ -7,13 +7,13 @@ using MuHua;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// UI装备栏
|
/// UI装备栏
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UIEquipmentColumn : ModuleUIPanel {
|
public class UIEquipment : ModuleUIPanel {
|
||||||
|
|
||||||
public EquipmentColumn equipment;
|
public Equipment equipment;
|
||||||
/// <summary> 插槽字典 </summary>
|
/// <summary> 插槽字典 </summary>
|
||||||
public Dictionary<string, UIEquipmentSlot> dictionary = new Dictionary<string, UIEquipmentSlot>();
|
public Dictionary<string, UIEquipmentSlot> dictionary = new Dictionary<string, UIEquipmentSlot>();
|
||||||
|
|
||||||
public UIEquipmentColumn(VisualElement element) : base(element) {
|
public UIEquipment(VisualElement element) : base(element) {
|
||||||
InitialSlot(1, EquipmentSlotType.主手);
|
InitialSlot(1, EquipmentSlotType.主手);
|
||||||
InitialSlot(2, EquipmentSlotType.副手);
|
InitialSlot(2, EquipmentSlotType.副手);
|
||||||
InitialSlot(3, EquipmentSlotType.上衣);
|
InitialSlot(3, EquipmentSlotType.上衣);
|
||||||
@@ -33,16 +33,16 @@ public class UIEquipmentColumn : ModuleUIPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Settings(EquipmentColumn equipment) {
|
public void Settings(Equipment equipment) {
|
||||||
if (this.equipment != null) { Dispose(); }
|
if (this.equipment != null) { Dispose(); }
|
||||||
this.equipment = equipment;
|
this.equipment = equipment;
|
||||||
if (equipment == null) { return; }
|
if (equipment == null) { return; }
|
||||||
foreach (var item in dictionary) { Settings(item.Key, item.Value); }
|
equipment.ForEach(Settings);
|
||||||
}
|
}
|
||||||
public void Settings(string key, UIEquipmentSlot uISlot) {
|
public void Settings(string key, InventorySlot slot) {
|
||||||
if (!equipment.ContainsKey(key)) { return; }
|
if (!dictionary.ContainsKey(key)) { return; }
|
||||||
EquipmentSlot slot = equipment[key];
|
UIEquipmentSlot uiSlot = dictionary[key];
|
||||||
uISlot.Settings(slot);
|
uiSlot.Settings(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitialSlot(int index, EquipmentSlotType type) {
|
private void InitialSlot(int index, EquipmentSlotType type) {
|
||||||
+4
-4
@@ -9,7 +9,7 @@ using MuHua;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UIEquipmentSlot : ModuleUIPanel, InventoryDrag {
|
public class UIEquipmentSlot : ModuleUIPanel, InventoryDrag {
|
||||||
|
|
||||||
public EquipmentSlot value;
|
public InventorySlot value;
|
||||||
|
|
||||||
public Label CountLabel => Q<Label>("Count");
|
public Label CountLabel => Q<Label>("Count");
|
||||||
public VisualElement Image => Q<VisualElement>("Image");
|
public VisualElement Image => Q<VisualElement>("Image");
|
||||||
@@ -39,12 +39,12 @@ public class UIEquipmentSlot : ModuleUIPanel, InventoryDrag {
|
|||||||
// Debug.Log("sss");
|
// Debug.Log("sss");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Settings(EquipmentSlot value) {
|
public void Settings(InventorySlot value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
}
|
}
|
||||||
public void Settings(InventoryItem item, int count) {
|
public void Settings(InventoryItem item, int count) {
|
||||||
value.Settings(item);
|
value.Settings(item, count);
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
}
|
}
|
||||||
public void Cancel() {
|
public void Cancel() {
|
||||||
@@ -58,7 +58,7 @@ public class UIEquipmentSlot : ModuleUIPanel, InventoryDrag {
|
|||||||
private bool Verify() {
|
private bool Verify() {
|
||||||
InventoryDrag container = UIPopupManager.I.inventoryDrag.container;
|
InventoryDrag container = UIPopupManager.I.inventoryDrag.container;
|
||||||
if (container == null) { return false; }
|
if (container == null) { return false; }
|
||||||
if (container.Item is Equipment equipment) { return value.verify.Invoke(equipment); }
|
// if (container.Item is Equipment equipment) { return value.verify.Invoke(equipment); }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user