Example #1
0
 public void ChangeTintCol(Vector3 weights)
 {
     planet.colorGenerator.settings.biomeColorSettings.biomes[0].tint.r = weights[0];
     planet.colorGenerator.settings.biomeColorSettings.biomes[0].tint.g = weights[1];
     planet.colorGenerator.settings.biomeColorSettings.biomes[0].tint.b = weights[2];
     //planet.colorGenerator.settings.biomeColorSettings.biomes[0].tint.r = value;
     planet.GenerateColors();
 }
Example #2
0
 public void toggleOcean()
 {
     planet.shapeSettings.zeroLvlIsOcean ^= true;
     oceanToggle = GameObject.Find("ToggleWater").GetComponent <Toggle>();
     if (planet.shapeSettings.zeroLvlIsOcean)
     {
         oceanToggle.isOn = true;
     }
     else
     {
         oceanToggle.isOn = false;
     }
     planet.shapeGenerator.elevationMinMax = new MinMax();
     planet.UpdateMesh();
     planet.GenerateColors();
 }
Example #3
0
    public void UpdateTintColor(Vector3 weights, float power)
    {
        float intensity = (weights.x + weights.y + weights.z) / 3f;
        float factor    = Mathf.Pow(intensity, power);

        if (planet)
        {
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.r = weights[0];
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.g = weights[1];
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.b = weights[2];
            //this way was weirdly different than just multiplying the weights first, and it is more stable across color assignments.
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.r *= factor;
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.g *= factor;
            planet.colorGenerator.settings.biomeColorSettings.biomes[biomeIndex].tint.b *= factor;
            planet.GenerateColors();
            bandPos[biomeIndex]       = handle.transform.localPosition;
            bandWeights[biomeIndex]   = weights;
            bandIntensity[biomeIndex] = power;
        }
        else
        {
            //makes sure that each band keeps the color that was selected before switching to other band, and that the handle reflects that color
            if (currBand == 0)
            {
                gasPlanet.ChangeBandColor1(weights, factor);
            }
            else if (currBand == 1)
            {
                gasPlanet.ChangeBandColor2(weights, factor);
            }
            else if (currBand == 2)
            {
                gasPlanet.ChangeBandColor3(weights, factor);
            }
            else
            {
                gasPlanet.ChangeStormColor(weights, factor);
            }
            bandPos[currBand]       = handle.transform.localPosition;
            bandWeights[currBand]   = weights;
            bandIntensity[currBand] = power;
        }
    }
