1
This commit is contained in:
@@ -77,7 +77,12 @@ namespace BITFALL.Guns
|
||||
{
|
||||
[Header(nameof(AssetableGun))]
|
||||
[SerializeReference, SubclassSelector] protected IFireMode fireMode;
|
||||
public IFireMode FireMode => fireMode;
|
||||
|
||||
[SerializeField] private int initialDamage;
|
||||
|
||||
[SerializeField] private int initialBulletForce;
|
||||
public IFireMode FireMode => fireMode;
|
||||
public int InitialBulletForce => initialBulletForce;
|
||||
public int InitialDamage => initialDamage;
|
||||
}
|
||||
}
|
@@ -35,7 +35,7 @@ namespace BITFALL
|
||||
[SerializeField] private string displayName;
|
||||
[SerializeField] private string description;
|
||||
[SerializeField] private string addressablePath;
|
||||
[SerializeField] private WorldableItem prefab;
|
||||
[SerializeField] private WorldItem prefab;
|
||||
[SerializeField] private Texture2D squareIcon;
|
||||
[SerializeField] private Texture2D rectangleIcon;
|
||||
[SerializeField] private ItemQuality quality;
|
||||
@@ -78,7 +78,7 @@ namespace BITFALL
|
||||
}
|
||||
#endregion
|
||||
#region 本地方法
|
||||
public WorldableItem GetPrefab() => prefab;
|
||||
public WorldItem GetPrefab() => prefab;
|
||||
public Texture2D SquareIcon => squareIcon;
|
||||
public Texture2D RectangleIcon=>rectangleIcon;
|
||||
#endregion
|
||||
|
@@ -6,6 +6,11 @@ namespace BITFALL.Items.Melee
|
||||
{
|
||||
public class AssetableMelee : AssetableEquip
|
||||
{
|
||||
|
||||
[Header(nameof(AssetableMelee))]
|
||||
[SerializeField] private int blockStaminaCost;
|
||||
[SerializeField] private int heavyAttackStaminaCost;
|
||||
|
||||
public int BlockStaminaCost => blockStaminaCost;
|
||||
public int HeavyAttackStaminaCost => heavyAttackStaminaCost;
|
||||
}
|
||||
}
|
||||
|
17
Assets/Artists/Scripts/Item/AssetableThrow.cs
Normal file
17
Assets/Artists/Scripts/Item/AssetableThrow.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Items
|
||||
{
|
||||
public class AssetableThrow :AssetableItem
|
||||
{
|
||||
[SerializeField] private Transform instance;
|
||||
|
||||
public Transform GetInstance()
|
||||
{
|
||||
return Instantiate(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
Assets/Artists/Scripts/Item/IPlayerSwapItem.cs
Normal file
21
Assets/Artists/Scripts/Item/IPlayerSwapItem.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Audio;
|
||||
|
||||
namespace BITFALL.Items
|
||||
{
|
||||
public interface IEntitySwapItem
|
||||
{
|
||||
bool TryGetCurrentContainer(out IBasicItemContainer container);
|
||||
event Func<IBasicItemContainer, bool> OpenSwapFactory;
|
||||
event Action<IBasicItemContainer> OnSwapOpened;
|
||||
event Action<IBasicItemContainer> OnSwapClosed;
|
||||
public bool Add(IBasicItem item);
|
||||
public bool Remove(IBasicItem item);
|
||||
bool Open(IBasicItemContainer container);
|
||||
bool Close();
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@ using UnityEngine.AddressableAssets;
|
||||
namespace BITFALL
|
||||
{
|
||||
|
||||
public class WorldableItem : MonoBehaviour,IBasicItem,IDescription
|
||||
public class WorldItem : MonoBehaviour,IBasicItem,IDescription
|
||||
{
|
||||
#region 本地字段
|
||||
[Header(Constant.Header.Settings)]
|
||||
@@ -88,8 +88,8 @@ namespace BITFALL
|
||||
#endregion
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(WorldableItem))]
|
||||
public class WorldableInspector:BITInspector<WorldableItem>
|
||||
[UnityEditor.CustomEditor(typeof(WorldItem))]
|
||||
public class WorldItemInspector:BITInspector<WorldItem>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
73
Assets/Artists/Scripts/Item/WorldItemContainer.cs
Normal file
73
Assets/Artists/Scripts/Item/WorldItemContainer.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Items
|
||||
{
|
||||
public class WorldItemContainer : MonoBehaviour,IBasicItemContainer,IDescription
|
||||
{
|
||||
[SerializeField] private string containerName;
|
||||
public string Name => containerName;
|
||||
private readonly Dictionary<int,IBasicItem> _items = new();
|
||||
public int Id => GetInstanceID();
|
||||
public bool TryGetItem(Func<IBasicItem, bool> func, out IBasicItem item)
|
||||
{
|
||||
if (_items.Values.TryGetAny(func.Invoke,out item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
item=null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public IBasicItem[] GetItems()=>_items.Values.ToArray();
|
||||
|
||||
public bool Add(IBasicItem item)
|
||||
{
|
||||
if (AddFactory.CastAsFunc().Any(x=>x.Invoke(item) is false)) return false;
|
||||
if (_items.ContainsKey(item.Id)) return false;
|
||||
_items.Add(item.Id,item);
|
||||
OnAdd?.Invoke(item);
|
||||
OnSet?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(IBasicItem item)
|
||||
{
|
||||
return Remove(item.Id);
|
||||
}
|
||||
public bool Remove(int id)
|
||||
{
|
||||
if (RemoveFactory.CastAsFunc().Any(x=>x.Invoke(_items[id]) is false)) return false;
|
||||
if (!_items.Remove(id)) return false;
|
||||
OnRemove?.Invoke(_items[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(Func<IBasicItem, bool> removeFactory)
|
||||
{
|
||||
return _items.Values.TryGetAny(removeFactory.Invoke,out var item) && Remove(item);
|
||||
}
|
||||
|
||||
public bool Drop(int Id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool DropOrSpawn(IBasicItem item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public event Func<IBasicItem, bool> AddFactory;
|
||||
public event Func<IBasicItem, bool> RemoveFactory;
|
||||
public event Func<IBasicItem, bool> DropFactory;
|
||||
public event Action<IBasicItem> OnAdd;
|
||||
public event Action<IBasicItem> OnRemove;
|
||||
public event Action<IBasicItem> OnSet;
|
||||
public event Action<IBasicItem> OnDrop;
|
||||
public event Action<IBasicItemContainer> OnRebuild;
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user