Exemple #1
0
 void OnGUI()
 {
     if (open)
     {
         // close if clicking elsewhere
         if (Input.GetMouseButtonDown(0))
         {
             Vector2 mouse = Input.mousePosition;
             if (!backgroundRect.Contains(new Vector2(mouse[0], Screen.height - mouse[1])))
             {
                 Close();
             }
         }
         // respond to button clicks
         GUI.Box(backgroundRect, "");
         HouseManager.HouseType firstType  = buildOptions[0];
         HouseManager.HouseType secondType = buildOptions[1];
         if (firstType == HouseManager.HouseType.LOCKED)
         {
             GUI.Box(firstBuildRect, "LOCKED", textStyle);
         }
         else
         {
             if (HouseManager.CanBuild(firstType))
             {
                 if (GUI.Button(closeRect, "x"))
                 {
                     Close();
                 }
                 else if (GUI.Button(firstBuildRect, firstType.ToString() + "\n$" + HouseManager.GetCost(firstType)))
                 {
                     Close();
                     Build(firstType);
                 }
             }
             else
             {
                 GUI.Box(firstBuildRect, "NEED $$$", textStyle);
             }
         }
         if (secondType == HouseManager.HouseType.LOCKED)
         {
             GUI.Box(secondBuildRect, "LOCKED", textStyle);
         }
         else
         {
             if (HouseManager.CanBuild(secondType))
             {
                 if (GUI.Button(secondBuildRect, secondType.ToString() + "\n$" + HouseManager.GetCost(secondType)))
                 {
                     Close();
                     Build(secondType);
                 }
             }
             else
             {
                 GUI.Box(secondBuildRect, "NEED $$$", textStyle);
             }
         }
     }
 }