79 lines
1.9 KiB
C#
79 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SolarSystemManager : MonoBehaviour
|
|
{
|
|
public GameObject[] objectsToDeactivate;
|
|
public GameObject[] objectsToActivate;
|
|
|
|
public float Industry;
|
|
public float Wealth;
|
|
public float Science;
|
|
public float Food;
|
|
public float MilitaryPower;
|
|
public float Population;
|
|
public float ActualFood;
|
|
|
|
public Text[] texts; // Array der Text-Objekte
|
|
private float[] Array = new float[7];
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < objectsToDeactivate.Length; i++)
|
|
{
|
|
objectsToDeactivate[i].SetActive(false); // deactivate the game object
|
|
}
|
|
for (int i = 0; i < objectsToActivate.Length; i++)
|
|
{
|
|
objectsToActivate[i].SetActive(true); // activate the game object
|
|
}
|
|
Array[0]= Industry;
|
|
Array[1]= Wealth;
|
|
Array[2]= Science;
|
|
Array[3]= Food;
|
|
Array[4]= MilitaryPower;
|
|
Array[5]= Population;
|
|
Array[6]= ActualFood;
|
|
}
|
|
|
|
public void SetPositionCenter()
|
|
{
|
|
transform.position = new Vector3(604.75f, 252.75f, 0f);
|
|
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
Array[0] += Industry;
|
|
Array[1] = Wealth;
|
|
Array[2] = Science;
|
|
Array[3] = Food;
|
|
Array[4] = MilitaryPower;
|
|
Array[5] = Population;
|
|
Array[6] = ActualFood;
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
float temp = Array[i];
|
|
|
|
if (temp / 1000000 >= 1)
|
|
{
|
|
temp /= 1000000;
|
|
texts[i].text = ((int)temp).ToString() + " M";
|
|
}
|
|
else if (temp / 1000 >= 1)
|
|
{
|
|
temp /= 1000;
|
|
texts[i].text = ((int)temp).ToString() + " K";
|
|
}
|
|
else
|
|
{
|
|
texts[i].text = Array[i].ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|