Extends warehouse api

This commit is contained in:
kabix09 2022-06-20 18:23:22 +02:00
parent ce358dafcb
commit 774930c876
6 changed files with 55 additions and 4 deletions

View File

@ -64,6 +64,7 @@
<Compile Include="Assets\Scripts\Knockback.cs" />
<Compile Include="Assets\Scripts\Inventory\InventoryManager.cs" />
<Compile Include="Assets\Scripts\SceneManager\SaveTask\SaveQuestSystem.cs" />
<Compile Include="Assets\Scripts\SceneManager\SaveInventory\SaveInventorySystem.cs" />
<Compile Include="Assets\Scripts\Dialogue.cs" />
<Compile Include="Assets\Scripts\SceneManager\SaveItem\ItemData\ItemData.cs" />
<Compile Include="Assets\Scripts\Item\ItemSlot.cs" />
@ -101,6 +102,7 @@
<Compile Include="Assets\Scripts\DoorBehaviour.cs" />
<Compile Include="Assets\Scripts\SceneManager\SaveItem\EquippableItemPrefarbAsset.cs" />
<Compile Include="Assets\Scripts\Enemies&apos; Scprits\PatrollingEnemy.cs" />
<Compile Include="Assets\Scripts\SceneManager\SceneInventoryManager.cs" />
<Compile Include="Assets\Scripts\Chest\ChestPanelController.cs" />
<Compile Include="Assets\Scripts\Inventory\InventoryPanelController.cs" />
<Compile Include="Assets\TakingDamage.cs" />

View File

@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: Axe
m_EditorClassIdentifier:
id: 0
name: Axe_one
name: lumberjack axe
description: Lumberjack's Axe
level: 1
image: {fileID: 21300000, guid: d7a7292796eda0941a6a863b7d66bbcb, type: 3}

View File

@ -47,7 +47,7 @@ public class NPCQuest : MonoBehaviour
// 1. Drop item on map
GameObject _axe = Instantiate(axe, new Vector3(37.1f, -31.7f, 0), Quaternion.identity, globalGUI.transform);
// 1.2 Fix names (prevent add "(Clone)" postfix)
_axe.name = axe.name;
_axe.name = axe.GetComponent<PickableController>().item.Name;
_axe.GetComponent<PickableController>().item.name = axe.name;
// 2. Add object to DynamicList in LocalSceneManager

View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
// T will be type panel: inventory, equipment, chest
abstract public class BaseWarehouseController : MonoBehaviour
@ -40,6 +41,11 @@ abstract public class BaseWarehouseController : MonoBehaviour
isOpen = false;
}
public KeyValuePair<int, Item> FindItemInWarehouse(string itemName)
{
return this._items.Where(item => item.Value.name == itemName).FirstOrDefault();
}
protected abstract void SetupPanel();
public virtual void SetItemOnPosition(int _keyPosition, Item _item)

View File

@ -0,0 +1,43 @@
# Warehouse
It's the core mechanism on which the entire set of panels available in the game is working.
On the basis of it work modules such as:
* Inventory
* Equippment
* Chest system
## API
### Open Panel
```c#
BaseWarehouseController.Instance.OpenPanel();
```
### Close Panel
```c#
BaseWarehouseController.Instance.OpenPanel();
```
### Find Item
Check if class extending base warehouse structure has the item you are looking for
```c#
var questItem = InventoryManager.Instance.FindItemInWarehouse("lumberjack axe");
if(!questItem.Equals(new KeyValuePair<int, Item>()))
{
// TODO code if item has been found
} else {
// TODO code if item was not found
}
```
### Remove Item
To delete the item, pass its position in the warehouse. You can use result of function above `questItem.Key`
```c#
BaseWarehouseController.Instance.RemoveItemFromPosition(int itemPosition);
```
Insteda of `BaseWarehouseController` you can use one of:
* `InventoryManager`
* `EquipmentManager`
* `ChestController`

View File

@ -30,10 +30,10 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650