Generified ElementStorage.cs and ElementStorageSlot.cs

This commit is contained in:
d-hain 2022-06-17 14:51:44 +02:00
parent df3fad8c51
commit e160867e7e
18 changed files with 210 additions and 212 deletions

View file

@ -2,7 +2,7 @@ using System;
using UnityEngine;
using UnityEngine.EventSystems;
public class InventorySlot : ItemStorageSlot, IPointerClickHandler {
public class InventorySlot : ElementStorageSlot<Item>, IPointerClickHandler {
private Inventory _inventory;
private PlayerController _playerController;
@ -14,10 +14,10 @@ public class InventorySlot : ItemStorageSlot, IPointerClickHandler {
/**
* Gets called when the Inventory Slot is clicked
*/
public override void UseItem() {
if(Item) {
if(Item.GetType() == typeof(UsableItem)) {
((UsableItem)Item).Select();
public override void UseElement() {
if(Element) {
if(Element.GetType() == typeof(UsableItem)) {
((UsableItem)Element).Select();
//Debug.Log("using " + Item.displayName);
} else {
//Debug.Log("Item not usable " + Item.displayName);
@ -33,8 +33,8 @@ public class InventorySlot : ItemStorageSlot, IPointerClickHandler {
public void OnPointerClick(PointerEventData eventData) {
// When clicked on with right Mouse Button sell the Item
if(eventData.button == PointerEventData.InputButton.Right) {
if(Item) {
_inventory.SellItem(Item, 1); //TODO: wie machen mehr als 1 verkaufen?!
if(Element) {
_inventory.SellItem(Element, 1); //TODO: wie machen mehr als 1 verkaufen?!
}
}
}