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

@@ -6,37 +6,39 @@ using UnityEngine.UI;
public class GalaxyUI : MonoBehaviour
{
public GameObject galaxyPrefab; // Prefab des Galaxy-Objekts
int numberOfGalaxies = GameUI.PlayersNumber; // Anzahl der zu erstellenden Galaxien
int numberOfSolarSystem; // Anzahl der zu erstellenden Solarsystem
public float distanceFromCenter; // Abstand der Galaxien vom Hauptobjekt
public GameObject canvas; // Referenz auf das Canvas-Objekt
private GameObject[] SolarSystems = new GameObject[12];
private Vector3[] SolarSystemPositions = new Vector3[12];
//private GameObject[] SolarSystems = new GameObject[12];
private Vector3[] SolarSystemPositions;
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 Text[] texts; // Array der Text-Objekte
private float[] Array = new float[7];
private int[] Array = new int[7];
void Start()
{
numberOfSolarSystem = GameUI.PlayersNumber; // Anzahl der zu erstellenden Solarsystem
SolarSystemPositions = new Vector3[numberOfSolarSystem];
Vector3 centerPosition = canvas.transform.position; // Position des Hauptobjekts
for (int i = 0; i < numberOfGalaxies; i++)
for (int i = 0; i < numberOfSolarSystem; i++)
{
// Erzeuge ein neues GameObject aus dem Prefab
SolarSystems[i] = Instantiate(galaxyPrefab);
// Setze das Canvas als Elternobjekt
SolarSystems[i].transform.SetParent(canvas.transform, false);
GameManager.SolarSystems[i].transform.SetParent(canvas.transform, false);
// Berechne den Winkel basierend auf der Anzahl der Galaxien
float angle = i * (360f / numberOfGalaxies);
float angle = i * (360f / numberOfSolarSystem);
// Berechne die Position basierend auf dem Winkel und dem Abstand vom Zentrum
float xPos = centerPosition.x + (distanceFromCenter * 3) * Mathf.Cos(Mathf.Deg2Rad * angle);
@@ -44,23 +46,23 @@ public class GalaxyUI : MonoBehaviour
// Setze die Position des Galaxy-Objekts
SolarSystemPositions[i] = new Vector3(xPos, yPos, centerPosition.z);
SolarSystems[i].transform.position = new Vector3(xPos, yPos, centerPosition.z);
GameManager.SolarSystems[i].transform.position = new Vector3(xPos, yPos, centerPosition.z);
}
}
public void HidetSolarSystems()
public void HideSolarSystems()
{
for (int i = 0; i < numberOfGalaxies; i++)
for (int i = 0; i < numberOfSolarSystem; i++)
{
SolarSystems[i].transform.position = new Vector3(10000, 0, 0);
GameManager.SolarSystems[i].transform.position = new Vector3(10000, 0, 0);
}
}
public void ResetSolarSystemPositions()
{
for (int i = 0; i < numberOfGalaxies; i++)
for (int i = 0; i < numberOfSolarSystem; i++)
{
SolarSystems[i].transform.position = new Vector3(SolarSystemPositions[i].x, SolarSystemPositions[i].y, SolarSystemPositions[i].z);
GameManager.SolarSystems[i].transform.position = new Vector3(SolarSystemPositions[i].x, SolarSystemPositions[i].y, SolarSystemPositions[i].z);
}
}
@@ -69,6 +71,18 @@ public class GalaxyUI : MonoBehaviour
// Update is called once per frame
void Update()
{
Industry = GameManager.playerManagers[0]._playerAttributes.industrialCapacity;
Wealth = GameManager.playerManagers[0]._playerAttributes.money;
Science = GameManager.playerManagers[0]._playerAttributes.science;
Food = GameManager.playerManagers[0]._playerAttributes.food;
MilitaryPower = GameManager.playerManagers[0]._playerAttributes.power;
Population = GameManager.playerManagers[0]._playerAttributes.population;
ActualFood = GameManager.playerManagers[0]._playerAttributes.actualFood;
Array[0] = Industry;
Array[1] = Wealth;
Array[2] = Science;
@@ -76,30 +90,19 @@ public class GalaxyUI : MonoBehaviour
Array[4] = MilitaryPower;
Array[5] = Population;
Array[6] = ActualFood;
for (int i = 0; i < numberOfGalaxies; i++)
{
Industry += SolarSystems[i].GetComponent<SolarSystemManager>().Industry;
Wealth += SolarSystems[i].GetComponent<SolarSystemManager>().Wealth;
Science += SolarSystems[i].GetComponent<SolarSystemManager>().Science;
Food += SolarSystems[i].GetComponent<SolarSystemManager>().Food;
MilitaryPower += SolarSystems[i].GetComponent<SolarSystemManager>().MilitaryPower;
Population += SolarSystems[i].GetComponent<SolarSystemManager>().Population;
ActualFood += SolarSystems[i].GetComponent<SolarSystemManager>().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
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,35 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlanetMove : MonoBehaviour
{
public int PlayerID;
public float rotationSpeed = 1f; // Geschwindigkeit der Rotation
public float radius = 5f; // Radius des Kreises
private float angle = 0f; // Aktueller Winkel im Kreis
private Vector2 centerPosition; // Position des Zentrums des Kreises
// Start is called before the first frame update
void Start()
{
centerPosition = transform.parent.position; // Position des Zentrums
transform.position = GetPositionOnCircle(angle); // Setze die Startposition
}
// Update is called once per frame
void Update()
{
angle += rotationSpeed * Time.deltaTime; // Aktualisiere den Winkel basierend auf der Geschwindigkeit
transform.position = GetPositionOnCircle(angle); // Berechne die neue Position des Planeten
}
Vector3 GetPositionOnCircle(float angle)
{
float xPos = centerPosition.x + Mathf.Sin(angle) * radius; // X-Position auf dem Kreis
float yPos = centerPosition.y + Mathf.Cos(angle) * radius; // Y-Position auf dem Kreis
return new Vector3(xPos, yPos, 0f); // Position als Vektor zur<75>ckgeben
}
}

Some files were not shown because too many files have changed in this diff Show More