修复BUG
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdef6696992dc94f977f5ca3a2cc528
|
||||
guid: 5592cd11563474d42a1f6805b66f7a1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物品 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/物品")]
|
||||
public class InventoryItemConst : ScriptableObject {
|
||||
/// <summary> 图片 </summary>
|
||||
public Sprite sprite;
|
||||
|
||||
/// <summary> 数据转换 </summary>
|
||||
public virtual InventoryItem To() {
|
||||
InventoryItem item = new InventoryItem();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de8ae08be418e3c48a7f938b6b842caa
|
||||
guid: 66da6092ac51f6a47a0c3d896f845816
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa01c7c9647ebd6468b17280d5065639
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Accessory : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cfcaecd119af2f48adf5a4649d88360
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Armor : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备
|
||||
/// </summary>
|
||||
public class Equipment : InventoryItem {
|
||||
/// <summary> 装备类型 (类型1/类型2) </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,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Weapon : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13afb37aea13dc94b97e8e85af77b5b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
Reference in New Issue
Block a user