init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
33
Assets/Scripts/Inventory.cs
Normal file
33
Assets/Scripts/Inventory.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue