浏览代码

[Bot] Automated dotnet-format update

/main
Trevor J McDonald 4 年前
当前提交
820cf542
共有 3 个文件被更改,包括 62 次插入62 次删除
  1. 14
      UOP1_Project/Assets/Scripts/Inventory/ItemStack.cs
  2. 108
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/Inventory.cs
  3. 2
      UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/ItemType.cs

14
UOP1_Project/Assets/Scripts/Inventory/ItemStack.cs


public class ItemStack
{
public Item Item { get; }
public Item Item { get; }
public int Amount { get; set; }
public int Amount { get; set; }
public ItemStack(Item item, int amount)
{
Item = item;
Amount = amount;
}
public ItemStack(Item item, int amount)
{
Item = item;
Amount = amount;
}
}

108
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/Inventory.cs


public List<ItemStack> Items => _items;
public void Add(Item item, int count = 1)
{
if (count <= 0)
return;
public void Add(Item item, int count = 1)
{
if (count <= 0)
return;
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
if (item == currentItemStack.Item)
{
currentItemStack.Amount += count;
return;
}
}
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
if (item == currentItemStack.Item)
{
currentItemStack.Amount += count;
return;
}
}
_items.Add(new ItemStack(item, count));
}
_items.Add(new ItemStack(item, count));
}
public void Remove(Item item, int count = 1)
{
if (count <= 0)
return;
public void Remove(Item item, int count = 1)
{
if (count <= 0)
return;
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
if (currentItemStack.Item == item)
{
currentItemStack.Amount -= count;
if (currentItemStack.Item == item)
{
currentItemStack.Amount -= count;
if (currentItemStack.Amount <= 0)
_items.Remove(currentItemStack);
if (currentItemStack.Amount <= 0)
_items.Remove(currentItemStack);
return;
}
}
}
return;
}
}
}
public bool Contains(Item item)
{
for (int i = 0; i < _items.Count; i++)
{
if (item == _items[i].Item)
{
return true;
}
}
public bool Contains(Item item)
{
for (int i = 0; i < _items.Count; i++)
{
if (item == _items[i].Item)
{
return true;
}
}
return false;
}
return false;
}
public int Count(Item item)
{
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
if (item == currentItemStack.Item)
{
return currentItemStack.Amount;
}
}
public int Count(Item item)
{
for (int i = 0; i < _items.Count; i++)
{
ItemStack currentItemStack = _items[i];
if (item == currentItemStack.Item)
{
return currentItemStack.Amount;
}
}
return 0;
}
return 0;
}
}

2
UOP1_Project/Assets/Scripts/Inventory/ScriptableObjects/ItemType.cs


private string _actionName;
public string ActionName => _actionName;
}
}
正在加载...
取消
保存