Galaxy Anpassen

This commit is contained in:
mkadou
2023-07-02 14:25:11 +02:00
parent 05142dbb22
commit b38ff3197a
107 changed files with 833 additions and 187 deletions

View File

@@ -7,17 +7,19 @@ public class SolarSystemManager : MonoBehaviour
{
public GameObject[] objectsToDeactivate;
public GameObject[] objectsToActivate;
public GameObject[] Planets;
public float Industry;
public float Wealth;
public float Science;
public float Food;
public float MilitaryPower;
public float Population;
public float ActualFood;
public int Industry;
public int Wealth;
public int Science;
public int Food;
public int MilitaryPower;
public int Population;
public int ActualFood;
public GameObject canvas; // Referenz auf das Canvas-Objekt
public Text[] texts; // Array der Text-Objekte
private float[] Array = new float[7];
private int[] Array = new int[7];
// Start is called before the first frame update
void Start()
@@ -30,24 +32,23 @@ public class SolarSystemManager : MonoBehaviour
{
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;
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);
transform.position = canvas.transform.position; // Position des Hauptobjekts
}
void Update()
{
Array[0] += Industry;
Array[0] = Industry;
Array[1] = Wealth;
Array[2] = Science;
Array[3] = Food;
@@ -56,17 +57,17 @@ public class SolarSystemManager : MonoBehaviour
Array[6] = ActualFood;
for (int i = 0; i < 7; i++)
{
float temp = Array[i];
int temp = Array[i];
if (temp / 1000000 >= 1)
{
temp /= 1000000;
texts[i].text = ((int)temp).ToString() + " M";
texts[i].text = temp.ToString() + " M";
}
else if (temp / 1000 >= 1)
{
temp /= 1000;
texts[i].text = ((int)temp).ToString() + " K";
texts[i].text = temp.ToString() + " K";
}
else
{
@@ -74,5 +75,147 @@ public class SolarSystemManager : MonoBehaviour
}
}
}
// Get Methodes, so it will search in all the planets in the solar system to get recours
public int GetFood(int id)
{
int food = 0;
if (Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
food += Planets[i].GetComponent<PlanetUI>().food;
}
}
}
return food;
}
public int GetScience(int id)
{
int science = 0;
if (Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
science += Planets[i].GetComponent<PlanetUI>().science;
}
}
}
return science;
}
public int GetPower(int id)
{
int power = 0;
if (Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
power += Planets[i].GetComponent<PlanetUI>().power;
}
}
}
return power;
}
public int GetMoney(int id)
{
int money = 0;
if (Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
money += Planets[i].GetComponent<PlanetUI>().money;
}
}
}
return money;
}
public int GetIndustrialCapacity(int id)
{
int industrialCapacity = 0;
if (Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
industrialCapacity += Planets[i].GetComponent<PlanetUI>().industrialCapacity;
}
}
}
return industrialCapacity;
}
public int GetPopulation(int id)
{
int population = 0;
if (Planets != null)
{
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
population += Planets[i].GetComponent<PlanetUI>().population;
}
}
}
return population;
}
public int GetActualFood(int id)
{
int actualFood = 0;
if(Planets != null) {
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
actualFood += Planets[i].GetComponent<PlanetUI>().actualFood;
}
}
}
return actualFood;
}
public void UpdateFood(int id , int FoodLvlScience)
{
if (Planets != null)
{
for (int i = 0; i < Planets.Length; i++)
{
if (Planets[i].GetComponent<PlanetUI>().PlayerID == id)
{
Planets[i].GetComponent<PlanetUI>().UpdateFood(FoodLvlScience);
}
}
}
}
public void SetIDPlanet(int PlayerID, int PlanetID)
{
Planets[PlanetID].GetComponent<PlanetUI>().PlayerID = PlayerID;
}
}