public void UpdatePlanetProperties()
 {
     currentPlanet           = GameManager.Instance.planets[GameManager.Instance.activePlanet];
     currentPlanetProperties = currentPlanet.GetComponent <PlanetProperties>();
     planetName.text         = currentPlanetProperties.planetName;
     planetRotPeriod.text    = currentPlanetProperties.planetRotationalPeriod;
     planetOrbPeriod.text    = currentPlanetProperties.planetOrbitalPeriod;
     planetDistance.text     = currentPlanetProperties.planetDistance;
     planetDiameter.text     = currentPlanetProperties.planetDiameter;
 }
Beispiel #2
0
    private void SelectPlanet(PlanetProperties planet, int planetId)
    {
        // set UI button color for inactive / active button
        foreach (var planetButton2 in planetButtons)
        {
            planetButton2.GetComponent <Image>().color          = planetButtonPrefab.GetComponent <Image>().color;
            planetButton2.GetComponentInChildren <Text>().color = Color.white;
        }
        planetButtons[planetId].GetComponent <Image>().color          = Color.cyan;
        planetButtons[planetId].GetComponentInChildren <Text>().color = Color.black;

        // transfer currently loaded data into json objects
        if (activePlanet != null)
        {
            List <HeightAdjustment> heightAdjustmentList = new List <HeightAdjustment>();
            foreach (var heightAdjustment in heightAdjustments)
            {
                heightAdjustmentList.Add(heightAdjustment.GetHeightAdjustment());
            }
            activePlanet.planet.heightAdjustments = heightAdjustmentList.ToArray();
        }

        //delete current objects
        foreach (var heightAdjustment in heightAdjustments)
        {
            Destroy(heightAdjustment.gameObject);
        }
        heightAdjustments.Clear();

        // set new planet
        activePlanet           = planet;
        currentPlanetText.text = activePlanet.name;
        planetSizeInput.text   = activePlanet.planet.radius.ToString();

        var heightAdjustmentArray = loadedSolarSystem.planets[planetId].planet.heightAdjustments;

        Debug.Log("Setting new height Adjustments:\n" + JsonUtility.ToJson(heightAdjustmentArray, true));
        foreach (var heightAdjustment in heightAdjustmentArray)
        {
            var heightAdjustmentObject = Instantiate(adjustmentObjectPrefab).GetComponent <HeightAdjustmentObject>();
            heightAdjustmentObject.LoadHeightAdjustment(heightAdjustment);
            heightAdjustments.Add(heightAdjustmentObject);
        }

        diameter      = activePlanet.planet.radius * 2;
        defaultRadius = (int)Math.Floor(diameter * 0.1f);
        setWorldSize();
    }