Example #4
0
 // Update is called once per frame
 public void toggleOcean()
 {
     planet.shapeSettings.zeroLvlIsOcean ^= true;
     oceanBtn    = GameObject.Find("ToggleWater").GetComponent <Button>();
     oceanBtnTxt = oceanBtn.GetComponentInChildren <Text>();
     if (planet.shapeSettings.zeroLvlIsOcean)
     {
         oceanBtn.GetComponent <Image>().color = toggledColor;
         oceanBtnTxt.color = toggledTxtColor;
     }
     else
     {
         oceanBtn.GetComponent <Image>().color = untoggledColor;
         oceanBtnTxt.color = untoggledTxtColor;
     }
     planet.shapeGenerator.elevationMinMax = new MinMax();
     Debug.Log("Min: " + planet.shapeGenerator.elevationMinMax.Min);
     Debug.Log("Max: " + planet.shapeGenerator.elevationMinMax.Max);
     planet.UpdateMesh();
     planet.GenerateColors();
 }
    void Update()
    {
        if (save)
        {
            if (sceneIndex == 2)
            {
                //Save one planet to newPlanet.data
                SaveLoadStarSystem.SaveStarSystem(true, "/newPlanet.data");
                save = false;
            }
            else if (sceneIndex == 1)
            {
                //Save the entire system to system.data
                if (saveSpecific)
                {
                    SaveLoadStarSystem.SaveSpecificStarSystem(false, systemName + ".data");
                    saveSpecific = false;
                }
                else
                {
                    SaveLoadStarSystem.SaveStarSystem(false, "/system.data");
                    if (!firstGenSystemSaved)
                    {
                        firstGenSystemSaved = true;
                    }
                }
                save = false;
            }
        }
        if (load)
        {
            if (sceneIndex == 1)
            {
                //Load the entire system from system.data
                SystemSimulationData data;
                if (loadSpecific)
                {
                    data         = SaveLoadStarSystem.LoadSavedStarSystem(systemName);
                    loadSpecific = false;
                }
                else
                {
                    if (firstGenSystemSaved)
                    {
                        data = SaveLoadStarSystem.LoadStarSystem(false);
                    }
                    else
                    {
                        data = null;
                    }
                    load = false;
                }
                if (data != null)
                {
                    //CelestialObject.DestroyAll();

                    var planets = FindObjectsOfType <CelestialObject>();
                    foreach (CelestialObject co in planets)
                    {
                        if (!co.staticBody)
                        {
                            Destroy(co.gameObject);
                        }
                    }

                    int        rocky_i = 0;
                    int        gasy_i  = 0;
                    GameObject parent  = GameObject.Find("SceneObjects");
                    for (int i = 0; i < data.planetCount; i++)
                    {
                        GameObject obj = getPrefab(data, i);


                        MotherPlanet mp = obj.GetComponentInChildren <MotherPlanet>();
                        if (mp != null)
                        {
                            mp.GeneratePlanet();
                            mp.SetShape(data.planetList[rocky_i]);
                            mp.UpdateMesh();
                            rocky_i += 1;
                        }
                        //GasPlanetShaderMAterialPropertyBlock gp = co.GetComponentInChildren<GasPlanetShaderMAterialPropertyBlock>();
                        GasPlanetShaderMAterialPropertyBlock gp = obj.GetComponent <GasPlanetShaderMAterialPropertyBlock>();
                        if (gp != null)
                        {
                            gp.SetMaterial(data.gasPlanetList[gasy_i]);
                            gasy_i += 1;
                        }
                        //obj.GetComponent<SphereCollider>().enabled=false;

                        obj.GetComponent <CelestialObject>().enabled = true;

                        CelestialObject co = obj.GetComponent <CelestialObject>();
                        //print("position");
                        //print(data.physicsData[i].position);
                        //print("----------");
                        co.SetState(data.physicsData[i]);
                        obj.transform.SetParent(parent.transform);
                    }
                    load = false;
                }
                else
                {
                    load = false;
                    Debug.Log("failed to load entire system");
                }
            }
        }
        if (loadNewPlanet)
        {
            if (sceneIndex == 1)
            {
                loadNewPlanet = false;
                //Load one planet from newPlanet data and p
                SystemSimulationData data = SaveLoadStarSystem.LoadStarSystem(true);
                if (data != null)
                {
                    //CelestialObject.DestroyAll();
                    int rocky_i = 0;
                    int gasy_i  = 0;
                    for (int i = 0; i < data.planetCount; i++)
                    {
                        GameObject      obj = getPrefab(data, i);
                        CelestialObject co  = GetComponent <CelestialObject>();
                        if (co != null)
                        {
                            obj.AddComponent(typeof(CelestialObject));
                        }
                        obj.GetComponent <CelestialObject>().isShot = false;
                        //obj.GetComponent<IcoPlanet>().enabled = true;

                        MotherPlanet mp = obj.GetComponentInChildren <MotherPlanet>();
                        if (mp != null)
                        {
                            mp.GeneratePlanet();
                            mp.SetShape(data.planetList[rocky_i]);
                            mp.UpdateMesh();
                            mp.GenerateColors();
                            mp.GetComponent <IcoPlanet>().staticBody = false;
                            mp.GetComponent <IcoPlanet>().enabled    = true;

                            rocky_i += 1;
                        }
                        GasPlanetShaderMAterialPropertyBlock gp = obj.GetComponentInChildren <GasPlanetShaderMAterialPropertyBlock>();
                        if (gp != null)
                        {
                            gp.SetMaterial(data.gasPlanetList[gasy_i]);
                            gp.GetComponent <GasPlanetShaderMAterialPropertyBlock>().enabled = true;
                            gasy_i += 1;
                        }
                        string newPlanetName = PlayerPrefs.GetString("NewPlanetName", "Unknown Planet");
                        obj.GetComponent <CelestialObject>().SetName(newPlanetName);
                        PlayerPrefs.SetString("NewPlanetName", "Unknown Planet");
                        if (!obj.GetComponent <CelestialObject>().isAsteroid)
                        {
                            obj.GetComponent <CelestialObject>().SetMass();
                        }
                        GameObject            ARSessOrig = GameObject.Find("AR Session Origin");
                        ARPlacementTrajectory placement  = ARSessOrig.GetComponent <ARPlacementTrajectory>();
                        placement.setGOtoInstantiate(obj);
                    }
                }
            }
        }
        if (delete)
        {
            if (sceneIndex == 1)
            {
                SaveLoadStarSystem.DeleteStarSystem(delSystemName);
                delete = false;
            }
        }
    }