From 68363672078d194230cc55f28ca0ccd267d57fe6 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Fri, 20 May 2022 08:48:33 +0200 Subject: [PATCH] ItemContainer.cs --- Assets/BaseTile.prefab | 2 +- Assets/Scripts/ItemContainer.cs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/ItemContainer.cs diff --git a/Assets/BaseTile.prefab b/Assets/BaseTile.prefab index 2181f70..d9d5305 100644 --- a/Assets/BaseTile.prefab +++ b/Assets/BaseTile.prefab @@ -121,6 +121,6 @@ MonoBehaviour: m_GameObject: {fileID: 4752245148499717901} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 99a22f4d69ce79542adc91bba6943f86, type: 3} + m_Script: {fileID: 11500000, guid: 3fd8bc1d313319d4f89f11548ccb1b6a, type: 3} m_Name: m_EditorClassIdentifier: diff --git a/Assets/Scripts/ItemContainer.cs b/Assets/Scripts/ItemContainer.cs new file mode 100644 index 0000000..bf8e6ef --- /dev/null +++ b/Assets/Scripts/ItemContainer.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ItemContainer : MonoBehaviour { + public Item[] allItems; + // Start is called before the first frame update + public Item GetItemByName(String name) { + for (int i = 0; i < allItems.Length; i++) { + if (allItems[i].displayName == name) { + return allItems[i]; + } + } + + return null; + } + + public int GetItemIdByName(String name) { + return GetItemByName(name).id; + } +}