修复BUG
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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>();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d078f2759ef3ef4bb65217dd9b2fb94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13afb37aea13dc94b97e8e85af77b5b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1d68199e9959734e85efd7a39d4d78c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user