Files
2026-05-29 18:21:53 +03:00

826 lines
37 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class GameManager : MonoBehaviour
{
public static GameManager Instance;
[Header("Ïàíåë³")]
public GameObject planetSelectPanel;
public GameObject infoPanel;
public GameObject layerOrderPanel;
public GameObject simulationPanel;
public GameObject questionPanel;
public GameObject answerSelectionPanel;
[Header("Êàìåðà")]
public CameraController cameraController;
[Header("Ñòàðòîâà ïîçèö³ÿ êàìåðè")]
public Transform startCameraPoint;
[Header("Info Panel åëåìåíòè")]
public TextMeshProUGUI infoPlanetName;
public TextMeshProUGUI infoMainText;
public Button startButton;
[Header("Ïëàíåòè")]
public PlanetData[] planets;
[System.Serializable]
public class PlanetData
{
public string planetKey;
public Transform planetTransform;
public GameObject atmosphereSystem;
public Transform[] layerTransforms;
public bool useCustomOffset;
public Vector3 customOffset;
public float layerCameraMultiplier = 1f;
}
private PlanetData currentPlanet;
private PlanetDatabase.PlanetInfo currentPlanetInfo;
public int currentLayerIndex = 0;
private bool positionSaved = false;
void Awake()
{
Instance = this;
}
void Start()
{
foreach (var p in planets)
if (p.atmosphereSystem != null)
p.atmosphereSystem.SetActive(false);
planetSelectPanel.SetActive(true);
infoPanel.SetActive(false);
layerOrderPanel.SetActive(false);
simulationPanel.SetActive(false);
if (questionPanel != null) questionPanel.SetActive(false);
if (answerSelectionPanel != null) answerSelectionPanel.SetActive(false);
}
public void SelectPlanet(int index)
{
if (index < 0 || index >= planets.Length) return;
if (!PlanetDatabase.Data.ContainsKey(planets[index].planetKey)) return;
currentPlanet = planets[index];
currentPlanetInfo = PlanetDatabase.Data[currentPlanet.planetKey];
currentLayerIndex = 0;
foreach (var p in planets)
if (p.atmosphereSystem != null)
p.atmosphereSystem.SetActive(false);
layerOrderPanel.SetActive(false);
infoPanel.SetActive(false);
simulationPanel.SetActive(false);
if (!positionSaved)
{
cameraController.SavePosition();
positionSaved = true;
}
Vector3? customRot = currentPlanet.planetKey == "Saturn" ? new Vector3(25f, -70f, 0f) : (Vector3?)null;
if (currentPlanet.useCustomOffset)
cameraController.FlyTo(currentPlanet.planetTransform, OnArrivedAtPlanet, currentPlanet.customOffset, customRot);
else
cameraController.FlyTo(currentPlanet.planetTransform, OnArrivedAtPlanet, null, customRot);
}
void OnArrivedAtPlanet()
{
if (currentPlanet.atmosphereSystem != null)
currentPlanet.atmosphereSystem.SetActive(true);
if (currentPlanet.planetKey == "Venus")
{
var venusAtmo = currentPlanet.atmosphereSystem
.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo != null)
{
venusAtmo.SetLayerActive("Layer_Troposphere", true);
venusAtmo.SetLayerActive("Layer_Mesosphere", true);
venusAtmo.SetLayerActive("Layer_Thermosphere", true);
venusAtmo.SetLayerActive("Layer_Exosphere", true);
venusAtmo.SetLayerIntensity("Layer_Troposphere", 2.5f);
venusAtmo.SetLayerIntensity("Layer_Mesosphere", 2.0f);
venusAtmo.SetLayerIntensity("Layer_Thermosphere", 1.5f);
venusAtmo.SetLayerIntensity("Layer_Exosphere", 1.2f);
}
var venusDeath = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath != null) venusDeath.ResetTexture();
}
infoPanel.SetActive(true);
if (infoPlanetName != null)
infoPlanetName.text = currentPlanetInfo.name;
if (infoMainText != null)
infoMainText.text = currentPlanetInfo.mainInfo;
if (startButton != null)
{
var btnText = startButton.GetComponentInChildren<TextMeshProUGUI>();
if (btnText != null)
btnText.text = currentPlanetInfo.hasAtmosphere ? "Ðîçïî÷àòè" : "Ïîâåðíóòèñü";
}
}
public void StartSimulation()
{
if (!currentPlanetInfo.hasAtmosphere)
{
infoPanel.SetActive(false);
cameraController.FlyToSavedPosition(() =>
{
planetSelectPanel.SetActive(true);
});
return;
}
infoPanel.SetActive(false);
planetSelectPanel.SetActive(false);
simulationPanel.SetActive(false);
currentLayerIndex = 0;
if (SimulationController.Instance != null)
{
if (SimulationController.Instance.prevButton != null)
SimulationController.Instance.prevButton.interactable = false;
if (SimulationController.Instance.nextButton != null)
SimulationController.Instance.nextButton.interactable = false;
}
cameraController.FlyToLayer(
currentPlanet.layerTransforms[currentLayerIndex],
() => {
simulationPanel.SetActive(true);
SimulationController.Instance.StartLayer(currentLayerIndex, currentPlanetInfo);
},
currentPlanet.layerCameraMultiplier
);
}
public void NextLayer()
{
ResetCurrentLayer();
currentLayerIndex++;
if (currentPlanetInfo.layers == null || currentLayerIndex >= currentPlanetInfo.layers.Length)
{
FinishSimulation();
return;
}
cameraController.FlyToLayer(
currentPlanet.layerTransforms[currentLayerIndex],
() => SimulationController.Instance.StartLayer(currentLayerIndex, currentPlanetInfo),
currentPlanet.layerCameraMultiplier
);
}
public void PrevLayer()
{
ResetCurrentLayer();
currentLayerIndex = Mathf.Max(0, currentLayerIndex - 1);
RestoreVenusLayersForIndex(currentLayerIndex);
cameraController.FlyToLayer(
currentPlanet.layerTransforms[currentLayerIndex],
() => SimulationController.Instance.StartLayer(currentLayerIndex, currentPlanetInfo),
currentPlanet.layerCameraMultiplier
);
}
void RestoreVenusLayersForIndex(int layerIndex)
{
if (currentPlanet.planetKey != "Venus") return;
var atmo = currentPlanet.atmosphereSystem;
if (atmo == null) return;
var venusAtmo = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo == null) return;
if (layerIndex <= 0)
{
venusAtmo.SetLayerActive("Layer_Troposphere", true);
venusAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
}
if (layerIndex <= 1)
{
venusAtmo.SetLayerActive("Layer_Mesosphere", true);
venusAtmo.SetLayerIntensity("Layer_Mesosphere", 0.15f);
}
if (layerIndex <= 2)
{
venusAtmo.SetLayerActive("Layer_Thermosphere", true);
venusAtmo.SetLayerIntensity("Layer_Thermosphere", 0.15f);
}
}
void ResetCurrentLayer()
{
PlanetDeath pd = GameObject.FindObjectOfType<PlanetDeath>();
if (pd == null) return;
var atmo = currentPlanet.atmosphereSystem;
if (atmo == null) return;
switch (currentLayerIndex)
{
case 0:
pd.troposphereLevel = 1f;
var tropo = atmo.GetComponentInChildren<TroposphereEffects>(true);
if (tropo != null) tropo.enabled = false;
var mercury = atmo.GetComponentInChildren<MercuryEffects>(true);
if (mercury != null)
{
mercury.exosphereLevel = 1f;
mercury.InitState();
mercury.enabled = false;
}
if (currentPlanet.planetKey == "Venus")
{
var venusAtmo = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo != null) venusAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
var venusDeath = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath != null) venusDeath.ResetTexture();
}
if (currentPlanet.planetKey == "Mars")
{
var marsEff = atmo.GetComponentInChildren<MarsEffects>(true);
if (marsEff != null) marsEff.CleanUp();
var marsAtmo = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo != null)
{
marsAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
marsAtmo.SetLayerActive("Layer_Mesosphere", true);
marsAtmo.SetLayerActive("Layer_Thermosphere", true);
marsAtmo.SetLayerActive("Layer_Exosphere", true);
}
var marsDeath = currentPlanet.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath != null) marsDeath.ResetTexture();
}
if (currentPlanet.planetKey == "Jupiter")
{
var jupiterTropo = atmo.GetComponentInChildren<JupiterTroposphereEffects>(true);
if (jupiterTropo != null) jupiterTropo.CleanUp();
var jupiterAtmo = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo != null)
{
jupiterAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
jupiterAtmo.SetLayerActive("Layer_Stratosphere", true);
jupiterAtmo.SetLayerActive("Layer_Thermosphere", true);
jupiterAtmo.SetLayerActive("Layer_Exosphere", true);
}
var jupiterDeath0 = currentPlanet.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath0 != null) jupiterDeath0.ResetTexture();
}
if (currentPlanet.planetKey == "Saturn")
{
var saturnTropo = atmo.GetComponentInChildren<SaturnTroposphereEffects>(true);
if (saturnTropo != null) saturnTropo.CleanUp();
var saturnAtmo = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo != null)
{
saturnAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
saturnAtmo.SetLayerActive("Layer_Stratosphere", true);
saturnAtmo.SetLayerActive("Layer_Thermosphere", true);
saturnAtmo.SetLayerActive("Layer_Exosphere", true);
}
var saturnDeath0 = currentPlanet.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath0 != null) saturnDeath0.ResetTexture();
}
if (currentPlanet.planetKey == "Uranus")
{
var uranusTropo = atmo.GetComponentInChildren<UranusTroposphereEffects>(true);
if (uranusTropo != null) uranusTropo.CleanUp();
var uranusAtmo = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo != null)
{
uranusAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
uranusAtmo.SetLayerActive("Layer_Stratosphere", true);
uranusAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var uranusDeath0 = currentPlanet.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath0 != null) uranusDeath0.ResetTexture();
}
if (currentPlanet.planetKey == "Neptune")
{
var neptuneTropo = atmo.GetComponentInChildren<NeptuneTroposphereEffects>(true);
if (neptuneTropo != null) neptuneTropo.CleanUp();
var neptuneAtmo = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo != null)
{
neptuneAtmo.SetLayerIntensity("Layer_Troposphere", 0.15f);
neptuneAtmo.SetLayerActive("Layer_Stratosphere", true);
neptuneAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var neptuneDeath0 = currentPlanet.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath0 != null) neptuneDeath0.ResetTexture();
}
break;
case 1:
pd.stratosphereLevel = 1f;
var strato = atmo.GetComponentInChildren<StratosphereEffects>(true);
if (strato != null)
{
foreach (Transform child in strato.transform)
if (child.name.StartsWith("GodRay_"))
UnityEngine.Object.Destroy(child.gameObject);
strato.enabled = false;
}
var stratoDeath = atmo.GetComponentInChildren<StratosphereDeath>(true);
if (stratoDeath != null)
{
stratoDeath.ResetState();
stratoDeath.enabled = false;
}
if (currentPlanet.planetKey == "Venus")
{
var venusEff = atmo.GetComponentInChildren<VenusEffects>(true);
if (venusEff != null) venusEff.CleanUp();
var venusAtmo2 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo2 != null) venusAtmo2.SetLayerIntensity("Layer_Mesosphere", 0f);
if (venusAtmo2 != null) venusAtmo2.SetLayerActive("Layer_Mesosphere", false);
if (venusAtmo2 != null) venusAtmo2.SetLayerActive("Layer_Troposphere", false);
var venusDeath2 = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath2 != null) venusDeath2.ResetTexture();
}
if (currentPlanet.planetKey == "Mars")
{
var marsMeso = atmo.GetComponentInChildren<MarsMesosphereEffects>(true);
if (marsMeso != null) marsMeso.CleanUp();
var marsAtmo2 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo2 != null)
{
marsAtmo2.SetLayerIntensity("Layer_Mesosphere", 0.15f);
marsAtmo2.SetLayerActive("Layer_Troposphere", true);
marsAtmo2.SetLayerActive("Layer_Thermosphere", true);
marsAtmo2.SetLayerActive("Layer_Exosphere", true);
}
var marsDeath2 = currentPlanet.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath2 != null) marsDeath2.ResetTexture();
}
if (currentPlanet.planetKey == "Jupiter")
{
var jupiterStrato = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStrato != null) jupiterStrato.CleanUp();
var jupiterAtmo2 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo2 != null)
{
jupiterAtmo2.SetLayerIntensity("Layer_Stratosphere", 0.15f);
jupiterAtmo2.SetLayerActive("Layer_Troposphere", true);
jupiterAtmo2.SetLayerActive("Layer_Thermosphere", true);
jupiterAtmo2.SetLayerActive("Layer_Exosphere", true);
}
var jupiterStratoGlow = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStratoGlow != null && jupiterStratoGlow.jupiterGlow != null)
{
var e = jupiterStratoGlow.jupiterGlow.emission;
e.rateOverTime = 100f;
jupiterStratoGlow.jupiterGlow.Play();
}
var jupiterDeath1 = currentPlanet.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath1 != null) jupiterDeath1.ResetTexture();
}
if (currentPlanet.planetKey == "Saturn")
{
var saturnStrato = atmo.GetComponentInChildren<SaturnStratosphereEffects>(true);
if (saturnStrato != null) saturnStrato.CleanUp();
var saturnAtmo2 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo2 != null)
{
saturnAtmo2.SetLayerIntensity("Layer_Stratosphere", 0.15f);
saturnAtmo2.SetLayerActive("Layer_Troposphere", true);
saturnAtmo2.SetLayerActive("Layer_Thermosphere", true);
saturnAtmo2.SetLayerActive("Layer_Exosphere", true);
}
var saturnDeath1 = currentPlanet.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath1 != null) saturnDeath1.ResetTexture();
}
if (currentPlanet.planetKey == "Uranus")
{
var uranusStrato = atmo.GetComponentInChildren<UranusStratosphereEffects>(true);
if (uranusStrato != null) uranusStrato.CleanUp();
var uranusAtmo2 = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo2 != null)
{
uranusAtmo2.SetLayerIntensity("Layer_Stratosphere", 0.15f);
uranusAtmo2.SetLayerActive("Layer_Troposphere", true);
uranusAtmo2.SetLayerActive("Layer_Thermosphere", true);
}
var uranusDeath1 = currentPlanet.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath1 != null) uranusDeath1.ResetTexture();
}
if (currentPlanet.planetKey == "Neptune")
{
var neptuneStrato = atmo.GetComponentInChildren<NeptuneStratosphereEffects>(true);
if (neptuneStrato != null) neptuneStrato.CleanUp();
var neptuneAtmo2 = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo2 != null)
{
neptuneAtmo2.SetLayerIntensity("Layer_Stratosphere", 0.15f);
neptuneAtmo2.SetLayerActive("Layer_Troposphere", true);
neptuneAtmo2.SetLayerActive("Layer_Thermosphere", true);
}
var neptuneDeath1 = currentPlanet.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath1 != null) neptuneDeath1.ResetTexture();
}
break;
case 2:
pd.mesosphereLevel = 1f;
var meso = atmo.GetComponentInChildren<MesosphereEffects>(true);
if (meso != null)
{
meso.mesosphereLevel = 1f;
meso.enabled = false;
}
if (currentPlanet.planetKey == "Venus")
{
var venusThermo = atmo.GetComponentInChildren<VenusThermosphereEffects>(true);
if (venusThermo != null) venusThermo.CleanUp();
var venusAtmo3 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo3 != null) venusAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
if (venusAtmo3 != null) venusAtmo3.SetLayerActive("Layer_Thermosphere", false);
var venusDeath3 = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath3 != null) venusDeath3.ResetTexture();
}
if (currentPlanet.planetKey == "Mars")
{
var marsThermo = atmo.GetComponentInChildren<MarsThermosphereEffects>(true);
if (marsThermo != null) marsThermo.CleanUp();
var marsAtmo3 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo3 != null)
{
marsAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
marsAtmo3.SetLayerActive("Layer_Troposphere", true);
marsAtmo3.SetLayerActive("Layer_Mesosphere", true);
marsAtmo3.SetLayerActive("Layer_Exosphere", true);
}
var marsDeath3 = currentPlanet.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath3 != null) marsDeath3.ResetTexture();
}
if (currentPlanet.planetKey == "Jupiter")
{
var jupiterThermo = atmo.GetComponentInChildren<JupiterThermosphereEffects>(true);
if (jupiterThermo != null) jupiterThermo.CleanUp();
var jupiterAtmo3 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo3 != null)
{
jupiterAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
jupiterAtmo3.SetLayerActive("Layer_Troposphere", true);
jupiterAtmo3.SetLayerActive("Layer_Stratosphere", true);
jupiterAtmo3.SetLayerActive("Layer_Exosphere", true);
}
var jupiterDeath2 = currentPlanet.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath2 != null) jupiterDeath2.ResetTexture();
}
if (currentPlanet.planetKey == "Saturn")
{
var saturnThermo = atmo.GetComponentInChildren<SaturnThermosphereEffects>(true);
if (saturnThermo != null) saturnThermo.CleanUp();
var saturnAtmo3 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo3 != null)
{
saturnAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
saturnAtmo3.SetLayerActive("Layer_Troposphere", true);
saturnAtmo3.SetLayerActive("Layer_Stratosphere", true);
saturnAtmo3.SetLayerActive("Layer_Exosphere", true);
}
var saturnDeath2 = currentPlanet.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath2 != null) saturnDeath2.ResetTexture();
}
if (currentPlanet.planetKey == "Uranus")
{
var uranusThermo = atmo.GetComponentInChildren<UranusThermosphereEffects>(true);
if (uranusThermo != null) uranusThermo.CleanUp();
var uranusAtmo3 = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo3 != null)
{
uranusAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
uranusAtmo3.SetLayerActive("Layer_Troposphere", true);
uranusAtmo3.SetLayerActive("Layer_Stratosphere", true);
}
var uranusDeath2 = currentPlanet.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath2 != null) uranusDeath2.ResetTexture();
}
if (currentPlanet.planetKey == "Neptune")
{
var neptuneThermo = atmo.GetComponentInChildren<NeptuneThermosphereEffects>(true);
if (neptuneThermo != null) neptuneThermo.CleanUp();
var neptuneAtmo3 = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo3 != null)
{
neptuneAtmo3.SetLayerIntensity("Layer_Thermosphere", 0.15f);
neptuneAtmo3.SetLayerActive("Layer_Troposphere", true);
neptuneAtmo3.SetLayerActive("Layer_Stratosphere", true);
}
var neptuneDeath2 = currentPlanet.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath2 != null) neptuneDeath2.ResetTexture();
}
break;
case 3:
pd.thermosphereLevel = 1f;
var thermo = atmo.GetComponentInChildren<ThermosphereEffects>(true);
if (thermo != null)
{
thermo.thermosphereLevel = 1f;
thermo.InitState();
thermo.enabled = false;
}
if (currentPlanet.planetKey == "Venus")
{
var venusExo = atmo.GetComponentInChildren<VenusExosphereEffects>(true);
if (venusExo != null) venusExo.CleanUp();
var venusAtmo4 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo4 != null) venusAtmo4.SetLayerIntensity("Layer_Exosphere", 0.15f);
if (venusAtmo4 != null) venusAtmo4.SetLayerActive("Layer_Exosphere", false);
var venusDeath4 = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath4 != null) venusDeath4.ResetTexture();
}
if (currentPlanet.planetKey == "Mars")
{
var marsAtmo4 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo4 != null)
{
marsAtmo4.SetLayerIntensity("Layer_Exosphere", 0.15f);
marsAtmo4.SetLayerActive("Layer_Troposphere", true);
marsAtmo4.SetLayerActive("Layer_Mesosphere", true);
marsAtmo4.SetLayerActive("Layer_Thermosphere", true);
}
var marsDeath4 = currentPlanet.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath4 != null) marsDeath4.ResetTexture();
var marsExo = atmo.GetComponentInChildren<MarsExosphereEffects>(true);
if (marsExo != null) marsExo.CleanUp();
}
if (currentPlanet.planetKey == "Jupiter")
{
var jupiterExo = atmo.GetComponentInChildren<JupiterExosphereEffects>(true);
if (jupiterExo != null) jupiterExo.CleanUp();
var jupiterAtmo4 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo4 != null)
{
jupiterAtmo4.SetLayerIntensity("Layer_Exosphere", 0.15f);
jupiterAtmo4.SetLayerActive("Layer_Troposphere", true);
jupiterAtmo4.SetLayerActive("Layer_Stratosphere", true);
jupiterAtmo4.SetLayerActive("Layer_Thermosphere", true);
}
var jupiterDeath3 = currentPlanet.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath3 != null) jupiterDeath3.ResetTexture();
}
if (currentPlanet.planetKey == "Saturn")
{
var saturnExo = atmo.GetComponentInChildren<SaturnExosphereEffects>(true);
if (saturnExo != null) saturnExo.CleanUp();
var saturnAtmo4 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo4 != null)
{
saturnAtmo4.SetLayerIntensity("Layer_Exosphere", 0.15f);
saturnAtmo4.SetLayerActive("Layer_Troposphere", true);
saturnAtmo4.SetLayerActive("Layer_Stratosphere", true);
saturnAtmo4.SetLayerActive("Layer_Thermosphere", true);
}
var saturnDeath3 = currentPlanet.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath3 != null) saturnDeath3.ResetTexture();
}
break;
case 4:
pd.exosphereLevel = 1f;
var exo = atmo.GetComponentInChildren<ExosphereEffects>(true);
if (exo != null)
{
exo.exosphereLevel = 1f;
exo.enabled = false;
}
break;
}
pd.ResetTextureCache();
}
public void FinishSimulation()
{
ResetCurrentLayer();
if (currentPlanet != null && currentPlanet.planetKey == "Mercury")
RestoreMercuryAtmosphere();
if (currentPlanet != null && currentPlanet.planetKey == "Venus")
RestoreVenusAtmosphere();
simulationPanel.SetActive(false);
if (currentPlanet != null && (currentPlanet.planetKey == "Mercury" || currentPlanet.planetKey == "Venus" || currentPlanet.planetKey == "Jupiter" || currentPlanet.planetKey == "Saturn" || currentPlanet.planetKey == "Uranus" || currentPlanet.planetKey == "Neptune"))
{
Vector3? offset = currentPlanet.useCustomOffset ? currentPlanet.customOffset : (Vector3?)null;
Vector3? customRot = currentPlanet.planetKey == "Saturn" ? new Vector3(25f, -70f, 0f) : (Vector3?)null;
cameraController.FlyTo(currentPlanet.planetTransform, () =>
{
if (questionPanel != null) questionPanel.SetActive(true);
if (QuestionController.Instance != null)
{
if ((currentPlanet.planetKey == "Venus" || currentPlanet.planetKey == "Saturn") && currentPlanetInfo.questions != null)
{
var questionData = System.Array.ConvertAll(
currentPlanetInfo.questions,
q => new QuestionController.QuestionData
{
text = q.text,
isYesCorrect = q.isYesCorrect
}
);
QuestionController.Instance.ShowQuestions(questionData);
}
else
{
QuestionController.Instance.ShowQuestion(
currentPlanetInfo.questionText,
currentPlanetInfo.questionCorrectAnswer
);
}
}
}, offset, customRot);
return;
}
if (currentPlanet != null && currentPlanet.planetKey == "Mars")
{
cameraController.FlyTo(currentPlanet.planetTransform, () =>
{
if (AnswerSelectionController.Instance != null && currentPlanetInfo.answerQuestion != null)
AnswerSelectionController.Instance.ShowQuestions(
new AnswerSelectionController.AnswerQuestion[] { currentPlanetInfo.answerQuestion }
);
});
return;
}
cameraController.FlyTo(currentPlanet.planetTransform, () =>
{
layerOrderPanel.SetActive(true);
planetSelectPanel.SetActive(true);
LayerOrderController.Instance.SetupForPlanet(currentPlanetInfo);
});
}
void RestoreVenusAtmosphere()
{
var atmo = currentPlanet?.atmosphereSystem;
if (atmo == null) return;
atmo.SetActive(true);
var venusAtmo = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo != null)
{
venusAtmo.SetLayerActive("Layer_Troposphere", true);
venusAtmo.SetLayerActive("Layer_Mesosphere", true);
venusAtmo.SetLayerActive("Layer_Thermosphere", true);
venusAtmo.SetLayerActive("Layer_Exosphere", true);
venusAtmo.SetLayerIntensity("Layer_Troposphere", 2.5f);
venusAtmo.SetLayerIntensity("Layer_Mesosphere", 2.0f);
venusAtmo.SetLayerIntensity("Layer_Thermosphere", 1.5f);
venusAtmo.SetLayerIntensity("Layer_Exosphere", 1.2f);
}
var venusDeath = currentPlanet.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath != null) venusDeath.ResetTexture();
}
public void OnLayerOrderComplete()
{
layerOrderPanel.SetActive(false);
planetSelectPanel.SetActive(false);
positionSaved = false;
cameraController.FlyToSavedPosition(() =>
{
planetSelectPanel.SetActive(true);
});
}
void RestoreMercuryAtmosphere()
{
var atmo = currentPlanet?.atmosphereSystem;
if (atmo == null) return;
atmo.SetActive(true);
var layerRenderer = atmo.GetComponentInChildren<Renderer>(true);
if (layerRenderer != null)
{
layerRenderer.material.SetFloat("_RimIntensity", 2.5f);
layerRenderer.material.SetFloat("_CoreIntensity", 0.4f);
}
var mercuryDeath = currentPlanet.planetTransform?.GetComponent<MercuryDeath>();
if (mercuryDeath == null)
mercuryDeath = currentPlanet.planetTransform?.GetComponentInChildren<MercuryDeath>();
if (mercuryDeath != null)
mercuryDeath.ResetTexture();
}
public void OnQuestionComplete()
{
var atmo = currentPlanet?.atmosphereSystem;
if (atmo != null)
{
var mercury = atmo.GetComponentInChildren<MercuryEffects>(true);
if (mercury != null)
{
if (mercury.SodiumGlowSystem != null) Destroy(mercury.SodiumGlowSystem.gameObject);
if (mercury.SolarWindSystem != null) Destroy(mercury.SolarWindSystem.gameObject);
mercury.enabled = false;
}
atmo.SetActive(true);
var layerExo = atmo.GetComponentInChildren<Renderer>(true);
if (layerExo != null)
{
layerExo.material.SetFloat("_RimIntensity", 2.5f);
layerExo.material.SetFloat("_CoreIntensity", 0.4f);
}
}
var mercuryDeath = currentPlanet?.planetTransform?.GetComponent<MercuryDeath>();
if (mercuryDeath == null)
mercuryDeath = currentPlanet?.planetTransform?.GetComponentInChildren<MercuryDeath>();
if (mercuryDeath != null)
mercuryDeath.ResetTexture();
questionPanel.SetActive(false);
planetSelectPanel.SetActive(false);
positionSaved = false;
cameraController.FlyToSavedPosition(() =>
{
planetSelectPanel.SetActive(true);
});
}
void ResetAllLayers()
{
var atmo = currentPlanet?.atmosphereSystem;
if (atmo == null) return;
var mercury = atmo.GetComponentInChildren<MercuryEffects>(true);
if (mercury != null)
{
mercury.exosphereLevel = 1f;
mercury.previousLevel = 1f;
if (mercury.SodiumGlowSystem != null)
Destroy(mercury.SodiumGlowSystem.gameObject);
if (mercury.SolarWindSystem != null)
Destroy(mercury.SolarWindSystem.gameObject);
mercury.enabled = false;
}
var mercuryDeath = currentPlanet.planetTransform?.GetComponent<MercuryDeath>();
if (mercuryDeath == null)
mercuryDeath = currentPlanet.planetTransform?.GetComponentInChildren<MercuryDeath>();
if (mercuryDeath != null)
mercuryDeath.ResetTexture();
PlanetDeath pd = GameObject.FindObjectOfType<PlanetDeath>();
if (pd != null)
{
pd.troposphereLevel = 1f;
pd.stratosphereLevel = 1f;
pd.mesosphereLevel = 1f;
pd.thermosphereLevel = 1f;
pd.exosphereLevel = 1f;
pd.ResetTextureCache();
}
}
public void ShowPlanetSelect()
{
foreach (var p in planets)
if (p.atmosphereSystem != null)
p.atmosphereSystem.SetActive(false);
planetSelectPanel.SetActive(true);
infoPanel.SetActive(false);
layerOrderPanel.SetActive(false);
simulationPanel.SetActive(false);
}
public PlanetDatabase.PlanetInfo GetCurrentPlanetInfo() => currentPlanetInfo;
public PlanetData GetCurrentPlanet() => currentPlanet;
}