Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Inventory : MonoBehaviour {
- private Vector2 ScrollInventory = Vector2.zero;
- //All Items in game
- public List<Item> items = new List<Item>();
- //Player's Inventory
- [HideInInspector]
- public static List<Item> mainInventory = new List<Item>();
- //Equipped Apparel
- //[0] = Head, [1] = Body, [2] = Legs, [3] = Feet, [4] = Hand, [5] = Neck
- List<Item> equippedApparel = new List<Item>();
- //Equipped Weapons/Tools
- //[0] = Left Hand, [1] = Right Hand
- List<Item> equippedWeapons = new List<Item>();
- public GameObject player;
- string currentMenu = "";
- bool open = false;
- void Start() {
- mainInventory.Add (items [0]);
- mainInventory.Add (items [1]);
- mainInventory.Add (items [2]);
- mainInventory.Add (items [3]);
- mainInventory.Add (items [4]);
- mainInventory.Add (items [5]);
- mainInventory.Add (items [6]);
- mainInventory.Add (items [7]);
- mainInventory.Add (items [8]);
- mainInventory.Add (items [9]);
- mainInventory.Add (items [10]);
- mainInventory.Add (items [11]);
- //mainInventory.Add (items [12]);
- }
- void Update() {
- if(Input.GetKeyDown(KeyCode.E)) {
- if(open == false) {
- open = true;
- NavigateTo("Sel");
- } else {
- open = false;
- currentMenu = "";
- }
- }
- if(open == true) {
- player.GetComponent<FirstPersonController>().enabled = false;
- //player.GetComponent<BasicSettings>().enabled = false;
- } else {
- player.GetComponent<FirstPersonController>().enabled = true;
- //player.GetComponent<BasicSettings>().enabled = true;
- currentMenu = "";
- }
- }
- void OnGUI() {
- if(currentMenu == "Sel")
- InvenSelect();
- if(currentMenu == "Weap")
- InvenWeap();
- if(currentMenu == "Tool")
- InvenTool();
- if(currentMenu == "App")
- InvenApperal();
- if(currentMenu == "Food")
- InvenFood();
- if(currentMenu == "Misc")
- InvenMisc();
- /*GUI.Box(new Rect(0, 0, 200, Screen.height), "");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- for(int x = 0;x < items.Count;x++) {
- if(GUILayout.Button("" + items[x].name)) {
- Debug.Log(items[x].desc);
- }
- }
- GUILayout.EndArea();*/
- }
- public void NavigateTo(string nextmenu) {
- currentMenu = nextmenu;
- }
- public void InvenSelect() {
- GUI.Box(new Rect(0, 0, 200, Screen.height), "Inventory");
- if(GUI.Button (new Rect(10, 30, 180, 30), "Weapons")) {
- NavigateTo("Weap");
- }
- if(GUI.Button (new Rect(10, 70, 180, 30), "Apperal")) {
- NavigateTo("App");
- }
- if(GUI.Button (new Rect(10, 110, 180, 30), "Tools")) {
- NavigateTo("Tool");
- }
- if(GUI.Button (new Rect(10, 150, 180, 30), "Food")) {
- NavigateTo("Food");
- }
- if(GUI.Button (new Rect(10, 190, 180, 30), "Misc.")) {
- NavigateTo("Misc");
- }
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- open = false;
- }
- }
- public void InvenWeap() {
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Weapons");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < mainInventory.Count;x++) {
- if(mainInventory[x].type == ItemType.weapon) {
- if(GUILayout.Button("" + mainInventory[x].name)) {
- Debug.Log(mainInventory[x].desc);
- }
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- public void InvenApperal() {
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Apperal");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < mainInventory.Count;x++) {
- if(mainInventory[x].type == ItemType.head || mainInventory[x].type == ItemType.body || mainInventory[x].type == ItemType.legs || mainInventory[x].type == ItemType.feet || mainInventory[x].type == ItemType.hand || mainInventory[x].type == ItemType.neck) {
- if(GUILayout.Button("" + mainInventory[x].name)) {
- Debug.Log(mainInventory[x].desc);
- }
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- public void InvenTool() {
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Tools");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < mainInventory.Count;x++) {
- if(mainInventory[x].type == ItemType.tool) {
- if(GUILayout.Button("" + mainInventory[x].name)) {
- Debug.Log(mainInventory[x].desc);
- }
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- public void InvenFood() {
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Food");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < mainInventory.Count;x++) {
- if(mainInventory[x].type == ItemType.food) {
- if(GUILayout.Button("" + mainInventory[x].name)) {
- Debug.Log(mainInventory[x].desc);
- }
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- public void InvenMisc() {
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Misc");
- ScrollInventory = GUILayout.BeginScrollView(ScrollInventory, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < mainInventory.Count;x++) {
- if(mainInventory[x].type == ItemType.misc) {
- if(GUILayout.Button("" + mainInventory[x].name)) {
- Debug.Log(mainInventory[x].desc);
- }
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement