Advertisement
shadowplaycoding

P028_GUIManagementScript

May 27th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. public class GUIManagementScript : MonoBehaviour {
  7.  
  8.     public static GUIManagementScript GUIManagerInstance;
  9.  
  10.     public List<GameObject> namePlates;
  11.  
  12.     public GameObject planetPanel;
  13.     public GameObject starBasePanel;
  14.  
  15.     GameObject content;
  16.  
  17.     void OnEnable()
  18.     {
  19.         GUIManagerInstance = this;
  20.         namePlates = new List<GameObject>();
  21.     }
  22.  
  23.     void Awake()
  24.     {
  25.         content = starBasePanel.GetComponentInChildren<VerticalLayoutGroup>().gameObject;
  26.     }
  27.  
  28.     // Use this for initialization
  29.     void Start () {
  30.        
  31.     }
  32.    
  33.     // Update is called once per frame
  34.     void Update () {
  35.  
  36.         if(namePlates.Count > 0)
  37.         {
  38.             if (CameraController.cameraController.zoomLevel < 0.4)
  39.             {
  40.                 for (int i = 0; i < namePlates.Count; i++)
  41.                 {
  42.                     namePlates[i].transform.LookAt(Camera.main.transform);
  43.                     float rotY = namePlates[i].transform.localEulerAngles.y + 180f;
  44.                     namePlates[i].transform.localEulerAngles = new Vector3(
  45.                         -namePlates[i].transform.localEulerAngles.x,
  46.                         rotY,
  47.                         -namePlates[i].transform.localEulerAngles.z);
  48.                 }
  49.             }
  50.         }
  51.  
  52.     }
  53.  
  54.     public void UpdateShipProductionUI()
  55.     {
  56.  
  57.         Planet planet = SolarSystem.SolarSystemInstance.currentPlanet;
  58.  
  59.         if (planet.production > 0)
  60.         {
  61.             for (int i = 0; i < content.transform.childCount; i++)
  62.             {
  63.                 Text[] texts = content.transform.GetChild(i).GetComponentsInChildren<Text>();
  64.  
  65.                 Ship ship = planet.starBase.buildCue[i];
  66.  
  67.                 int numberOfTurns = Mathf.CeilToInt((ship.productionValue - planet.starBase.currentProduction) / planet.production);
  68.  
  69.                 texts[texts.Length - 1].text = numberOfTurns.ToString();
  70.             }
  71.  
  72.         }
  73.     }
  74.  
  75.     /*
  76.     Copyright Shadowplay Coding 2018 - see www.shadowplaycoding.com for licensing details
  77.     Removing this comment forfits any rights given to the user under licensing.
  78.     */
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement