- #pragma strict
- //var dialog : GameObject;
- var pauseMenuActive : boolean = false;
- var main : MainClass;
- var menuState : String = "Main";
- var centerScreenWidth : float;
- var centerScreenHeight : float;
- var pauseTexture : Texture;
- var headingSkin : GUISkin;
- var descriptionText : GUISkin;
- var textSkin : GUISkin;
- var skillButtonText : GUISkin;
- var tooltipText : GUISkin;
- private var skillDescription : GUIContent;
- var placementRect : Rect;
- var playerStats : PlayerStats;
- private var player : Transform;
- var pauseMenuBG : Texture ;
- var leftButton : Texture;
- var rightButton : Texture;
- var menuBox : Texture;
- var inventoryScrollPosition : Vector2 = new Vector2(100,100);
- var skillScrollPosition : Vector2 = Vector2.zero;
- var longString = "This is a long-ish string";
- //////////////////////////////////////////////
- // Skills
- var skillA : GUIContent;
- var skillB : GUIContent;
- var skillC : GUIContent;
- var skillD : GUIContent;
- var skillE : GUIContent;
- var skillF : GUIContent;
- var skillG : GUIContent;
- var skillH : GUIContent;
- var skillI : GUIContent;
- var skillJ : GUIContent;
- var skillK : GUIContent;
- var skillL : GUIContent;
- var skillM : GUIContent;
- function Awake(){
- var go : GameObject = GameObject.FindGameObjectWithTag("Player");
- player = go.transform;
- playerStats = player.GetComponent(PlayerStats);
- centerScreenWidth = Screen.width / 2;
- centerScreenHeight = Screen.height / 2;
- placementRect = new Rect(10,10,100,100);
- }
- function Start(){
- DisablePauseMenu();
- }
- function Update(){
- if(Input.GetKeyDown(KeyCode.K)){
- TogglePauseMenu();
- }
- }
- function TogglePauseMenu(){
- switch(pauseMenuActive){
- case true:
- DisablePauseMenu();
- break;
- case false:
- menuState = "Status";
- EnablePauseMenu();
- break;
- }
- }
- function EnablePauseMenu(){
- main.PauseGame();
- Screen.lockCursor = false;
- pauseMenuActive = true;
- }
- function DisablePauseMenu(){
- main.UnpauseGame();
- Screen.lockCursor = true;
- pauseMenuActive = false;
- }
- function OnGUI(){
- if(pauseMenuActive){
- //Check for pause menu background texture
- if(!pauseTexture){
- Debug.LogError("You need to assign a Pause Menu background texture!");
- return;
- }
- //////////////////////////////////////////////////
- // Main Container Group
- GUI.BeginGroup (new Rect (Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 600));
- //Draw background Texture
- GUI.DrawTexture(Rect(0,0,800,600), pauseTexture, ScaleMode.StretchToFill, true, 10.0f);
- GUI.DrawTexture(Rect(64,58,671,485), pauseMenuBG, ScaleMode.StretchToFill, true, 10.0f);
- GUI.color = new Color(1,1,1,1);
- GUI.backgroundColor = Color.clear;
- GUI.skin = headingSkin;
- //Label the menu
- GUI.Label(new Rect(190,75,400,72),menuState);
- /////////////////////////////////////////////
- // Navigation buttons
- GUI.backgroundColor = Color.clear;
- GUI.skin = null;
- if(GUI.Button(Rect(650,80,50,50),rightButton)){
- switch(menuState){
- case "Status":
- menuState = "Inventory";
- break;
- case "Inventory":
- menuState = "Skills";
- break;
- case "Skills":
- menuState = "FadeSkills";
- break;
- case "FadeSkills":
- menuState = "FadeSkills";
- break;
- }
- }
- if(GUI.Button(Rect(100,80,50,50),leftButton)){
- switch(menuState){
- case "Status":
- break;
- case "Inventory":
- menuState = "Status";
- break;
- case "Skills":
- menuState = "Inventory";
- break;
- case "FadeSkills":
- menuState = "Skills";
- break;
- }
- }
- ///////////////////////////////////////////////////
- // Sub Menu Groups
- switch(menuState){
- case "Status":
- GUI.BeginGroup(new Rect(5,75,795,525));
- GUI.DrawTexture(Rect(75,85,300,355),menuBox,ScaleMode.StretchToFill,true,10.0f);
- GUI.DrawTexture(Rect(415,85,300,355),menuBox,ScaleMode.StretchToFill,true,10.0f);
- GUI.skin = textSkin;
- // Vital Stats
- GUI.Label(new Rect(89,89,200,140),"Level: "+playerStats.GetCurrentLevel() +
- "\nHP: "+playerStats.GetCurrentHealth() +"/" +playerStats.GetMaxHealth() +
- "\nEP: "+playerStats.GetCurrentEnergy() +"/" +playerStats.GetMaxEnergy() +
- "\nXP: "+playerStats.GetCurrentXP() +"/" +playerStats.GetXPToLevel()
- );
- //Basic Stats
- GUI.Label(new Rect(89,264,200,150),"Strength: "+playerStats.GetStrength() +
- "\nStamina: " + playerStats.GetStamina() +
- "\nAgility: " + playerStats.GetAgility() +
- "\nWillpower: " + playerStats.GetWillpower()
- );
- GUI.EndGroup();
- break;
- case "Skills":
- GUI.BeginGroup(new Rect(5,75,795,525));
- /////////////////////////////////////////
- // ScrollView
- GUI.skin = skillButtonText;
- GUI.backgroundColor = Color.white;
- skillScrollPosition = GUI.BeginScrollView (new Rect(96,80,600,350),
- skillScrollPosition, Rect (0, 0, 580, 900));
- GUI.backgroundColor = Color.cyan;
- GUI.Box(new Rect(0,0,580,170), "");
- GUI.backgroundColor = Color.blue;
- /////////////////////////////////////////////////
- // Skilltree A
- GUI.Button (Rect (5,42.5,75,75), skillA);
- GUI.Button (Rect (85,5,75,75), skillB);
- GUI.Button (Rect (85,85,75,75), skillC);
- GUI.Button (Rect (165,5,75,75), skillD);
- GUI.Button (Rect (165,85,75,75), skillE);
- GUI.backgroundColor = Color.red;
- GUI.Box(new Rect(0,175,580,170), "");
- GUI.backgroundColor = Color.blue;
- // End the scroll view that we began above.
- GUI.EndScrollView ();
- GUI.backgroundColor = Color.clear;
- //Display the tooltip if there is one
- if(GUI.tooltip){
- GUI.skin = tooltipText;
- GUI.backgroundColor=Color.clear;
- GUI.BeginGroup (Rect (Input.mousePosition.x-230, Screen.height-Input.mousePosition.y-150, 275, 125));
- GUI.DrawTexture(Rect (0,0,275,125),menuBox);
- GUI.Label(Rect (0,0,275,125),GUI.tooltip +"\n" +playerStats.GetCurrentHealth() +"/" +playerStats.GetMaxHealth());
- //GUI.Label(Rect(0,10,250,100), playerStats.GetCurrentHealth() +"/" +playerStats.GetMaxHealth());
- GUI.EndGroup();
- }
- GUI.EndGroup();
- break;
- case "Inventory":
- GUI.BeginGroup(new Rect(5,75,795,525));
- /////////////////////////////////////////
- // ScrollView
- GUI.backgroundColor=Color.gray;
- // Item portrait
- GUI.Box(new Rect(125,77,200,200),"");
- // Item Description
- GUI.skin = descriptionText;
- GUI.Label(new Rect(108,300,235,300),"Descriptive Text Here. Hell I can put whatever I want, I'm just glad to be makin' games!");
- //Inventory List
- inventoryScrollPosition = GUI.BeginScrollView (new Rect(400,80,300,350),
- inventoryScrollPosition, Rect (0, 0, 280, 900));
- GUI.Box(new Rect(0,0,380,900),"");
- // End the scroll view that we began above.
- GUI.EndScrollView ();
- GUI.EndGroup();
- break;
- case "Fade Skill":
- GUI.BeginGroup(new Rect(5,75,795,525));
- /////////////////////////////////////////
- // ScrollView
- GUI.backgroundColor=Color.gray;
- //Item portrait
- //GUI.Box(new Rect(125,77,200,200),"");
- // Item Description
- //GUI.skin = descriptionText;
- //GUI.Label(new Rect(108,300,235,300),"Descriptive Text Here. Hell I can put whatever I want, I'm just glad to be makin' games!");
- //Inventory List
- //inventoryScrollPosition = GUI.BeginScrollView (new Rect(400,80,300,350),
- //inventoryScrollPosition, Rect (0, 0, 280, 900));
- GUI.Box(placementRect,"");
- // End the scroll view that we began above.
- GUI.EndScrollView ();
- GUI.EndGroup();
- break;
- }
- GUI.EndGroup();
- }
- }
- // GUI.box