33 lines
861 B
C#
33 lines
861 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
public static class Inventory
|
|
{
|
|
public static List<GameObject> Items = new List<GameObject>();
|
|
public static int Index = 0;
|
|
public static void cycleItem() {
|
|
if (Items.Count > 0) {
|
|
Index = (Index + 1) % Items.Count;
|
|
}
|
|
}
|
|
public static GameObject getActiveItem() {
|
|
return Items[Index];
|
|
}
|
|
public static void addItem(GameObject go) {
|
|
if (!containsItem(go)) {
|
|
Items.Add(go);
|
|
}
|
|
}
|
|
public static bool containsItem(GameObject i) {
|
|
bool found = false;
|
|
foreach (GameObject a in Items) {
|
|
if (a.name.Equals(i.name)) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
return found;
|
|
}
|
|
}
|