Advertisement
Guest User

Untitled

a guest
Jun 14th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. enum options {main, health, equipment, supplies, map, telcom}
  4. public class InventoryGUI : MonoBehaviour {
  5. int i = 0;
  6. int a,b;
  7. public static List<Slots> slots = new List<Slots>();
  8. List<Texture2D> icons = new List<Texture2D>();
  9. private options Option = options.main;
  10. public float width, height;
  11. private bool canShowGUI = false;
  12. public static bool dead = false;
  13. public Texture2D Background;
  14. public Texture2D health;
  15. private float healthWidth=0;
  16. public GUISkin leSkin;
  17.  
  18. float x,y;
  19.  
  20. // Use this for initialization
  21. void Start () {
  22. for (int a = 20; a < width-90; a += 70)
  23. {
  24. for (int b = 20; b < height - 50; b += 70)
  25. {
  26. slots.Add(new Slots(a, b));
  27. }
  28.  
  29. }
  30. foreach (Slots slot in slots)
  31. {
  32. Debug.Log (i);
  33. GameManager.items.Add (new Item());
  34. }
  35. }
  36. // Update is called once per frame
  37. void Update () {
  38. x = (Screen.width / 2)-400;
  39. y=(Screen.height/2)-200;
  40. if (Input.GetKeyDown (KeyCode.I)) {
  41.  
  42. canShowGUI = !canShowGUI;
  43. Option = options.main;
  44.  
  45. }
  46. healthWidth = (Mathf.Lerp (GameManager.player.health,0 , 0.15f))*3f;
  47.  
  48. }
  49. void OnGUI(){
  50. GUI.skin = leSkin;
  51. if (canShowGUI) {
  52. GameManager.realPlayer.GetComponentInChildren<MouseLook> ().enabled = false;
  53. GameManager.realPlayer.transform.GetChild (0).transform.GetChild (0).GetComponent<MouseLook> ().enabled = false;
  54. GameManager.GUN.GetComponent<GunShootingScript> ().enabled = false;
  55. //GROUP START
  56. GUI.BeginGroup (new Rect (x, y, width, height));
  57. GUI.DrawTexture (new Rect (0, 0, width, height), Background);
  58. if (GUI.Button (new Rect (width - 70, 15, 50, 50), "Exit")) {
  59. canShowGUI = false;
  60. }
  61. if (GUI.Button (new Rect (width - 70, height - 65, 50, 50), "back")) {
  62. Option = options.main;
  63. }
  64. switch (Option)
  65. {
  66. case options.main:
  67.  
  68. if (GUI.Button(new Rect(100, 40, 150, 40), "Health"))
  69. {
  70. Debug.Log("Action1");
  71. Option = options.health;
  72. }
  73. if (GUI.Button(new Rect(150, 100, 150, 40), "Equipment"))
  74. {
  75. Debug.Log("Action2");
  76. Option = options.equipment;
  77. }
  78. if (GUI.Button(new Rect(200, 160, 150, 40), "Supplies"))
  79. {
  80. Debug.Log("Action3");
  81. Option = options.supplies;
  82. }
  83. if (GUI.Button(new Rect(250, 220, 150, 40), "Map"))
  84. {
  85. Debug.Log("Action4");
  86. Option = options.map;
  87. }
  88. if (GUI.Button(new Rect(300, 280, 150, 40), "Telcom"))
  89. {
  90. Option = options.telcom;
  91. }
  92. break;
  93.  
  94. case options.health:
  95. GUI.Label(new Rect(width - 200, height - 150, 100, 100), "Health");
  96. GUI.DrawTexture(new Rect(width - 300, height - 100, healthWidth, health.height), health);
  97. break;
  98. case options.equipment:
  99. foreach(Slots slot in slots){
  100. if(GUI.Button(new Rect(slot.x, slot.y, 50, 50),GameManager.items[i].icon)){
  101.  
  102. }
  103. if(i < GameManager.items.Count-1) i++;
  104. else i = 0;
  105. }
  106. break; }
  107. GUI.EndGroup ();
  108. //GROUP END
  109.  
  110.  
  111. } else {
  112. GameManager.GUN.GetComponent<GunShootingScript> ().enabled = true;
  113. GameManager.realPlayer.GetComponentInChildren<MouseLook> ().enabled = true;
  114. GameManager.realPlayer.transform.GetChild (0).transform.GetChild (0).GetComponent<MouseLook> ().enabled = true;
  115.  
  116. }
  117.  
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement