Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- enum options {main, health, equipment, supplies, map, telcom}
- public class InventoryGUI : MonoBehaviour {
- int i = 0;
- int a,b;
- public static List<Slots> slots = new List<Slots>();
- List<Texture2D> icons = new List<Texture2D>();
- private options Option = options.main;
- public float width, height;
- private bool canShowGUI = false;
- public static bool dead = false;
- public Texture2D Background;
- public Texture2D health;
- private float healthWidth=0;
- public GUISkin leSkin;
- float x,y;
- // Use this for initialization
- void Start () {
- for (int a = 20; a < width-90; a += 70)
- {
- for (int b = 20; b < height - 50; b += 70)
- {
- slots.Add(new Slots(a, b));
- }
- }
- foreach (Slots slot in slots)
- {
- Debug.Log (i);
- GameManager.items.Add (new Item());
- }
- }
- // Update is called once per frame
- void Update () {
- x = (Screen.width / 2)-400;
- y=(Screen.height/2)-200;
- if (Input.GetKeyDown (KeyCode.I)) {
- canShowGUI = !canShowGUI;
- Option = options.main;
- }
- healthWidth = (Mathf.Lerp (GameManager.player.health,0 , 0.15f))*3f;
- }
- void OnGUI(){
- GUI.skin = leSkin;
- if (canShowGUI) {
- GameManager.realPlayer.GetComponentInChildren<MouseLook> ().enabled = false;
- GameManager.realPlayer.transform.GetChild (0).transform.GetChild (0).GetComponent<MouseLook> ().enabled = false;
- GameManager.GUN.GetComponent<GunShootingScript> ().enabled = false;
- //GROUP START
- GUI.BeginGroup (new Rect (x, y, width, height));
- GUI.DrawTexture (new Rect (0, 0, width, height), Background);
- if (GUI.Button (new Rect (width - 70, 15, 50, 50), "Exit")) {
- canShowGUI = false;
- }
- if (GUI.Button (new Rect (width - 70, height - 65, 50, 50), "back")) {
- Option = options.main;
- }
- switch (Option)
- {
- case options.main:
- if (GUI.Button(new Rect(100, 40, 150, 40), "Health"))
- {
- Debug.Log("Action1");
- Option = options.health;
- }
- if (GUI.Button(new Rect(150, 100, 150, 40), "Equipment"))
- {
- Debug.Log("Action2");
- Option = options.equipment;
- }
- if (GUI.Button(new Rect(200, 160, 150, 40), "Supplies"))
- {
- Debug.Log("Action3");
- Option = options.supplies;
- }
- if (GUI.Button(new Rect(250, 220, 150, 40), "Map"))
- {
- Debug.Log("Action4");
- Option = options.map;
- }
- if (GUI.Button(new Rect(300, 280, 150, 40), "Telcom"))
- {
- Option = options.telcom;
- }
- break;
- case options.health:
- GUI.Label(new Rect(width - 200, height - 150, 100, 100), "Health");
- GUI.DrawTexture(new Rect(width - 300, height - 100, healthWidth, health.height), health);
- break;
- case options.equipment:
- foreach(Slots slot in slots){
- if(GUI.Button(new Rect(slot.x, slot.y, 50, 50),GameManager.items[i].icon)){
- }
- if(i < GameManager.items.Count-1) i++;
- else i = 0;
- }
- break; }
- GUI.EndGroup ();
- //GROUP END
- } else {
- GameManager.GUN.GetComponent<GunShootingScript> ().enabled = true;
- GameManager.realPlayer.GetComponentInChildren<MouseLook> ().enabled = true;
- GameManager.realPlayer.transform.GetChild (0).transform.GetChild (0).GetComponent<MouseLook> ().enabled = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement