void Update() { if (Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp(KeyCode.C)) { craterPlacement ^= true; } paintAudioPlaying = false; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { selection = hit.transform; if (craterPlacement) { if (Input.GetMouseButton(0)) { paintAudioPlaying = true; if (!paSource.isPlaying) { paSource.Play(0); } planet.shapeGenerator.craterGenerator.PlaceCrater(selection.InverseTransformPoint(hit.point)); planet.UpdateMesh(); } } else { if (Input.GetMouseButton(0)) { paintAudioPlaying = true; if (!paSource.isPlaying) { paSource.Play(0); } interactionPoint = selection.InverseTransformPoint(hit.point); hitCoords.Add(interactionPoint); planet.UpdateMesh(); //hitCoords.Add(selection.InverseTransformPoint(hit.point)); } } } if (!paintAudioPlaying) { if (paSource) { paSource.Pause(); } } }
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(); }
// 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; } } }