首次提交
This commit is contained in:
112
Assets/Scripts/Common/ItemBindHelper.cs
Normal file
112
Assets/Scripts/Common/ItemBindHelper.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public struct ItemBindData
|
||||
{
|
||||
public ItemType Type;
|
||||
public bool Optional;
|
||||
|
||||
public ItemBindData(ItemType type, bool optional = false)
|
||||
{
|
||||
Type = type;
|
||||
Optional = optional;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemBindConfig
|
||||
{
|
||||
public ItemSubType SubType;
|
||||
public readonly List<ItemBindData> Binds = new List<ItemBindData>();
|
||||
|
||||
public ItemBindConfig(ItemSubType subType)
|
||||
{
|
||||
SubType = subType;
|
||||
}
|
||||
|
||||
public void Add(ItemType type, bool optional = false)
|
||||
{
|
||||
Binds.Add(new ItemBindData(type, optional));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemBindHelper
|
||||
{
|
||||
private static readonly Dictionary<ItemSubType, ItemBindConfig> _bindConfigs =
|
||||
new Dictionary<ItemSubType, ItemBindConfig>();
|
||||
|
||||
#region 初始化
|
||||
|
||||
static ItemBindHelper()
|
||||
{
|
||||
var rodTele = new ItemBindConfig(ItemSubType.RodTele);
|
||||
rodTele.Add(ItemType.Line);
|
||||
rodTele.Add(ItemType.Bobber);
|
||||
rodTele.Add(ItemType.Weight);
|
||||
rodTele.Add(ItemType.Hook);
|
||||
|
||||
|
||||
var rodBolo = new ItemBindConfig(ItemSubType.RodBolo);
|
||||
rodBolo.Add(ItemType.Line);
|
||||
rodBolo.Add(ItemType.Weight);
|
||||
rodBolo.Add(ItemType.Lure);
|
||||
|
||||
var rodSpine = new ItemBindConfig(ItemSubType.RodSpine);
|
||||
rodSpine.Add(ItemType.Line);
|
||||
rodSpine.Add(ItemType.Weight);
|
||||
rodSpine.Add(ItemType.Lure);
|
||||
|
||||
|
||||
_bindConfigs.Add(rodTele.SubType, rodTele);
|
||||
_bindConfigs.Add(rodBolo.SubType, rodBolo);
|
||||
_bindConfigs.Add(rodSpine.SubType, rodSpine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public static ItemBindConfig GetBindConfig(this ItemInfo itemInfo)
|
||||
{
|
||||
return _bindConfigs.GetValueOrDefault((ItemSubType)itemInfo.Config.Type);
|
||||
}
|
||||
|
||||
|
||||
// public List<ItemType> GetItemGearBindTypes()
|
||||
// {
|
||||
// var itemType = ItemType;
|
||||
// var subType = (ItemSubType)Config.Type;
|
||||
// List<ItemType> types = new List<ItemType>();
|
||||
// if (itemType == ItemType.Rod)
|
||||
// {
|
||||
// if (subType == ItemSubType.RodTele)
|
||||
// {
|
||||
// types.Add(ItemType.Line);
|
||||
// types.Add(ItemType.Bobber);
|
||||
// types.Add(ItemType.Weight);
|
||||
// types.Add(ItemType.Hook);
|
||||
// }
|
||||
// else if (subType == ItemSubType.RodBolo)
|
||||
// {
|
||||
// types.Add(ItemType.Line);
|
||||
// types.Add(ItemType.Weight);
|
||||
// types.Add(ItemType.Lure);
|
||||
// }
|
||||
// else if (subType == ItemSubType.RodSpine)
|
||||
// {
|
||||
// types.Add(ItemType.Line);
|
||||
// types.Add(ItemType.Weight);
|
||||
// types.Add(ItemType.Lure);
|
||||
// }
|
||||
// }
|
||||
// else if (itemType == ItemType.Lure)
|
||||
// {
|
||||
// types.Add(ItemType.Hook);
|
||||
// types.Add(ItemType.Hook);
|
||||
// }
|
||||
//
|
||||
// return types;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user