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 Chest : MonoBehaviour {
- public List<Item> chestInventory = new List<Item>();
- public List<Item> playerInventory = Inventory.mainInventory;
- private Vector2 scrollChest;
- private Vector2 scrollMine;
- public string chestName;
- string currentMenu = "";
- bool canClick = false;
- bool canOpen = false;
- bool open = false;
- public GameObject player;
- void Start() {
- }
- void Update() {
- if(Input.GetKeyDown(KeyCode.F) && canClick == true && canOpen == true) {
- open = true;
- }
- if(open == true) {
- currentMenu = "Sel";
- player.GetComponent<FirstPersonController>().enabled = false;
- //player.GetComponent<BasicSettings>().enabled = false;
- } else if(open == false) {
- currentMenu = "";
- player.GetComponent<FirstPersonController>().enabled = true;
- //player.GetComponent<BasicSettings>().enabled = true;
- }
- }
- public void NavigateTo(string nextmenu) {
- currentMenu = nextmenu;
- }
- void OnGUI() {
- if(currentMenu == "Sel")
- InvSelect();
- if(currentMenu == "Chest")
- InvChest();
- if(currentMenu == "Mine")
- InvMine();
- }
- public void InvSelect() {
- GUI.Box(new Rect(0, 0, 200, Screen.height), "Choose Inventory");
- if(GUI.Button(new Rect(10, 40, 180, 30), "Chest")) {
- NavigateTo("Chest");
- }
- if(GUI.Button(new Rect(10, 80, 180, 30), "My Inventory")) {
- NavigateTo("Mine");
- }
- if(GUI.Button(new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- open = false;
- NavigateTo("");
- }
- }
- public void InvChest() {
- Debug.Log("InvChest");
- GUI.Box (new Rect(0, 0, 200, Screen.height), "Weapons");
- scrollChest = GUILayout.BeginScrollView(scrollChest, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < chestInventory.Count;x++) {
- if(GUILayout.Button("" + chestInventory[x].name)) {
- Debug.Log(chestInventory[x].desc);
- }
- }
- GUILayout.EndArea();
- if(GUI.Button (new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- public void InvMine() {
- Debug.Log("InvMine");
- GUI.Box(new Rect(0, 0, 200, Screen.height), "My Inventory");
- scrollMine = GUILayout.BeginScrollView(scrollMine, GUILayout.MaxWidth(200));
- GUILayout.Space(40);
- for(int x = 0;x < playerInventory.Count;x++) {
- if(GUILayout.Button("" + Inventory.mainInventory[x].name)) {
- Debug.Log(Inventory.mainInventory[x].desc);
- }
- }
- if(GUI.Button(new Rect(10, Screen.height - 40, 180, 30), "Back")) {
- NavigateTo("Sel");
- }
- }
- void OnTriggerEnter(Collider other) {
- canClick = true;
- }
- void OnTriggerExit(Collider other){
- canClick = true;
- }
- void OnMouseEnter() {
- canOpen = true;
- }
- void OnMouseExit() {
- canOpen = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement