Advertisement
Guest User

MainScreenMenu.js

a guest
Jan 15th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2. #pragma implicit
  3. #pragma downcast
  4.  
  5. enum MainMenuState
  6. {
  7.     IDLE,
  8.     OPTIONS,
  9.     GRAPHICS,
  10.     ABOUT,
  11.     CONECTION,
  12. }
  13.  
  14. class MainMenuScreen extends MonoBehaviour
  15. {
  16.  
  17.     private var nameRoom : String = "";
  18.     public var _usePhoton : GameObject;
  19.     public var ShowMainConect : boolean;
  20.     public var gameManager : GameManager;
  21.     public var menuBackground : Texture2D;
  22.     private var menuBackgroundRect : Rect;
  23.     private var limit : int = 8;
  24.     public var windowBackground : Texture2D;
  25.     private var windowBackgroundRect : Rect;
  26.    
  27.     public var playGame : Texture2D;
  28.     public var playGameOver : Texture2D;
  29.     private var playGameRect : Rect;
  30.    
  31.     public var resume : Texture2D;
  32.     public var resumeOver : Texture2D;
  33.     private var resumeRect : Rect;
  34.    
  35.     public var options : Texture2D;
  36.     public var optionsOver : Texture2D;
  37.     private var optionsRect : Rect;
  38.    
  39.     public var graphics : Texture2D;
  40.     public var graphicsOver : Texture2D;
  41.     private var graphicsRect : Rect;
  42.    
  43.     public var about : Texture2D;
  44.     public var aboutOver : Texture2D;
  45.     private var aboutRect : Rect;
  46.    
  47.     public var conect : Texture2D;
  48.     public var conectOver : Texture2D;
  49.     private var conectRect : Rect;
  50.    
  51.     public var hudSkin : GUISkin;
  52.    
  53.     private var panelLeft : GUIStyle;
  54.     private var panelLeftRect : Rect;
  55.    
  56.     private var panelRight : GUIStyle;
  57.     private var panelRightRect : Rect;
  58.    
  59.     private var descriptionStyle : GUIStyle;
  60.     private var titleStyle : GUIStyle;
  61.     private var customBox : GUIStyle;
  62.    
  63.     private var mousePos : Vector2;
  64.     private var screenSize : Vector2;
  65.    
  66.     private var evt : Event;
  67.    
  68.     private var state : MainMenuState;
  69.     private var lastMouseTime : float;
  70.    
  71.     public var receiveDamageOn : Texture2D;
  72.     public var receiveDamageOff : Texture2D;
  73.     public var dontReceiveDamageOn : Texture2D;
  74.     public var dontReceiveDamageOff : Texture2D;
  75.     private var damageRect : Rect;
  76.    
  77.     private var scrollPosition : Rect;
  78.     private var scrollView : Rect;
  79.     private var scroll : Vector2;
  80.    
  81.     public var black : Texture2D;
  82.     private var alpha : float;
  83.     static public var goingToGame : boolean;
  84.     static public var showProgress : boolean;
  85.    
  86.     private var aboutScroll : Vector2;
  87.     private var connectScroll : Vector2;
  88.     private var graphicsScroll : Vector2;
  89.     private var aboutStyle : GUIStyle;
  90.     private var conectStyle: GUIStyle;
  91.     private var resumeGame : boolean;
  92.     public var visible : boolean;
  93.    
  94.     private var sliderBackground : GUIStyle;
  95.     private var sliderButton : GUIStyle;
  96.    
  97.     public var greenBar : Texture2D;
  98.     public var checkOn : Texture2D;
  99.     public var checkOff : Texture2D;
  100.     public var whiteMarker : Texture2D;
  101.    
  102.     private var margin : float  = 30;
  103.  
  104.     private var questionRect : Rect;
  105.     private var greenRect : Rect;
  106.     private var tooltipStyle : GUIStyle;
  107.     private var questionButtonStyle : GUIStyle;
  108.    
  109.     private var aquirisLogo : GUIStyle;
  110.     private var unityLogo : GUIStyle;
  111.     private var textFieldStyle : GUIStyle;
  112.     public var overSound : AudioClip;
  113.     public var overVolume : float = 0.4;
  114.  
  115.     public var clickSound : AudioClip;
  116.     public var clickVolume : float = 0.7;
  117.    
  118.     private var over : boolean;
  119.     private var hideOptions : boolean;
  120.     private var loadingIndustry : boolean;
  121.  
  122.     public var textStyle : GUIStyle;
  123.     private var angle : float;
  124.     public var loadingBackground : Texture2D;
  125.    
  126.     var GameList : Hashtable = new Hashtable();
  127.  
  128.     function PushList(_gameList : Hashtable)
  129.     {
  130.         if(_gameList != GameList)
  131.         {
  132.             GameList.Clear();
  133.             GameList = _gameList;
  134.         }
  135.     }
  136.     function ShowMainConection()
  137.     {
  138.         ShowMainConect = true;
  139.     }
  140.  
  141.     function Awake()
  142.     {
  143.         angle = 0.0;
  144.         over = false;
  145.         loadingIndustry = false;
  146.         showProgress = false;
  147.         hideOptions = Application.loadedLevelName != "demo_industry";
  148. GameManager.receiveDamage = true;
  149.         questionButtonStyle = hudSkin.GetStyle("QuestionButton");
  150.         tooltipStyle = hudSkin.GetStyle("TooltipStyle");
  151.         aquirisLogo = hudSkin.GetStyle("AquirisLogo");
  152.         unityLogo = hudSkin.GetStyle("UnityLogo");
  153.         questionRect = new Rect(0, 0, 11, 11);
  154.         textFieldStyle = hudSkin.GetStyle("textField");
  155.         alpha = 1.0;
  156.         goingToGame = false;
  157.         resumeGame = false;
  158.        
  159.         state = MainMenuState.IDLE;
  160.        
  161.         descriptionStyle = hudSkin.GetStyle("Description");
  162.         titleStyle = hudSkin.GetStyle("Titles");
  163.         customBox = hudSkin.GetStyle("CustomBox");
  164.         panelLeft = hudSkin.GetStyle("PanelLeft");
  165.         panelRight = hudSkin.GetStyle("PanelRight");
  166.         aboutStyle = hudSkin.GetStyle("About");
  167.         conectStyle = hudSkin.GetStyle("Conect");
  168.        
  169.         menuBackgroundRect = new Rect(0, 0, menuBackground.width, menuBackground.height);
  170.         windowBackgroundRect = new Rect(0, 0, windowBackground.width, windowBackground.height);
  171.  
  172.         panelLeftRect = new Rect(0, 0, 235, 240);
  173.         panelRightRect = new Rect(0, 0, 235, 240);
  174.         playGameRect = new Rect(0, 0, playGame.width * 0.75, playGame.height * 0.75);
  175.         optionsRect = new Rect(0, 0, options.width * 0.75, options.height * 0.75);
  176.         graphicsRect = new Rect(0, 0, graphics.width * 0.75, graphics.height * 0.75);
  177.         aboutRect = new Rect(0, 0, about.width * 0.75, about.height * 0.75);
  178.         conectRect = new Rect(0, 0, conect.width * 0.75, conect.height * 0.75);
  179.         resumeRect = new Rect(0, 0, resume.width * 0.75, resume.height * 0.75);
  180.         damageRect = new Rect(0, 0, receiveDamageOn.width * 0.7, receiveDamageOn.height * 0.7);
  181.  
  182.     }
  183.    
  184.     function Update()
  185.     {
  186.    
  187.         if(goingToGame)
  188.         {
  189.             alpha += Time.deltaTime;
  190.            
  191.             if(alpha >= 1.0)
  192.             {
  193.                 if(!loadingIndustry)
  194.                 {
  195.                     loadingIndustry = true;
  196.                     Application.LoadLevelAsync("demo_industry");
  197.                 }
  198.             }
  199.         }
  200.         else
  201.         {
  202.        
  203.             if(alpha > 0 && gameManager.showMenu == false)
  204.             {
  205.                 alpha -= Time.deltaTime * 0.5;
  206.             }
  207.         }
  208.        
  209.         if(Time.timeScale == 0.0 || GameManager.showMenu)
  210.         {
  211.             lastMouseTime -= 0.01;
  212.         }
  213.  
  214.         if(showProgress)
  215.         {
  216.             angle -= Time.deltaTime * 360;
  217.  
  218.             if(angle < -360.0)
  219.             {
  220.                 angle += 360.0;
  221.             }
  222.         }
  223.     }
  224.    
  225.     function DrawGUI(event : Event)
  226.     {
  227.    
  228.         evt = event;
  229.         screenSize = new Vector2(Screen.width, Screen.height);
  230.         mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
  231.        
  232.         if(visible)
  233.         {
  234.             if(state != MainMenuState.IDLE)
  235.             {
  236.                 windowBackgroundRect.x = menuBackgroundRect.x + menuBackgroundRect.width;
  237.                 windowBackgroundRect.y = (screenSize.y - windowBackgroundRect.height) * 0.5;
  238.            
  239.                 GUI.DrawTexture(windowBackgroundRect, windowBackground);
  240.                
  241.                 if(state == MainMenuState.GRAPHICS || state == MainMenuState.ABOUT || state == MainMenuState.CONECTION)
  242.                 {
  243.                     panelLeftRect.width = 475;
  244.                     panelLeftRect.x = windowBackgroundRect.x + 15;
  245.                     panelLeftRect.y = windowBackgroundRect.y + 55;
  246.            
  247.                     GUI.Box(panelLeftRect, "", panelLeft);
  248.                 }
  249.             }
  250.            
  251.             if(state == MainMenuState.OPTIONS)
  252.             {
  253.                 DrawGameOptions();
  254.             }
  255.             else if(state == MainMenuState.GRAPHICS)
  256.             {
  257.                 DrawGraphicOptions();
  258.             }
  259.             else if(state == MainMenuState.ABOUT)
  260.             {
  261.                 DrawAbout();
  262.             }
  263.             else if(state == MainMenuState.CONECTION)
  264.             {
  265.                 DrawConection();
  266.                  
  267.             }
  268.            
  269.             DrawMenu();
  270.         }
  271.        
  272.  
  273.  
  274.         if(showProgress)
  275.         {  
  276.             var currentProgress : float = IndustryLoader.industryProgress;//Application.GetStreamProgressForLevel("demo_industry");
  277.             currentProgress *= 100.0;
  278.             var aux : int = currentProgress;
  279.             currentProgress = aux;
  280.  
  281.             if(currentProgress < 1.0)
  282.             {
  283.                 GUIUtility.RotateAroundPivot(angle, new Vector2(Screen.width - 28, Screen.height - 28));
  284.                 GUI.DrawTexture(Rect(Screen.width - 56, Screen.height - 56, 56, 56), loadingBackground, ScaleMode.ScaleToFit, true, 0);
  285.  
  286.                 GUI.matrix = Matrix4x4.identity;
  287.                 GUI.Label(new Rect(Screen.width - 52, Screen.height - 36, 50, 20), currentProgress.ToString(), textStyle);
  288.             }
  289.         }
  290.                
  291.         if(alpha > 0.0)
  292.         {
  293.             var c : Color = GUI.color;
  294.             var d : Color = c;
  295.             d.a = alpha;
  296.             GUI.color = d;
  297.        
  298.             GUI.DrawTexture(new Rect(0, 0, screenSize.x, screenSize.y), black);
  299.  
  300.             if(goingToGame)
  301.             {
  302.                 GUI.Label(new Rect(Screen.width - 120, Screen.height - 40, 90, 20), "Loading...", textStyle);
  303.             }
  304.             GUI.color = c;
  305.         }
  306.         if(ShowMainConect)
  307.             MainConection();
  308.     }
  309.    
  310.     function DrawGameOptions()
  311.     {
  312.         panelLeftRect.width = 235;
  313.         panelLeftRect.x = windowBackgroundRect.x + 15;
  314.         panelLeftRect.y = windowBackgroundRect.y + 55;
  315.  
  316.         panelRightRect.x = panelLeftRect.x + 5 + panelLeftRect.width;
  317.         panelRightRect.y = panelLeftRect.y;
  318.        
  319.         damageRect.x = panelLeftRect.x + ((panelLeftRect.width - damageRect.width) * 0.5);
  320.         damageRect.y = panelLeftRect.y + ((panelLeftRect.height - damageRect.height) * 0.5);
  321.        
  322.         var dRect = damageRect;
  323.         dRect.x = panelRightRect.x + ((panelRightRect.width - damageRect.width) * 0.5);
  324.        
  325.         if(evt.current.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  326.         {
  327.             if(damageRect.Contains(mousePos))
  328.             {
  329.                 if(!GameManager.receiveDamage)
  330.                 {
  331.                     audio.volume = clickVolume;
  332.                     audio.PlayOneShot(clickSound);
  333.                     GameManager.receiveDamage = true;  
  334.                     lastMouseTime = Time.time;
  335.                 }
  336.             }
  337.             else if(dRect.Contains(mousePos))
  338.             {
  339.                 if(GameManager.receiveDamage)
  340.                 {
  341.                     audio.volume = clickVolume;
  342.                     audio.PlayOneShot(clickSound);
  343.                     GameManager.receiveDamage = false;
  344.                     lastMouseTime = Time.time;
  345.                 }
  346.             }
  347.         }
  348.        
  349.         if(GameManager.receiveDamage)
  350.         {
  351.             GUI.DrawTexture(damageRect, receiveDamageOn);
  352.             GUI.DrawTexture(dRect, dontReceiveDamageOff);
  353.         }
  354.         else
  355.         {
  356.             GUI.DrawTexture(damageRect, receiveDamageOff);
  357.             GUI.DrawTexture(dRect, dontReceiveDamageOn);
  358.         }
  359.        
  360.         GUI.Label(new Rect(windowBackgroundRect.x + 20, windowBackgroundRect.y + 15, 200, 20), "GAME OPTIONS", titleStyle);
  361.     }
  362.    
  363.    
  364.     private var sceneConf : SceneSettings;
  365.     function GetSceneRef()
  366.     {
  367.         //var currentScene : int = Application.loadedLevel;
  368.         var currentScene : int;// = Application.loadedLevel;
  369.        
  370.         if(Application.loadedLevelName == "demo_start_cutscene")
  371.         {
  372.             currentScene = 0;
  373.         }
  374.         else if(Application.loadedLevelName == "demo_forest")
  375.         {
  376.             currentScene = 1;
  377.         }
  378.         else if(Application.loadedLevelName == "demo_industry")
  379.         {
  380.             currentScene = 2;
  381.         }
  382.  
  383.         if(GameQualitySettings.scenes != null)
  384.         {
  385.             if(currentScene >= 0 && currentScene < GameQualitySettings.scenes.Length)
  386.             {
  387.                 sceneConf = GameQualitySettings.scenes[currentScene];      
  388.             }
  389.             else
  390.             {
  391.                 currentScene = -1;
  392.             }
  393.         }
  394.         else
  395.         {
  396.             currentScene = -1;
  397.         }
  398.     }
  399.    
  400.     private function DrawSliderOverlay (rect : Rect, val : float)
  401.     {
  402.         rect.width = Mathf.Clamp(val * 199.0, 0.0, 199.0);
  403.         GUI.DrawTexture (rect, greenBar);
  404.     }
  405.        
  406.     private function SettingsSlider (name : String, nameLen : int, tooltip : String, v : float, vmin : float, vmax : float, dispname : String, dispmul : float, dispadd : float)
  407.     {
  408.         GUILayout.BeginHorizontal();
  409.         GUILayout.Space(margin);
  410.         GUILayout.BeginVertical();
  411.         GUILayout.Label (name);
  412.                
  413.         questionRect.x = margin + nameLen;
  414.         questionRect.y += 39;
  415.         GUI.Button(questionRect, GUIContent(String.Empty, tooltip), questionButtonStyle);
  416.        
  417.         v = GUILayout.HorizontalSlider(v, vmin, vmax, GUILayout.Width(210));
  418.         greenRect.y += 39;
  419.         DrawSliderOverlay (greenRect, Mathf.InverseLerp (vmin, vmax, v));
  420.        
  421.         var disp = v * dispmul + dispadd;
  422.         GUI.Label(new Rect(greenRect.x + 220, greenRect.y - 7, 200, 20), dispname + disp.ToString("0.00"));
  423.        
  424.         GUILayout.EndVertical();
  425.         GUILayout.EndHorizontal();
  426.        
  427.         return v;
  428.     }
  429.    
  430.     private function SettingsIntSlider (name : String, nameLen : int, tooltip : String, v : int, vmin : int, vmax : int, dispnames : String[])
  431.     {
  432.         GUILayout.BeginHorizontal();
  433.         GUILayout.Space(margin);
  434.         GUILayout.BeginVertical();
  435.         GUILayout.Label (name);
  436.                
  437.         questionRect.x = margin + nameLen;
  438.         questionRect.y += 39;
  439.         GUI.Button(questionRect, GUIContent(String.Empty, tooltip), questionButtonStyle);
  440.        
  441.         v = GUILayout.HorizontalSlider(v, vmin, vmax, GUILayout.Width(210));
  442.         greenRect.y += 39;
  443.         DrawSliderOverlay (greenRect, Mathf.InverseLerp (vmin, vmax, v));
  444.        
  445.         GUI.Label(new Rect(greenRect.x + 220, greenRect.y - 7, 200, 20), dispnames == null ? v.ToString() : dispnames[v]);
  446.        
  447.         if (Mathf.Abs(vmin-vmax) < 8)
  448.             DrawMarker (greenRect.y + 5, Mathf.Abs(vmin-vmax));
  449.        
  450.         GUILayout.EndVertical();
  451.         GUILayout.EndHorizontal();
  452.        
  453.         return v;
  454.     }
  455.    
  456.     private function SettingsSpace (pix:int)
  457.     {
  458.         GUILayout.Space (pix);
  459.         questionRect.y += pix;
  460.         greenRect.y += pix;
  461.     }
  462.    
  463.     private function SettingsToggle (v : boolean, name : String, nameLen : int, tooltip : String) : boolean
  464.     {
  465.         GUILayout.BeginVertical();
  466.         GUILayout.Space(7);
  467.         v = GUILayout.Toggle (v, v ? checkOn : checkOff, GUILayout.Width(14), GUILayout.Height(14));
  468.         GUILayout.EndVertical();
  469.         GUILayout.Space(5);
  470.         GUILayout.Label(name);
  471.         questionRect.x = margin + nameLen;
  472.         GUI.Button (questionRect, GUIContent(String.Empty, tooltip), questionButtonStyle);
  473.         return v;
  474.     }
  475.    
  476.     private function BeginToggleRow ()
  477.     {
  478.         GUILayout.BeginHorizontal();
  479.         GUILayout.Space(margin);
  480.         GUILayout.BeginVertical();
  481.         GUILayout.BeginHorizontal(GUILayout.Width(400));
  482.         questionRect.y += 21;
  483.     }
  484.    
  485.     private function EndToggleRow (pix : int)
  486.     {
  487.         GUILayout.Space (pix);     
  488.         GUILayout.EndHorizontal();
  489.         GUILayout.EndVertical();
  490.         GUILayout.EndHorizontal();
  491.     }
  492.    
  493.     function DrawGraphicOptions()
  494.     {
  495.         GetSceneRef();
  496.        
  497.         var currentQualityLevel : int = QualitySettings.currentLevel;
  498.         var originalColor : Color = GUI.color;
  499.  
  500.         if(sceneConf == null) return;
  501.        
  502.         GUI.Label(new Rect(windowBackgroundRect.x + 20, windowBackgroundRect.y + 15, 200, 20), "GRAPHICS OPTIONS", titleStyle);
  503.        
  504.         var graphicRect : Rect = new Rect(panelLeftRect.x + 7, panelLeftRect.y + 30, panelLeftRect.width - 9, panelLeftRect.height - 35);
  505.        
  506.         var cSkin : GUISkin = GUI.skin;
  507.         GUI.skin = hudSkin;
  508.        
  509.         greenRect = new Rect(margin, 0, 210, 5);
  510.  
  511.         GUILayout.BeginArea(graphicRect);
  512.         graphicsScroll = GUILayout.BeginScrollView(graphicsScroll, GUILayout.Width(graphicRect.width));
  513.        
  514.         var boxRect = new Rect(17, 0, 430, 0);
  515.         // overall level
  516.         boxRect.height = 18 + 39;
  517.         GUI.Box(boxRect, "", customBox);
  518.         // post-fx
  519.         boxRect.y += 10 + boxRect.height;
  520.         boxRect.height = 93;
  521.         GUI.Box(boxRect, "", customBox);
  522.         // distances
  523.         boxRect.y += 10 + boxRect.height;
  524.         boxRect.height = 18 + 39;
  525.         GUI.Box(boxRect, "", customBox);
  526.         // shadow distance
  527.         boxRect.y += 10 + boxRect.height;
  528.         boxRect.height = 18 + 39;
  529.         GUI.Box(boxRect, "", customBox);
  530.         // texture limit
  531.         boxRect.y += 10 + boxRect.height;
  532.         boxRect.height = 18 + 39;
  533.         GUI.Box(boxRect, "", customBox);
  534.         // terrain
  535.         boxRect.y += 10 + boxRect.height;
  536.         boxRect.height = 18 + 39 * 7;
  537.         GUI.Box(boxRect, "", customBox);
  538.        
  539.         GUILayout.BeginVertical();
  540.         questionRect.y = -31;
  541.         greenRect.y = -9;
  542.        
  543.         GameQualitySettings.overallQuality = SettingsIntSlider (
  544.             "Overall Quality Level", 125, "Overall quality level of the game.",
  545.             GameQualitySettings.overallQuality, 0, 5,
  546.             ["QUALITY: FASTEST", "QUALITY: FAST", "QUALITY: SIMPLE", "QUALITY: GOOD", "QUALITY: BEAUTIFUL", "QUALITY: FANTASTIC"]);
  547.        
  548.         GUILayout.Space(29);
  549.         questionRect.y += 47;
  550.        
  551.         BeginToggleRow ();
  552.         GameQualitySettings.anisotropicFiltering = SettingsToggle (GameQualitySettings.anisotropicFiltering, "Anisotropic Filtering", 153, "Anisotropic filtering for the textures.");
  553.         GUILayout.FlexibleSpace();
  554.         GameQualitySettings.ambientParticles = SettingsToggle (GameQualitySettings.ambientParticles, "Ambient Particles", 355, "Smoke & dust particles.");
  555.         EndToggleRow (50);
  556.  
  557.         BeginToggleRow ();
  558.         GameQualitySettings.colorCorrection = SettingsToggle (GameQualitySettings.colorCorrection, "Color Correction", 128, "Color correction image effect.");
  559.         GUILayout.FlexibleSpace();
  560.         GameQualitySettings.bloomAndFlares = SettingsToggle (GameQualitySettings.bloomAndFlares, "Bloom & Flares", 336, "Bloom & Lens Flares image effect.");
  561.         EndToggleRow (71);
  562.  
  563.         BeginToggleRow ();
  564.         GameQualitySettings.sunShafts = SettingsToggle (GameQualitySettings.sunShafts, "Sun Shafts", 100, "Sun Shafts image effect.");
  565.         GUILayout.FlexibleSpace();
  566.         GameQualitySettings.depthOfFieldAvailable = SettingsToggle (GameQualitySettings.depthOfFieldAvailable, "Depth Of Field", 336, "Depth Of Field image effect while aiming.");
  567.         EndToggleRow (73);
  568.  
  569.         BeginToggleRow (); 
  570.         var ssaoEnable : boolean = SettingsToggle (GameQualitySettings.ssao, "SSAO", 60, "Screen Space Ambient Ccclusion image effect.");
  571.         if(GameQualitySettings.overallQuality > 3) 
  572.              GameQualitySettings.ssao = ssaoEnable;
  573.         GUILayout.FlexibleSpace();
  574.         EndToggleRow (0);
  575.        
  576.         greenRect.y += 113;
  577.         questionRect.y -= 18;
  578.        
  579.         SettingsSpace (25);
  580.        
  581.         GameQualitySettings.dynamicObjectsFarClip = SettingsSlider (
  582.             "Dynamic Objects Far Distance", 180, "Drawing distance of dynamic objects.",
  583.             GameQualitySettings.dynamicObjectsFarClip, 0.0, 1.0, "DYNAMIC: ",
  584.             GameQualitySettings._dynamicLayersRange.y - GameQualitySettings._dynamicLayersRange.x, GameQualitySettings._dynamicLayersRange.x);
  585.        
  586.         SettingsSpace (27);
  587.        
  588.         GameQualitySettings.shadowDistance = SettingsSlider (
  589.             "Shadow Distance", 108, "Realtime shadows drawing distance.",
  590.             GameQualitySettings.shadowDistance, 0.0, 30.0, "",
  591.             1.0, 0.0);
  592.            
  593.         SettingsSpace (28);
  594.        
  595.         GameQualitySettings.masterTextureLimit = SettingsIntSlider (
  596.             "Texture Quality", 100, "Overall texture detail.",
  597.             GameQualitySettings.masterTextureLimit, 3, 0,
  598.             ["FULL RESOLUTION", "HALF RESOLUTION", "QUARTER RESOLUTION", "1/8 RESOLUTION"]);
  599.        
  600.         SettingsSpace (27);
  601.        
  602.         sceneConf.detailObjectDensity = SettingsSlider (
  603.             "Terrain Grass Density", 136, "Grass density.",
  604.             sceneConf.detailObjectDensity, 0.0, 1.0, "",
  605.             1.0, 0.0);
  606.            
  607.         sceneConf.detailObjectDistance = SettingsSlider (
  608.             "Terrain Grass Distance", 141, "Grass drawing distance.",
  609.             sceneConf.detailObjectDistance, 0.0, 50.0, "",
  610.             1.0, 0.0);
  611.            
  612.         sceneConf.nearTerrainPixelError = SettingsSlider (
  613.             "Terrain Pixel Error", 146, "Set terrain pixel error.",
  614.             sceneConf.nearTerrainPixelError, 50.0, 5.0, "",
  615.             1.0, 0.0);
  616.        
  617.         sceneConf.treeDistance = SettingsSlider (
  618.             "Terrain Tree Distance", 137, "Tree drawing distance.",
  619.             sceneConf.treeDistance, 200.0, 400.0, "",
  620.             1.0, 0.0);
  621.        
  622.         sceneConf.heightmapMaximumLOD = SettingsIntSlider (
  623.             "Terrain Level of Detail", 139, "Overall terrain Level of Detail.",
  624.             sceneConf.heightmapMaximumLOD, 2, 0,
  625.             ["FULL RESOLUTION", "QUARTER RESOLUTION", "1/16 RESOLUTION"]);
  626.        
  627.         sceneConf.terrainTreesBillboardStart = SettingsSlider (
  628.             "Terrain Billboard Start", 140, "Distance from the camera where trees will be rendered as billboards.",
  629.             sceneConf.terrainTreesBillboardStart, 10.0, 70.0, "",
  630.             1.0, 0.0);
  631.            
  632.         sceneConf.maxMeshTrees = SettingsIntSlider (
  633.             "Max Mesh Trees", 100, "Set the maximum number of trees rendered at full LOD.",
  634.             sceneConf.maxMeshTrees, 5, 60,
  635.             null);
  636.        
  637.         GUILayout.Space(20);
  638.            
  639.         GUILayout.EndVertical();
  640.    
  641.         GUILayout.EndScrollView();
  642.         GUILayout.EndArea();
  643.        
  644.         if(GUI.tooltip != "")
  645.         {
  646.             GUI.Label(new Rect(mousePos.x + 15, mousePos.y - 60, 150, 70), GUI.tooltip, tooltipStyle);
  647.         }
  648.        
  649.         GUI.skin = cSkin;
  650.     }
  651.    
  652.     function DrawMarker(y : float, steps : int)
  653.     {
  654.         var markerRect : Rect = new Rect(margin, y + 2, 1, 5);
  655.         var aux : float;
  656.         var s : float = steps;
  657.        
  658.         for(var i : int = 0; i <= steps; i++)
  659.         {
  660.             aux = i;
  661.             aux     /= s;
  662.             markerRect.x = margin + 5 + aux * 196;
  663.            
  664.             GUI.DrawTexture(markerRect, whiteMarker);
  665.         }
  666.     }
  667.    
  668.     function DrawAbout()
  669.     {
  670.         GUI.Label(new Rect(windowBackgroundRect.x + 20, windowBackgroundRect.y + 15, 200, 20), "ABOUT", titleStyle);   
  671.        
  672.         var abRect : Rect = new Rect(panelLeftRect.x + 7, panelLeftRect.y + 30, panelLeftRect.width - 12, panelLeftRect.height - 40);
  673.  
  674.         var cSkin : GUISkin = GUI.skin;
  675.         GUI.skin = hudSkin;
  676.  
  677.         GUILayout.BeginArea(abRect);
  678.         aboutScroll = GUILayout.BeginScrollView(aboutScroll, GUILayout.Width(abRect.width));
  679.        
  680.         GUILayout.BeginHorizontal();
  681.         GUILayout.Space(17);
  682.         GUILayout.BeginVertical();
  683.         GUILayout.Label("Developed by Aquiris Game Experience and Unity Technologies ApS.", aboutStyle, GUILayout.Width(423));
  684.         GUILayout.Space(5);
  685.         var names : String;
  686.         names = "Alessandro Peixoto Lima, ";
  687.         names += "Amilton Diesel, ";
  688.         names += "Andre Schaan, ";
  689.         names += "Aras Pranckevicius, ";
  690.         names += "Bret Church, ";
  691.         names += "Ethan Vosburgh, ";
  692.         names += "Gustavo Allebrandt, ";
  693.         names += "Israel Mendes, ";
  694.         names += "Henrique Geremia Nievinski, ";
  695.         names += "Jakub Cupisz, ";
  696.         names += "Joe Robins, ";
  697.         names += "Marcelo Ferranti, ";
  698.         names += "Mauricio Longoni, ";
  699.         names += "Ole Ciliox, ";
  700.         names += "Rafael Rodrigues, ";
  701.         names += "Raphael Lopes Baldi, ";
  702.         names += "Robert Cupisz, ";
  703.         names += "Rodrigo Peixoto Lima, ";
  704.         names += "Rune Skovbo Johansen, ";
  705.         names += "Wagner Monticelli.";
  706.         GUILayout.Label(names, GUILayout.Width(400));
  707.         GUILayout.Space(20);
  708.         GUILayout.Label("Special thanks to:", aboutStyle, GUILayout.Width(423));
  709.         GUILayout.Space(5);
  710.         names = "Cristiano Bartel, ";
  711.         names += "Daniel Merkel, ";
  712.         names += "Felipe Lahti, ";
  713.         names += "Kely Cunha, ";
  714.         names += "Otto Lopes, ";
  715.         names += "Rory Jennings.";
  716.         GUILayout.Label(names, GUILayout.Width(400));
  717.  
  718.         GUILayout.Space(70);
  719.         GUI.DrawTexture(new Rect(170, 180, 339 * 0.75, 94 * 0.75), aquirisLogo.normal.background);
  720.        
  721.         GUILayout.EndVertical();
  722.         GUILayout.EndHorizontal();
  723.        
  724.         GUILayout.EndScrollView();
  725.        
  726.         GUILayout.EndArea();
  727.  
  728.         GUI.skin = cSkin;
  729.     }
  730.    
  731.     function MainConection()
  732.     {
  733.         GUI.DrawTexture(new Rect((Screen.width / 2) - (windowBackground.width / 2), (Screen.height / 2) - (windowBackground.height / 2), windowBackground.width, windowBackground.height), windowBackground);
  734.         GUI.Box(new Rect(((Screen.width / 2) - (windowBackground.width / 2))+8, ((Screen.height / 2) - (windowBackground.height / 2))+49, windowBackground.width-50, windowBackground.height-69), "", panelLeft);
  735.         //new Rect(247.00f-100,194.50f,475f,240f), "", panelLeft);
  736.         GUI.Label(new Rect(((Screen.width / 2) - (windowBackground.width / 2))+20, ((Screen.height / 2) - (windowBackground.height / 2))+10, windowBackground.width-12, windowBackground.height-80), "Rooms", titleStyle); 
  737.        
  738.         var coRect : Rect =new Rect(((Screen.width / 2) - (windowBackground.width / 2))+9, ((Screen.height / 2) - (windowBackground.height / 2))+50, windowBackground.width-58, windowBackground.height-70);// new Rect(247f + 7f-100, 194.50f + 10f, 475f - 12f, 240f - 20f);
  739.  
  740.         var cSkin : GUISkin = GUI.skin;
  741.         GUI.skin = hudSkin;
  742.         GUILayout.BeginArea(coRect);
  743.         GUILayout.BeginHorizontal( );
  744.             GUILayout.Space(8);
  745.             GUILayout.Label("Room Name",conectStyle,GUILayout.Width(coRect.width/3));
  746.             GUILayout.Space(80);
  747.             GUILayout.Label("Connected Players " ,conectStyle,GUILayout.Width(coRect.width/3));
  748.         GUILayout.EndHorizontal();
  749.             GUILayout.Space(5);
  750.         connectScroll = GUILayout.BeginScrollView(connectScroll, GUILayout.Width(coRect.width));
  751.        
  752.         for(var key : DictionaryEntry  in GameList)
  753.         {
  754.             var numofPlayers : int = parseInt(key.Value.ToString());
  755.             if(numofPlayers != 0)
  756.             {
  757.                 GUILayout.BeginHorizontal(GUI.skin.GetStyle("box"));
  758.                     GUILayout.Label(key.Key+"",conectStyle,GUILayout.Width(coRect.width/3));
  759.                     GUILayout.Space(80);
  760.                     GUILayout.Label("Players: " + key.Value,conectStyle,GUILayout.Width(coRect.width/3));
  761.                    
  762.                     if(numofPlayers < limit)
  763.                     {
  764.                         if (GUILayout.Button("Go",conectStyle,GUILayout.Width(coRect.width/10)) )
  765.                         {
  766.                             ShowMainConect =false;
  767.                             _usePhoton.SendMessage("JoinToLobby",key.Key);
  768.                             gameManager.initGame();
  769.                         }
  770.                     }
  771.                     else
  772.                     {
  773.                         GUILayout.Label("Full",conectStyle,GUILayout.Width(coRect.width/10));
  774.                     }
  775.                 GUILayout.EndHorizontal();
  776.             }
  777.         }
  778.         //GameList
  779.  
  780.         GUILayout.EndScrollView();
  781.         GUILayout.Space(0);
  782.         GUILayout.BeginHorizontal();
  783.         GUILayout.Label("Create New Room:",hudSkin.GetStyle("Create"),GUILayout.Width(coRect.width/3));
  784.         nameRoom = GUILayout.TextField(nameRoom,textFieldStyle,GUILayout.Width(coRect.width/3));
  785.                 if (GUILayout.Button("OK",hudSkin.GetStyle("Create"),GUILayout.Width(coRect.width/8)) && nameRoom.length > 0 || Input.GetKeyUp(KeyCode.KeypadEnter) || Input.GetKeyUp(KeyCode.Return))
  786.                 {
  787.                     if(nameRoom != ""){
  788.                     ShowMainConect =false;
  789.                         _usePhoton.SendMessage("JoinToLobby",nameRoom);
  790.                         nameRoom = "";
  791.                         gameManager.initGame();
  792.                     }
  793.                 }
  794.         GUILayout.EndHorizontal();
  795.         GUILayout.Space(5);
  796.         GUILayout.EndArea();
  797.         GUI.skin = cSkin;
  798.     }
  799.    
  800.     function DrawConection()
  801.     {
  802.         GUI.Label(new Rect(windowBackgroundRect.x + 20, windowBackgroundRect.y + 15, 200, 20), "Rooms", titleStyle);   
  803.        
  804.         var coRect : Rect = new Rect(panelLeftRect.x + 7, panelLeftRect.y + 10, panelLeftRect.width - 12, panelLeftRect.height - 20);
  805.  
  806.         var cSkin : GUISkin = GUI.skin;
  807.         GUI.skin = hudSkin;
  808.         GUILayout.BeginArea(coRect);
  809.         GUILayout.BeginHorizontal( );
  810.             GUILayout.Space(8);
  811.             GUILayout.Label("Room Name",conectStyle,GUILayout.Width(coRect.width/3));
  812.             GUILayout.Space(80);
  813.             GUILayout.Label("Connected Players " ,conectStyle,GUILayout.Width(coRect.width/3));
  814.         GUILayout.EndHorizontal();
  815.             GUILayout.Space(5);
  816.         connectScroll = GUILayout.BeginScrollView(connectScroll, GUILayout.Width(coRect.width));
  817.        
  818.         for(var key : DictionaryEntry  in GameList)
  819.         {
  820.             var numofPlayers : int = parseInt(key.Value.ToString());
  821.             if(numofPlayers != 0)
  822.             {
  823.                 GUILayout.BeginHorizontal(GUI.skin.GetStyle("box"));
  824.                     GUILayout.Label(key.Key+"",conectStyle,GUILayout.Width(coRect.width/3));
  825.                     GUILayout.Space(80);
  826.                     GUILayout.Label("Players: " + key.Value,conectStyle,GUILayout.Width(coRect.width/3));
  827.                    
  828.                     if(numofPlayers < limit)
  829.                     {
  830.                         if (GUILayout.Button("Go",conectStyle,GUILayout.Width(coRect.width/10)) )
  831.                         {
  832.                             _usePhoton.SendMessage("JoinToLobby",key.Key);
  833.                             gameManager.initGame();
  834.                         }
  835.                     }
  836.                     else
  837.                     {
  838.                         GUILayout.Label("Full",conectStyle,GUILayout.Width(coRect.width/10));
  839.                     }
  840.                 GUILayout.EndHorizontal();
  841.             }
  842.         }
  843.         //GameList
  844.        
  845.                
  846.         GUILayout.EndScrollView();
  847.         GUILayout.Space(0);
  848.         GUILayout.BeginHorizontal();
  849.         GUILayout.Label("Create New Room:",hudSkin.GetStyle("Create"),GUILayout.Width(coRect.width/3));
  850.         nameRoom = GUILayout.TextField(nameRoom,textFieldStyle,GUILayout.Width(coRect.width/3));
  851.                 if (GUI.Button(Rect(330,180,50,50),"OK",hudSkin.GetStyle("Create")) && nameRoom.length > 0 || Input.GetKeyUp(KeyCode.KeypadEnter) || Input.GetKeyUp(KeyCode.Return))
  852.                 {
  853.                     if(nameRoom != ""){
  854.                         _usePhoton.SendMessage("JoinToLobby",nameRoom);
  855.                         nameRoom = "";
  856.                         gameManager.initGame();
  857.                     }
  858.                 }
  859.         GUILayout.EndHorizontal();
  860.         GUILayout.Space(5);
  861.         GUILayout.EndArea();
  862.         GUI.skin = cSkin;
  863.     }
  864.    
  865.     function DrawMenu()
  866.     {
  867.         menuBackgroundRect.x = 0;
  868.         menuBackgroundRect.y = (screenSize.y - menuBackgroundRect.height) * 0.5 - 50;
  869.        
  870.         playGameRect.x = menuBackgroundRect.x + 93;
  871.        
  872.         if(hideOptions)
  873.         {
  874.             playGameRect.y = menuBackgroundRect.y + 80;
  875.         }
  876.         else
  877.         {
  878.             playGameRect.y = menuBackgroundRect.y + 62;
  879.         }
  880.        
  881.         resumeRect.x = playGameRect.x;
  882.         resumeRect.y = playGameRect.y;
  883.        
  884.         optionsRect.x = playGameRect.x;
  885.         optionsRect.y = playGameRect.y + playGameRect.height + 15;
  886.        
  887.         graphicsRect.x = playGameRect.x;
  888.        
  889.         if(hideOptions)
  890.         {
  891.             graphicsRect.y = playGameRect.y + playGameRect.height + 15;
  892.         }
  893.         else
  894.         {
  895.             graphicsRect.y = optionsRect.y + optionsRect.height + 15;
  896.         }
  897.        
  898.         aboutRect.x = playGameRect.x;
  899.         aboutRect.y = graphicsRect.y + graphicsRect.height + 15;
  900.        
  901.         conectRect.x = playGameRect.x;
  902.         conectRect.y = aboutRect.y + graphicsRect.height + 15;
  903.        
  904.         GUI.DrawTexture(menuBackgroundRect, menuBackground);
  905.        
  906.         var overButton = false;
  907.        
  908. //      if(Application.loadedLevelName == "main_menu")
  909. //      {
  910. //          if(playGameRect.Contains(mousePos))
  911. //          {
  912. //              overButton = true;
  913. //                     
  914. //              if(!over)
  915. //              {
  916. //                  over = true;
  917. //                  audio.volume = overVolume;
  918. //                  audio.PlayOneShot(overSound);
  919. //              }
  920. //             
  921. //              GUI.DrawTexture(playGameRect, playGameOver);
  922. //             
  923. //              if(alpha <= 0.0 && !goingToGame)
  924. //              {
  925. //                  if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  926. //                  {
  927. //                      audio.volume = clickVolume;
  928. //                      audio.PlayOneShot(clickSound);
  929. //                     
  930. //                      goingToGame = true;
  931. //                     
  932. //                      lastMouseTime = Time.time;
  933. //                  }
  934. //              }
  935. //          }
  936. //          else
  937. //          {
  938. //              GUI.DrawTexture(playGameRect, playGame);
  939. //          }
  940. //      }
  941. //      else
  942. //      {
  943.             if(resumeRect.Contains(mousePos))
  944.             {
  945.                 overButton = true;
  946.                
  947.                 if(!over)
  948.                 {
  949.                     over = true;
  950.                     audio.volume = overVolume;
  951.                     audio.PlayOneShot(overSound);
  952.                 }
  953.                
  954.                 GUI.DrawTexture(resumeRect, resumeOver);
  955.                
  956.                 if(alpha <= 0.0 && GameManager.showMenu)
  957.                 {
  958.                     if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  959.                     {
  960.                         audio.volume = clickVolume;
  961.                         audio.PlayOneShot(clickSound);
  962.                        
  963.                         GameManager.showMenu = false;                      
  964.                         _usePhoton.SendMessage("StatusPause",false);
  965.                        
  966.                         Time.timeScale = 1.0;
  967.                         visible = false;
  968.                         lastMouseTime = Time.time;
  969.                     }
  970.                 }
  971.             }
  972.             else
  973.             {
  974.                 GUI.DrawTexture(resumeRect, resume);
  975.             }
  976.         //}
  977.        
  978.         if(!hideOptions)
  979.         {
  980.             if(optionsRect.Contains(mousePos))
  981.             {
  982.                 overButton = true;
  983.                
  984.                 if(!over)
  985.                 {
  986.                     over = true;
  987.                     audio.volume = overVolume;
  988.                     audio.PlayOneShot(overSound);
  989.                 }
  990.                
  991.                 GUI.DrawTexture(optionsRect, optionsOver);
  992.                
  993.                 if(alpha <= 0.0 && !goingToGame)
  994.                 {
  995.                     if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  996.                     {
  997.                         audio.volume = clickVolume;
  998.                         audio.PlayOneShot(clickSound);
  999.                        
  1000.                         if(state != MainMenuState.OPTIONS)
  1001.                         {
  1002.                             state = MainMenuState.OPTIONS;
  1003.                         }
  1004.                         else
  1005.                         {
  1006.                             state = MainMenuState.IDLE;
  1007.                         }
  1008.                        
  1009.                         lastMouseTime = Time.time;
  1010.                     }
  1011.                 }
  1012.             }
  1013.             else
  1014.             {
  1015.                 GUI.DrawTexture(optionsRect, options);
  1016.             }
  1017.         }
  1018.        
  1019.         if(graphicsRect.Contains(mousePos))
  1020.         {
  1021.             overButton = true;
  1022.            
  1023.             if(!over)
  1024.             {
  1025.                 over = true;
  1026.                 audio.volume = overVolume;
  1027.                 audio.PlayOneShot(overSound);
  1028.             }
  1029.            
  1030.             GUI.DrawTexture(graphicsRect, graphicsOver);
  1031.            
  1032.             if(alpha <= 0.0 && !goingToGame)
  1033.             {
  1034.                 if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  1035.                 {
  1036.                     audio.volume = clickVolume;
  1037.                     audio.PlayOneShot(clickSound);
  1038.                    
  1039.                     if(state != MainMenuState.GRAPHICS)
  1040.                     {
  1041.                         state = MainMenuState.GRAPHICS;
  1042.                     }
  1043.                     else
  1044.                     {
  1045.                         state = MainMenuState.IDLE;
  1046.                     }
  1047.                    
  1048.                     lastMouseTime = Time.time;
  1049.                 }
  1050.             }
  1051.         }
  1052.         else
  1053.         {
  1054.             GUI.DrawTexture(graphicsRect, graphics);
  1055.         }
  1056.        
  1057.         if(aboutRect.Contains(mousePos))
  1058.         {
  1059.             overButton = true;
  1060.            
  1061.             if(!over)
  1062.             {
  1063.                 over = true;
  1064.                 audio.volume = overVolume;
  1065.                 audio.PlayOneShot(overSound);
  1066.             }
  1067.            
  1068.             GUI.DrawTexture(aboutRect, aboutOver);
  1069.            
  1070.             if(alpha <= 0.0 && !goingToGame)
  1071.             {
  1072.                 if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  1073.                 {
  1074.                     audio.volume = clickVolume;
  1075.                     audio.PlayOneShot(clickSound);
  1076.                    
  1077.                     if(state != MainMenuState.ABOUT)
  1078.                     {
  1079.                         state = MainMenuState.ABOUT;
  1080.                     }
  1081.                     else
  1082.                     {
  1083.                         state = MainMenuState.IDLE;
  1084.                     }
  1085.                    
  1086.                     lastMouseTime = Time.time;
  1087.                 }
  1088.             }
  1089.         }
  1090.         else
  1091.         {
  1092.             GUI.DrawTexture(aboutRect, about);
  1093.         }
  1094.        
  1095.         if(conectRect.Contains(mousePos))
  1096.         {
  1097.             overButton = true;
  1098.            
  1099.             if(!over)
  1100.             {
  1101.                 over = true;
  1102.                 audio.volume = overVolume;
  1103.                 audio.PlayOneShot(overSound);
  1104.             }
  1105.            
  1106.             GUI.DrawTexture(conectRect, conectOver);
  1107.            
  1108.             if(alpha <= 0.0 && !goingToGame)
  1109.             {
  1110.                 if(evt.type == EventType.MouseUp && evt.button == 0 && Time.time > lastMouseTime)
  1111.                 {
  1112.                     audio.volume = clickVolume;
  1113.                     audio.PlayOneShot(clickSound);
  1114.                    
  1115.                     if(state != MainMenuState.CONECTION)
  1116.                     {
  1117.                         state = MainMenuState.CONECTION;
  1118.                     }
  1119.                     else
  1120.                     {
  1121.                         state = MainMenuState.IDLE;
  1122.  
  1123.                     }
  1124.                    
  1125.                     lastMouseTime = Time.time;
  1126.                 }
  1127.             }
  1128.         }
  1129.         else
  1130.         {
  1131.             GUI.DrawTexture(conectRect, conect);
  1132.         }
  1133.        
  1134.         if(!overButton)
  1135.         {
  1136.             over = false;
  1137.         }
  1138.     }
  1139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement