重做物品系统
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a2d6badedf74af4a8e4faffb6130a48
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d96c081aa34edfb4d9197a0bfb23858c
|
||||
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,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe28b450df84584cb523a09c813e59b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
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,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51b8c6d3c0b5b3d459dca741e39b455e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23403840a9d12654f8f15c6188728498
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 535afb79004b58e43a958d46e4f3eb20
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34e0f6e731b56d54db838c594430c73b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
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>
|
||||
public float maxValue = float.MaxValue;
|
||||
/// <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>
|
||||
public AccessoryType type;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = type.ToString();
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = type.ToString();
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ public class ArmorConst : EquipmentConst {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType type;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = type.ToString();
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = type.ToString();
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ public class WeaponConst : EquipmentConst {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponCategory category;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = $"{type}/{category}";
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = $"{type}/{category}";
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
font-size: 14px;
|
||||
-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-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 {
|
||||
@@ -24,6 +24,7 @@
|
||||
padding-left: 2px;
|
||||
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-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-background-image-tint-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3a7044b333aacb4286fef636118cfec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d2605ccaa6985d4e9296b749694fc1d
|
||||
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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d078f2759ef3ef4bb65217dd9b2fb94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1d68199e9959734e85efd7a39d4d78c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccf9ef6e831628349a83b354e196e98d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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,68 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物品库存
|
||||
/// </summary>
|
||||
public class Inventory {
|
||||
/// <summary> 背包容量 </summary>
|
||||
public int capacity;
|
||||
/// <summary> 插槽列表 </summary>
|
||||
public List<InventorySlot> slots;
|
||||
/// <summary> 改变事件 </summary>
|
||||
public event Action<Inventory> OnChange;
|
||||
|
||||
/// <summary> 物品库存 </summary>
|
||||
public Inventory(int capacity) {
|
||||
this.capacity = capacity;
|
||||
slots = new List<InventorySlot>();
|
||||
for (int i = 0; i < capacity; i++) { slots.Add(new InventorySlot()); }
|
||||
}
|
||||
|
||||
/// <summary> 应用修改 </summary>
|
||||
public void Apply() => OnChange?.Invoke(this);
|
||||
/// <summary> 遍历数组 </summary>
|
||||
public void ForEach(Action<InventorySlot> action) => slots.ForEach(action);
|
||||
|
||||
/// <summary> 添加物品 </summary>
|
||||
public void AddItem(InventoryItem item, int count) {
|
||||
int remain = MergeToSlots(item, count);
|
||||
// 如果还有剩余,按照MaxStack分批放入空位
|
||||
if (remain > 0) { AddToSlots(item, remain, true); }
|
||||
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>
|
||||
public int MergeToSlots(InventoryItem item, int count) {
|
||||
// 查询所有可合并的插槽
|
||||
List<InventorySlot> sameSlots = slots.Where(slot => slot.Same(item)).ToList();
|
||||
// 合并到已有插槽
|
||||
sameSlots.ForEach(obj => MergeToSlots(obj, ref count));
|
||||
return count;
|
||||
}
|
||||
/// <summary> 合并到插槽 </summary>
|
||||
public void MergeToSlots(InventorySlot slot, ref int count) {
|
||||
int canAdd = slot.MaxStack - slot.count;
|
||||
int addCount = Mathf.Min(canAdd, count);
|
||||
slot.count += addCount;
|
||||
count -= addCount;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 299fd3a7463d8ef46ab2221eca3eeae7
|
||||
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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 427a33328910b764b9014f337267f950
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb28431ab55e034386cfe8f66c0d9f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebf768e6a16ccf04da50e6e25559a8f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 资源管理器
|
||||
/// </summary>
|
||||
public class AssetsManager : ModuleSingle<AssetsManager> {
|
||||
|
||||
public List<InventoryItemConst> items;
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c361800b57f418848ab005dbaca34a7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,35 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 物品 - 管理器
|
||||
/// </summary>
|
||||
public class ManagerItem : ModuleSingle<ManagerItem> {
|
||||
/// <summary> 材料列表 </summary>
|
||||
public List<ConstMaterial> materials;
|
||||
/// <summary> 装备列表 </summary>
|
||||
public List<EquipmentConst> equipments;
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 物品奖励
|
||||
/// </summary>
|
||||
public class ItemReward {
|
||||
/// <summary> 物品列表 </summary>
|
||||
public List<InventoryItem> items;
|
||||
|
||||
public void Settings<T>(List<T> list) where T : InventoryItemConst {
|
||||
items = new List<InventoryItem>();
|
||||
list.ForEach(obj => items.Add(obj.To()));
|
||||
}
|
||||
|
||||
public (InventoryItem, int) Get(int max = 1) {
|
||||
int count = Random.Range(1, max + 1);
|
||||
int index = Random.Range(0, items.Count);
|
||||
return (items[index], count);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 287f1e957d7061a42977427a98b178b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 全局管理器
|
||||
/// </summary>
|
||||
public class SingleManager : ModuleSingle<SingleManager> {
|
||||
|
||||
public Inventory inventory;
|
||||
public EquipmentColumn equipment;
|
||||
|
||||
public ItemReward materialReward;
|
||||
public ItemReward equipmentReward;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Start() {
|
||||
inventory = new Inventory(40);
|
||||
equipment = new EquipmentColumn();
|
||||
|
||||
materialReward = new ItemReward();
|
||||
materialReward.Settings(ManagerItem.I.materials);
|
||||
equipmentReward = new ItemReward();
|
||||
equipmentReward.Settings(ManagerItem.I.equipments);
|
||||
|
||||
UIShortcutMenu shortcutMenu = UIPopupManager.I.shortcutMenu;
|
||||
shortcutMenu.Add("背包", () => { ModuleUI.Settings(Page.Backpack); });
|
||||
shortcutMenu.Add("奖励/材料", RewardMaterial);
|
||||
shortcutMenu.Add("奖励/装备", RewardEquipment);
|
||||
|
||||
ValueSystem.I.Initial();
|
||||
}
|
||||
|
||||
private void RewardMaterial() {
|
||||
(InventoryItem item, int count) = materialReward.Get(10);
|
||||
inventory.AddItem(item, count);
|
||||
}
|
||||
private void RewardEquipment() {
|
||||
(InventoryItem item, int count) = equipmentReward.Get(1);
|
||||
inventory.AddItem(item, count);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50f6b4ec374a86846b626668e0b5627e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 数值系统
|
||||
/// </summary>
|
||||
public class ValueSystem : Module<ValueSystem> {
|
||||
/// <summary> 对战数值 </summary>
|
||||
public ValueContainer battle;
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial() {
|
||||
battle = new ValueContainer();
|
||||
battle.AddInstance(ValueType.Integer, "生命");
|
||||
battle.AddInstance(ValueType.Integer, "金币");
|
||||
battle.AddInstance(ValueType.Integer, "水晶");
|
||||
|
||||
Debug.Log(battle["生命"].value);
|
||||
|
||||
ValueModifier modifier = new ValueModifier { Fixed = 100 };
|
||||
battle["生命"].AddModifier(modifier, true);
|
||||
|
||||
Debug.Log(battle["生命"].value);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9b82c2b1930d5f4b8b002d671c4e28c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0db5829ba53f6da40b31c07ed5a10af6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleUISingle<ModuleUI> {
|
||||
/// <summary> 当前页面 </summary>
|
||||
public static Page Current;
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static Page BackPage;
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
/// <summary> 页面跳转事件 </summary>
|
||||
public static event Action<Page> OnJumpPage;
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Settings(Page pageType) {
|
||||
BackPage = Current;
|
||||
Current = pageType;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static void Back() {
|
||||
Current = BackPage;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 添加控件 </summary>
|
||||
public static void AddControl(UIControl control) {
|
||||
controls.Add(control);
|
||||
}
|
||||
/// <summary> 移除控件 </summary>
|
||||
public static void RemoveControl(UIControl control) {
|
||||
controls.Remove(control);
|
||||
}
|
||||
|
||||
public override VisualElement Element => document.rootVisualElement;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||
}
|
||||
/// <summary>
|
||||
/// 页面
|
||||
/// </summary>
|
||||
public enum Page {
|
||||
/// <summary> 无 </summary>
|
||||
None,
|
||||
/// <summary> 背包 </summary>
|
||||
Backpack,
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea89ac05041b5d74582ee9d0add233ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8f196d318cab0f47a3c84eade044392
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 背包页面
|
||||
/// </summary>
|
||||
public class UIBackpackPage : ModuleUIPage {
|
||||
public VisualTreeAsset inventorySlot;
|
||||
|
||||
private UIInventory inventory;
|
||||
private UIEquipmentColumn equipment;
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("BackpackPage");
|
||||
|
||||
public VisualElement Inventory => Q<VisualElement>("Inventory");
|
||||
public VisualElement EquipmentColumn => Q<VisualElement>("EquipmentColumn");
|
||||
|
||||
protected void Awake() {
|
||||
equipment = new UIEquipmentColumn(EquipmentColumn);
|
||||
inventory = new UIInventory(Inventory, inventorySlot);
|
||||
|
||||
ModuleUI.OnJumpPage += ModuleUI_OnJumpPage;
|
||||
}
|
||||
|
||||
private void ModuleUI_OnJumpPage(Page page) {
|
||||
Element.EnableInClassList("document-page-hide", page != Page.Backpack);
|
||||
if (page != Page.Backpack) { return; }
|
||||
equipment.Settings(SingleManager.I.equipment);
|
||||
inventory.Settings(SingleManager.I.inventory);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 255d109f8aae559419ae63856abc96c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6be8605ab2df3348bdd03749d5ca2c5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06f31db1c09e8a0409a8b3b960a13216
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// SliderInputH - Panel
|
||||
/// </summary>
|
||||
public class UISliderInputH : ModuleUIPanel {
|
||||
|
||||
public float value;
|
||||
public Vector2 range = new Vector2(1, 1);
|
||||
public UISliderH slider;
|
||||
public event Action<float> ValueChanged;
|
||||
|
||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
||||
public UIFloatField FloatField => Q<UIFloatField>("UIFloatField");
|
||||
|
||||
public UISliderInputH(VisualElement element, VisualElement canvas) : base(element) {
|
||||
slider = new UISliderH(element, canvas);
|
||||
|
||||
slider.ValueChanged += Slider_ValueChanged;
|
||||
FloatField.RegisterCallback<ChangeEvent<float>>(FloatField_ValueChanged);
|
||||
}
|
||||
private void Slider_ValueChanged(float obj) {
|
||||
value = Mathf.Lerp(range.x, range.y, obj);
|
||||
FloatField.SetValueWithoutNotify(value);
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void FloatField_ValueChanged(ChangeEvent<float> obj) {
|
||||
value = Mathf.Clamp(obj.newValue, range.x, range.y);
|
||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
||||
slider.UpdateValue(scale, false);
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
public void Update() {
|
||||
slider.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(float value) {
|
||||
this.value = Mathf.Clamp(range.x, range.y, value);
|
||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
||||
slider.UpdateValue(scale, false);
|
||||
FloatField.SetValueWithoutNotify(value);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5f8ad3cc3aff1940bdf68f3d911a263
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// Vector2 - Panel
|
||||
/// </summary>
|
||||
public class UIVector2 : ModuleUIPanel {
|
||||
|
||||
public bool isLock;
|
||||
public Vector2 value;
|
||||
public UISliderInputH sliderX;
|
||||
public UISliderInputH sliderY;
|
||||
public event Action<Vector2, bool> ValueChanged;
|
||||
|
||||
public Button Lock => Q<Button>("Lock");
|
||||
public VisualElement SliderX => Q<VisualElement>("SliderInputX");
|
||||
public VisualElement SliderY => Q<VisualElement>("SliderInputY");
|
||||
|
||||
public UIVector2(VisualElement element, VisualElement canvas) : base(element) {
|
||||
sliderX = new UISliderInputH(SliderX, canvas);
|
||||
sliderY = new UISliderInputH(SliderY, canvas);
|
||||
|
||||
Lock.clicked += Lock_clicked;
|
||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
||||
}
|
||||
private void Lock_clicked() {
|
||||
isLock = !isLock;
|
||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
||||
if (isLock) { value.y = value.x; sliderY.UpdateValue(value.x); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
private void SliderX_ValueChanged(float obj) {
|
||||
value.x = obj;
|
||||
if (isLock) { value.y = obj; sliderY.UpdateValue(obj); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
private void SliderY_ValueChanged(float obj) {
|
||||
value.y = obj;
|
||||
if (isLock) { value.x = obj; sliderX.UpdateValue(obj); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
public void Update() {
|
||||
sliderX.Update();
|
||||
sliderY.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(Vector2 value, bool isLock) {
|
||||
this.value = value;
|
||||
this.isLock = isLock;
|
||||
sliderX.UpdateValue(value.x);
|
||||
sliderY.UpdateValue(value.y);
|
||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
||||
}
|
||||
/// <summary> 设置范围 </summary>
|
||||
public void Settings(Vector2 range) {
|
||||
sliderX.range = range;
|
||||
sliderY.range = range;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0898288ac15d9a4e9a82e0d6d36ff17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// Vector3 - Panel
|
||||
/// </summary>
|
||||
public class UIVector3 : ModuleUIPanel {
|
||||
|
||||
public Vector3 value;
|
||||
public UISliderInputH sliderX;
|
||||
public UISliderInputH sliderY;
|
||||
public UISliderInputH sliderZ;
|
||||
public event Action<Vector3> ValueChanged;
|
||||
|
||||
public VisualElement SliderInputX => Q<VisualElement>("SliderInputX");
|
||||
public VisualElement SliderInputY => Q<VisualElement>("SliderInputY");
|
||||
public VisualElement SliderInputZ => Q<VisualElement>("SliderInputZ");
|
||||
|
||||
public UIVector3(VisualElement element, VisualElement canvas) : base(element) {
|
||||
sliderX = new UISliderInputH(SliderInputX, canvas);
|
||||
sliderY = new UISliderInputH(SliderInputY, canvas);
|
||||
sliderZ = new UISliderInputH(SliderInputZ, canvas);
|
||||
|
||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
||||
sliderZ.ValueChanged += SliderZ_ValueChanged;
|
||||
}
|
||||
|
||||
private void SliderX_ValueChanged(float obj) {
|
||||
value.x = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void SliderY_ValueChanged(float obj) {
|
||||
value.y = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void SliderZ_ValueChanged(float obj) {
|
||||
value.z = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
public void Update() {
|
||||
sliderX.Update();
|
||||
sliderY.Update();
|
||||
sliderZ.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(Vector3 value) {
|
||||
this.value = value;
|
||||
sliderX.UpdateValue(value.x);
|
||||
sliderY.UpdateValue(value.y);
|
||||
sliderZ.UpdateValue(value.z);
|
||||
}
|
||||
/// <summary> 设置范围 </summary>
|
||||
public void Settings(Vector2 range) {
|
||||
sliderX.range = range;
|
||||
sliderY.range = range;
|
||||
sliderZ.range = range;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36d613e41a27e8f40be6e6c05de1aeb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,113 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.Video;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 视频播放控件
|
||||
/// </summary>
|
||||
public class UIVideoPlayPanel : ModuleUIPanel {
|
||||
private float showTime;
|
||||
private bool isDownSlider;
|
||||
private Action fullAction;
|
||||
private RenderTexture renderTexture;
|
||||
private VideoPlayer videoPlayer;
|
||||
private UISliderH slider;
|
||||
|
||||
private VisualElement VideoView => element.Q<VisualElement>("VideoView");
|
||||
private VisualElement VideoController => element.Q<VisualElement>("VideoController");
|
||||
private VisualElement Slider => element.Q<VisualElement>("Slider");
|
||||
private Label Time => element.Q<Label>("Time");
|
||||
private Button Play => element.Q<Button>("Play");
|
||||
private Button Pause => element.Q<Button>("Pause");
|
||||
private Button FullScreen => element.Q<Button>("FullScreen");
|
||||
|
||||
public UIVideoPlayPanel(VisualElement element, VisualElement canvas, VideoPlayer videoPlayer, Action fullAction = null) : base(element) {
|
||||
this.videoPlayer = videoPlayer;
|
||||
this.fullAction = fullAction;
|
||||
|
||||
int width = (int)element.parent.resolvedStyle.width;
|
||||
int height = (int)element.parent.resolvedStyle.height;
|
||||
renderTexture = new RenderTexture(width, height, 0);
|
||||
Background background = Background.FromRenderTexture(renderTexture);
|
||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
||||
|
||||
Play.clicked += Play_clicked;
|
||||
Pause.clicked += Pause_clicked;
|
||||
FullScreen.clicked += FullScreen_clicked;
|
||||
|
||||
VideoView.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
||||
VideoController.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
||||
|
||||
Slider.RegisterCallback<PointerDownEvent>((evt) => isDownSlider = true);
|
||||
Slider.RegisterCallback<PointerUpEvent>((evt) => isDownSlider = false);
|
||||
Slider.RegisterCallback<PointerLeaveEvent>((evt) => isDownSlider = false);
|
||||
|
||||
slider = new UISliderH(element, canvas);
|
||||
slider.ValueChanged += Slider_SlidingValueChanged;
|
||||
}
|
||||
|
||||
/// <summary> 启用 </summary>
|
||||
public void Enable(string url) {
|
||||
videoPlayer.url = url; Enable();
|
||||
}
|
||||
/// <summary> 启用 </summary>
|
||||
public void Enable() {
|
||||
UpdateRenderTexture();
|
||||
videoPlayer.targetTexture = renderTexture;
|
||||
if (videoPlayer.isPlaying) { Play_clicked(); }
|
||||
else { Pause_clicked(); }
|
||||
}
|
||||
|
||||
/// <summary> 更新 </summary>
|
||||
public void Update() {
|
||||
if (videoPlayer == null) { return; }
|
||||
showTime -= UnityEngine.Time.deltaTime;
|
||||
Visibility visibility = showTime > 0 ? Visibility.Visible : Visibility.Hidden;
|
||||
VideoController.style.visibility = visibility;
|
||||
//进度条
|
||||
float value = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
|
||||
if (!isDownSlider) { slider.UpdateValue(value, false); }
|
||||
//播放时间
|
||||
string clockTime = TimeSpan.FromSeconds(videoPlayer.clockTime).ToString(@"mm\:ss");
|
||||
string length = TimeSpan.FromSeconds(videoPlayer.length).ToString(@"mm\:ss");
|
||||
Time.text = clockTime + "/" + length;
|
||||
}
|
||||
/// <summary> 播放 </summary>
|
||||
public void Play_clicked() {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.Play(); showTime = 5;
|
||||
Play.style.display = DisplayStyle.None;
|
||||
Pause.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
/// <summary> 暂停 </summary>
|
||||
public void Pause_clicked() {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.Pause();
|
||||
Play.style.display = DisplayStyle.Flex;
|
||||
Pause.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
/// <summary> 更新渲染纹理 </summary>
|
||||
private void UpdateRenderTexture() {
|
||||
int width = (int)element.parent.resolvedStyle.width;
|
||||
int height = (int)element.parent.resolvedStyle.height;
|
||||
if (renderTexture.width == width && renderTexture.height == height) { return; }
|
||||
renderTexture.Release();
|
||||
renderTexture = new RenderTexture(width, height, 0);
|
||||
Background background = Background.FromRenderTexture(renderTexture);
|
||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
||||
}
|
||||
/// <summary> 全屏 </summary>
|
||||
private void FullScreen_clicked() {
|
||||
fullAction?.Invoke();
|
||||
}
|
||||
/// <summary> 进度条更新 </summary>
|
||||
private void Slider_SlidingValueChanged(float obj) {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.frame = (long)obj;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00c04ca4ef821d0469a77408648f5ff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7b948b996cc2644fbc9e750c6c24f4c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI装备栏
|
||||
/// </summary>
|
||||
public class UIEquipmentColumn : ModuleUIPanel {
|
||||
|
||||
public EquipmentColumn equipment;
|
||||
/// <summary> 插槽字典 </summary>
|
||||
public Dictionary<string, UIEquipmentSlot> dictionary = new Dictionary<string, UIEquipmentSlot>();
|
||||
|
||||
public UIEquipmentColumn(VisualElement element) : base(element) {
|
||||
InitialSlot(1, EquipmentSlotType.主手);
|
||||
InitialSlot(2, EquipmentSlotType.副手);
|
||||
InitialSlot(3, EquipmentSlotType.上衣);
|
||||
InitialSlot(4, EquipmentSlotType.项链);
|
||||
|
||||
InitialSlot(5, EquipmentSlotType.戒指1);
|
||||
InitialSlot(6, EquipmentSlotType.戒指2);
|
||||
InitialSlot(7, EquipmentSlotType.手镯1);
|
||||
InitialSlot(8, EquipmentSlotType.手镯2);
|
||||
|
||||
InitialSlot(9, EquipmentSlotType.头盔);
|
||||
InitialSlot(10, EquipmentSlotType.手套);
|
||||
InitialSlot(11, EquipmentSlotType.腰带);
|
||||
InitialSlot(12, EquipmentSlotType.鞋子);
|
||||
}
|
||||
public void Dispose() {
|
||||
|
||||
}
|
||||
|
||||
public void Settings(EquipmentColumn equipment) {
|
||||
if (this.equipment != null) { Dispose(); }
|
||||
this.equipment = equipment;
|
||||
if (equipment == null) { return; }
|
||||
foreach (var item in dictionary) { Settings(item.Key, item.Value); }
|
||||
}
|
||||
public void Settings(string key, UIEquipmentSlot uISlot) {
|
||||
if (!equipment.ContainsKey(key)) { return; }
|
||||
EquipmentSlot slot = equipment[key];
|
||||
uISlot.Settings(slot);
|
||||
}
|
||||
|
||||
private void InitialSlot(int index, EquipmentSlotType type) {
|
||||
VisualElement element = Q<VisualElement>($"EquipmentSlot{index}");
|
||||
UIEquipmentSlot uiSlot = new UIEquipmentSlot(element);
|
||||
dictionary.Add(type.ToString(), uiSlot);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad4c66685a426345b174ec593f67f56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI装备插槽
|
||||
/// </summary>
|
||||
public class UIEquipmentSlot : ModuleUIPanel, InventoryDrag {
|
||||
|
||||
public EquipmentSlot value;
|
||||
|
||||
public Label CountLabel => Q<Label>("Count");
|
||||
public VisualElement Image => Q<VisualElement>("Image");
|
||||
|
||||
public int Count => 1;
|
||||
public InventoryItem Item => value.item;
|
||||
public VisualElement Anchor => element;
|
||||
|
||||
public UIEquipmentSlot(VisualElement element) : base(element) {
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseOverEvent>(MouseOverEvent);
|
||||
element.RegisterCallback<MouseLeaveEvent>(MouseLeaveEvent);
|
||||
element.RegisterCallback<ClickEvent>(ClickEvent);
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
UIPopupManager.I.inventoryDrag.Settings(this);
|
||||
Image.EnableInClassList("equipment-image-drag", true);
|
||||
}
|
||||
private void MouseOverEvent(MouseOverEvent evt) {
|
||||
if (!Verify()) { return; }
|
||||
UIPopupManager.I.inventoryDrag.EnterContainer(this);
|
||||
}
|
||||
private void MouseLeaveEvent(MouseLeaveEvent evt) {
|
||||
UIPopupManager.I.inventoryDrag.ExitContainer(this);
|
||||
}
|
||||
private void ClickEvent(ClickEvent evt) {
|
||||
// Debug.Log("sss");
|
||||
}
|
||||
|
||||
public void Settings(EquipmentSlot value) {
|
||||
this.value = value;
|
||||
UpdatePreview();
|
||||
}
|
||||
public void Settings(InventoryItem item, int count) {
|
||||
value.Settings(item);
|
||||
UpdatePreview();
|
||||
}
|
||||
public void Cancel() {
|
||||
Image.EnableInClassList("equipment-image-drag", false);
|
||||
}
|
||||
|
||||
private void UpdatePreview() {
|
||||
Sprite sprite = value == null || value.item == null ? null : value.item.sprite;
|
||||
Image.style.backgroundImage = new StyleBackground(sprite);
|
||||
}
|
||||
private bool Verify() {
|
||||
InventoryDrag container = UIPopupManager.I.inventoryDrag.container;
|
||||
if (container == null) { return false; }
|
||||
if (container.Item is Equipment equipment) { return value.verify.Invoke(equipment); }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99dc774aaeb03bc44b6607bd012c0e6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 装备提示
|
||||
/// </summary>
|
||||
public class UIEquipmentTip : ModuleUIPanel {
|
||||
public UIEquipmentTip(VisualElement element) : base(element) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d2e2ebf18434ab489d8a0918806f5af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 791ea0dc13231374f91db42c5f083cc2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user