1
This commit is contained in:
@@ -14,26 +14,43 @@ public class EquipmentColumn {
|
||||
public EquipmentSlot this[string key] => dictionary[key];
|
||||
|
||||
public EquipmentColumn() {
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.主手, VerifyWeapon));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.副手, VerifyDeputy));
|
||||
AddSlot(WeaponSlot());
|
||||
AddSlot(DeputySlot());
|
||||
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.上衣, (equipment) => VerifyCommon(equipment, ArmorType.上衣.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.头盔, (equipment) => VerifyCommon(equipment, ArmorType.头盔.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.手套, (equipment) => VerifyCommon(equipment, ArmorType.手套.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.腰带, (equipment) => VerifyCommon(equipment, ArmorType.腰带.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.鞋子, (equipment) => VerifyCommon(equipment, ArmorType.鞋子.ToString())));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.上衣, ArmorType.上衣));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.头盔, ArmorType.头盔));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.手套, ArmorType.手套));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.腰带, ArmorType.腰带));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.鞋子, ArmorType.鞋子));
|
||||
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.项链, (equipment) => VerifyCommon(equipment, AccessoryType.项链.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.戒指1, (equipment) => VerifyCommon(equipment, AccessoryType.戒指.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.戒指2, (equipment) => VerifyCommon(equipment, AccessoryType.戒指.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.手镯1, (equipment) => VerifyCommon(equipment, AccessoryType.手镯.ToString())));
|
||||
AddSlot(new EquipmentSlot(EquipmentSlotType.手镯2, (equipment) => VerifyCommon(equipment, AccessoryType.手镯.ToString())));
|
||||
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("/");
|
||||
|
||||
@@ -9,18 +9,26 @@ public enum WeaponType {
|
||||
单手, 副手, 双手
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器类别
|
||||
/// </summary>
|
||||
public enum WeaponCategory {
|
||||
剑, 刀, 枪, 弓, 法杖, 斧头, 锤子
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/武器")]
|
||||
public class ConstWeapon : ConstEquipment {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponType type;
|
||||
/// <summary> 武器类别 </summary>
|
||||
public WeaponCategory category;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = type.ToString();
|
||||
item.type = $"{type}/{category}";
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d2e2ebf18434ab489d8a0918806f5af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 库存提示
|
||||
/// </summary>
|
||||
public class UIInventoryTip : ModuleUIPanel {
|
||||
|
||||
public UIInventoryTip(VisualElement element) : base(element) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 029d4912285f5c74c8d041ea54164d8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,11 +15,11 @@ public class UIBackpackPage : ModuleUIPage {
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("BackpackPage");
|
||||
|
||||
public VisualElement Equipment => Q<VisualElement>("Equipment");
|
||||
public VisualElement Inventory => Q<VisualElement>("Inventory");
|
||||
public VisualElement EquipmentColumn => Q<VisualElement>("EquipmentColumn");
|
||||
|
||||
protected void Awake() {
|
||||
equipment = new UIEquipmentColumn(Equipment);
|
||||
equipment = new UIEquipmentColumn(EquipmentColumn);
|
||||
inventory = new UIInventory(Inventory, inventorySlot);
|
||||
|
||||
ModuleUI.OnJumpPage += ModuleUI_OnJumpPage;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
||||
<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="Equipment" src="project://database/Assets/UI%20Toolkit/GamePanel/Equipment/Equipment.uxml?fileID=9197481963319205126&guid=5cc8bcb294d4fe241a2e6d3deb627c57&type=3#Equipment" />
|
||||
<ui:Template name="Equipment" src="project://database/Assets/UI%20Toolkit/GamePanel/Equipment/EquipmentColumn.uxml?fileID=9197481963319205126&guid=5cc8bcb294d4fe241a2e6d3deb627c57&type=3#EquipmentColumn" />
|
||||
<ui:Template name="Inventory" src="project://database/Assets/UI%20Toolkit/GamePanel/Inventory/Inventory.uxml?fileID=9197481963319205126&guid=66c4934900f42194a928ece38b3e68eb&type=3#Inventory" />
|
||||
<ui:Template name="ItemInfo" src="project://database/Assets/UI%20Toolkit/GamePanel/ItemInfo/ItemInfo.uxml?fileID=9197481963319205126&guid=7b84b855a52611f4291ff7a90fdb83dd&type=3#ItemInfo" />
|
||||
<ui:Template name="ItemInfo" src="project://database/Assets/UI%20Toolkit/GamePanel/InventoryTip/InventoryTip.uxml?fileID=9197481963319205126&guid=7b84b855a52611f4291ff7a90fdb83dd&type=3#InventoryTip" />
|
||||
<Style src="project://database/Assets/UI%20Toolkit/GamePage/BackpackPage/BackpackPage.uss?fileID=7433441132597879392&guid=06b8f7d50f09d2f4b9f9d44aae8a0455&type=3#BackpackPage" />
|
||||
<ui:VisualElement style="flex-grow: 1; flex-direction: row; align-items: stretch; justify-content: center; padding-top: 100px; padding-right: 100px; padding-bottom: 100px; padding-left: 100px;">
|
||||
<ui:Instance template="Equipment" name="Equipment" />
|
||||
<ui:Instance template="Equipment" name="EquipmentColumn" />
|
||||
<ui:Instance template="Inventory" name="Inventory" style="width: 500px; margin-right: 10px; margin-left: 10px;" />
|
||||
<ui:Instance template="ItemInfo" name="ItemInfo" style="width: 400px; display: none;" />
|
||||
<ui:Instance template="ItemInfo" name="InventoryTip" style="width: 400px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<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/UI%20Toolkit/GamePanel/InventoryTip/InventoryTip.uss?fileID=7433441132597879392&guid=6e24d6aca80b52c479d5de875f77b8fc&type=3#InventoryTip" />
|
||||
<ui:VisualElement class="inventorytip-bg">
|
||||
<ui:VisualElement>
|
||||
<ui:Label tabindex="-1" text="灾厄之巨剑" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" class="inventorytip-text" style="font-size: 20px; -unity-font-style: bold;" />
|
||||
<ui:Label tabindex="-1" text="双手 剑" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Type" class="inventorytip-text" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement style="height: 2px; background-color: rgb(255, 255, 255);" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a517837085469640812216ec11d1570
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,28 @@
|
||||
.inventorytip-bg {
|
||||
flex-grow: 1;
|
||||
margin-top: 5px;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 5px;
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
border-bottom-right-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
background-color: rgb(102, 102, 102);
|
||||
padding-top: 5px;
|
||||
padding-right: 5px;
|
||||
padding-bottom: 5px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.inventorytip-text {
|
||||
color: rgb(255, 255, 255);
|
||||
margin-top: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 0;
|
||||
padding-top: 0;
|
||||
padding-right: 0;
|
||||
padding-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<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/UI%20Toolkit/GamePanel/InventoryTip/InventoryTip.uss?fileID=7433441132597879392&guid=6e24d6aca80b52c479d5de875f77b8fc&type=3#InventoryTip" />
|
||||
<ui:VisualElement class="inventorytip-bg">
|
||||
<ui:Label tabindex="-1" text="名字名字名字名字" parse-escape-sequences="true" display-tooltip-when-elided="true" class="inventorytip-text" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,6 +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/UI%20Toolkit/GamePanel/ItemInfo/ItemInfo.uss?fileID=7433441132597879392&guid=6e24d6aca80b52c479d5de875f77b8fc&type=3#ItemInfo" />
|
||||
<ui:VisualElement style="flex-grow: 1;">
|
||||
<ui:VisualElement style="flex-grow: 1; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(102, 102, 102);" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
Reference in New Issue
Block a user