initial commit

This commit is contained in:
2026-05-29 18:21:53 +03:00
commit 66ddf0ead0
2184 changed files with 1384338 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class AnswerSelectionController : MonoBehaviour
{
public static AnswerSelectionController Instance;
[Header("UI")]
public GameObject answerSelectionPanel;
public TextMeshProUGUI descriptionText;
public Toggle[] toggles;
public Button checkButton;
[Header("Êîëüîðè")]
public Color correctColor = new Color(0.3f, 1f, 0.3f);
public Color wrongColor = new Color(1f, 0.3f, 0.3f);
public Color missedColor = new Color(1f, 0.8f, 0f);
public Color defaultColor = new Color(0.725f, 0.522f, 0.949f);
public class AnswerQuestion
{
public string questionText;
public string[] answers;
public int[] correctIndices;
}
private AnswerQuestion[] questions;
private int currentQuestionIndex = 0;
private int[] shuffledIndices;
void Awake()
{
Instance = this;
if (answerSelectionPanel != null)
answerSelectionPanel.SetActive(false);
}
public void ShowQuestions(AnswerQuestion[] questionList)
{
questions = questionList;
currentQuestionIndex = 0;
answerSelectionPanel.SetActive(true);
ShowCurrentQuestion();
}
void ShowCurrentQuestion()
{
if (questions == null || currentQuestionIndex >= questions.Length) return;
var q = questions[currentQuestionIndex];
if (descriptionText != null)
descriptionText.text = q.questionText;
shuffledIndices = ShuffleIndices(q.answers.Length);
for (int i = 0; i < toggles.Length; i++)
{
if (i < q.answers.Length)
{
toggles[i].gameObject.SetActive(true);
toggles[i].isOn = false;
toggles[i].interactable = true;
var label = toggles[i].GetComponentInChildren<Text>();
if (label != null)
label.text = q.answers[shuffledIndices[i]];
var bg = toggles[i].transform.Find("Background")?.GetComponent<Image>();
if (bg != null) bg.color = defaultColor;
}
else
{
toggles[i].gameObject.SetActive(false);
}
}
checkButton.interactable = true;
var btnImg = checkButton.GetComponent<Image>();
if (btnImg != null) btnImg.color = defaultColor;
}
int[] ShuffleIndices(int count)
{
int[] indices = new int[count];
for (int i = 0; i < count; i++)
indices[i] = i;
for (int i = count - 1; i > 0; i--)
{
int j = Random.Range(0, i + 1);
int tmp = indices[i];
indices[i] = indices[j];
indices[j] = tmp;
}
return indices;
}
public void OnCheckPressed()
{
if (questions == null || currentQuestionIndex >= questions.Length) return;
var q = questions[currentQuestionIndex];
checkButton.interactable = false;
for (int i = 0; i < toggles.Length; i++)
{
if (!toggles[i].gameObject.activeSelf) continue;
toggles[i].interactable = false;
int originalIndex = shuffledIndices[i];
bool isCorrect = System.Array.IndexOf(q.correctIndices, originalIndex) >= 0;
bool isSelected = toggles[i].isOn;
var bg = toggles[i].transform.Find("Background")?.GetComponent<Image>();
if (bg == null) continue;
if (isCorrect && isSelected)
bg.color = correctColor;
else if (isCorrect && !isSelected)
bg.color = missedColor;
else if (!isCorrect && isSelected)
bg.color = wrongColor;
else
bg.color = defaultColor;
}
StartCoroutine(NextAfterDelay());
}
IEnumerator NextAfterDelay()
{
yield return new WaitForSeconds(2f);
currentQuestionIndex++;
if (currentQuestionIndex < questions.Length)
ShowCurrentQuestion();
else
{
answerSelectionPanel.SetActive(false);
GameManager.Instance.OnQuestionComplete();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a52e759f209ece24aa123343a4290076
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AtmosphereLayer : MonoBehaviour
{
public string layerName;
public float altitudeStartKm;
public float altitudeEndKm;
[TextArea(2, 4)]
public string description;
public float ThicknessKm => altitudeEndKm - altitudeStartKm;
public void OnLayerClicked()
{
Debug.Log(layerName + " | " + altitudeStartKm + "-" + altitudeEndKm + " êì");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9f7a5c3de73a914499d2c4546edbe66
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AtmosphereRotator : MonoBehaviour
{
public float rotationSpeedX = 0f;
public float rotationSpeedY = 2f;
public float rotationSpeedZ = 0f;
void Update()
{
transform.Rotate(rotationSpeedX * Time.deltaTime,
rotationSpeedY * Time.deltaTime,
rotationSpeedZ * Time.deltaTime,
Space.World);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77ce9ec2e0562ab41aefaf68943223dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class AtmosphereSystem : MonoBehaviour
{
public float earthRadiusUnits = 6.371f;
public float heightMultiplier = 50f;
private struct LayerData
{
public string name;
public float altitudeStartKm;
public float altitudeEndKm;
public Color color;
public float opacity;
public string description;
}
private LayerData[] layers = new LayerData[]
{
new LayerData { name = "Troposphere", altitudeStartKm = 0f, altitudeEndKm = 12f, color = new Color(0.40f, 0.75f, 1.00f), opacity = 0.55f, description = "0-12 êì. Ïîâ³òðÿ, ïîãîäà, õìàðè." },
new LayerData { name = "Stratosphere", altitudeStartKm = 12f, altitudeEndKm = 50f, color = new Color(0.20f, 0.50f, 0.90f), opacity = 0.45f, description = "12-50 êì. Îçîíîâèé øàð, UV." },
new LayerData { name = "Mesosphere", altitudeStartKm = 50f, altitudeEndKm = 85f, color = new Color(0.10f, 0.25f, 0.70f), opacity = 0.38f, description = "50-85 êì. Ìåòåîðèòè çãîðÿþòü." },
new LayerData { name = "Thermosphere", altitudeStartKm = 85f, altitudeEndKm = 600f, color = new Color(0.05f, 0.10f, 0.50f), opacity = 0.28f, description = "85-600 êì. ÌÊÑ, ïîëÿðíå ñÿéâî." },
new LayerData { name = "Exosphere", altitudeStartKm = 600f, altitudeEndKm = 10000f, color = new Color(0.15f, 0.10f, 0.45f), opacity = 0.22f, description = "600-10000 êì. Ïåðåõ³ä äî êîñìîñó." }
};
void Start()
{
}
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
DestroyOldLayers();
for (int i = 0; i < layers.Length; i++)
CreateLayerSphere(layers[i]);
}
GameObject CreateLayerSphere(LayerData data)
{
float radiusUnits = earthRadiusUnits + (data.altitudeEndKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = "Layer_" + data.name;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying)
Destroy(obj.GetComponent<Collider>());
else
DestroyImmediate(obj.GetComponent<Collider>());
obj.GetComponent<Renderer>().material = CreateURPMaterial(data.color, data.opacity);
AtmosphereLayer layerComp = obj.AddComponent<AtmosphereLayer>();
layerComp.layerName = data.name;
layerComp.altitudeStartKm = data.altitudeStartKm;
layerComp.altitudeEndKm = data.altitudeEndKm;
layerComp.description = data.description;
return obj;
}
Material CreateURPMaterial(Color color, float opacity)
{
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
Color coreColor = new Color(color.r * 0.2f, color.g * 0.3f, color.b * 0.6f, opacity * 0.5f);
mat.SetColor("_RimColor", color);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 1.5f);
mat.SetFloat("_RimIntensity", 2.5f);
mat.SetFloat("_CoreIntensity", 0.4f);
mat.SetFloat("_PulseSpeed", 0.8f);
mat.SetFloat("_PulseStrength", 0.15f);
return mat;
}
void DestroyOldLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying)
Destroy(child.gameObject);
else
DestroyImmediate(child.gameObject);
}
}
}
public void SetLayerVisible(int index, bool visible)
{
Transform child = transform.Find("Layer_" + layers[index].name);
if (child != null) child.gameObject.SetActive(visible);
}
public int GetLayerCount() => layers.Length;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cb3335a4d032a81438a944a6cadfa932
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class CameraController : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ ïîëüîòó")]
public float flightDuration = 4f;
public AnimationCurve flightCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
[Header("Ô³íàëüíà ïîçèö³ÿ â³äíîñíî ïëàíåòè")]
public Vector3 finalOffset = new Vector3(100f, 20f, -40f);
public Vector3 finalRotation = new Vector3(8f, -70f, 0f);
private bool isFlying = false;
private Vector3 savedPosition;
private Quaternion savedRotation;
public void SavePosition()
{
savedPosition = transform.position;
savedRotation = transform.rotation;
}
public void FlyToSavedPosition(System.Action onArrived = null)
{
StopAllCoroutines();
StartCoroutine(FlyToSavedCoroutine(onArrived));
}
IEnumerator FlyToSavedCoroutine(System.Action onArrived)
{
Vector3 startPos = transform.position;
Quaternion startRot = transform.rotation;
Vector3 mid = Vector3.Lerp(startPos, savedPosition, 0.5f);
mid += Vector3.up * Vector3.Distance(startPos, savedPosition) * 0.3f;
float elapsed = 0f;
while (elapsed < flightDuration)
{
elapsed += Time.deltaTime;
float t = flightCurve.Evaluate(elapsed / flightDuration);
Vector3 p1 = Vector3.Lerp(startPos, mid, t);
Vector3 p2 = Vector3.Lerp(mid, savedPosition, t);
transform.position = Vector3.Lerp(p1, p2, t);
transform.rotation = Quaternion.Slerp(startRot, savedRotation, t);
yield return null;
}
transform.position = savedPosition;
transform.rotation = savedRotation;
onArrived?.Invoke();
}
public void FlyTo(Transform target, Action onArrived = null, Vector3? customOffset = null, Vector3? customRotation = null)
{
StopAllCoroutines();
isFlying = false;
StartCoroutine(FlyCoroutine(target, onArrived, customOffset, customRotation));
}
IEnumerator FlyCoroutine(Transform target, Action onArrived, Vector3? customOffset = null, Vector3? customRotation = null)
{
isFlying = true;
Vector3 startPos = transform.position;
Quaternion startRot = transform.rotation;
float planetRadius = target.lossyScale.x * 0.5f;
float scale = planetRadius / 6.371f;
Vector3 offset = customOffset.HasValue ? customOffset.Value : finalOffset * scale;
Vector3 targetPos = target.position + offset;
Quaternion targetRot = customRotation.HasValue ? Quaternion.Euler(customRotation.Value) : Quaternion.Euler(finalRotation);
Vector3 mid = Vector3.Lerp(startPos, targetPos, 0.5f);
mid += Vector3.up * Vector3.Distance(startPos, targetPos) * 0.3f;
mid += Vector3.right * Vector3.Distance(startPos, targetPos) * 0.2f;
float elapsed = 0f;
while (elapsed < flightDuration)
{
elapsed += Time.deltaTime;
float t = flightCurve.Evaluate(elapsed / flightDuration);
Vector3 p1 = Vector3.Lerp(startPos, mid, t);
Vector3 p2 = Vector3.Lerp(mid, targetPos, t);
transform.position = Vector3.Lerp(p1, p2, t);
transform.rotation = Quaternion.Slerp(startRot, targetRot, t);
yield return null;
}
transform.position = targetPos;
transform.rotation = targetRot;
isFlying = false;
onArrived?.Invoke();
}
public void FlyToLayer(Transform layer, Action onArrived = null, float cameraMultiplier = 1f)
{
StopAllCoroutines();
isFlying = false;
StartCoroutine(FlyToLayerCoroutine(layer, onArrived, cameraMultiplier));
}
IEnumerator FlyToLayerCoroutine(Transform layer, Action onArrived, float cameraMultiplier = 1f)
{
isFlying = true;
Vector3 startPos = transform.position;
Quaternion startRot = transform.rotation;
float layerRadius = layer.lossyScale.x * 0.5f;
Vector3 targetPos = layer.position + new Vector3(layerRadius * 1.1f * cameraMultiplier, layerRadius * 0.3f, -layerRadius * 0.7f * cameraMultiplier);
Quaternion targetRot = Quaternion.LookRotation(layer.position - targetPos);
float elapsed = 0f;
while (elapsed < flightDuration)
{
elapsed += Time.deltaTime;
float t = flightCurve.Evaluate(elapsed / flightDuration);
transform.position = Vector3.Lerp(startPos, targetPos, t);
transform.rotation = Quaternion.Slerp(startRot, targetRot, t);
yield return null;
}
transform.position = targetPos;
transform.rotation = targetRot;
isFlying = false;
onArrived?.Invoke();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac3bc35875c73ab48933500cd005e49c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CursorSet : MonoBehaviour
{
[SerializeField] private Texture2D cursorTexture;
private void Start()
{
Vector2 hotSpot = new Vector2(0, 0);
Cursor.SetCursor(cursorTexture, hotSpot, CursorMode.Auto);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67c9122b737e55342a054ed83b01bcce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
public class DraggableCard : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public string layerName;
private RectTransform rectTransform;
private CanvasGroup canvasGroup;
private Vector2 startPosition;
private Transform startParent;
private Canvas canvas;
void Awake()
{
rectTransform = GetComponent<RectTransform>();
canvasGroup = GetComponent<CanvasGroup>();
if (canvasGroup == null)
canvasGroup = gameObject.AddComponent<CanvasGroup>();
canvas = GetComponentInParent<Canvas>();
}
void Start()
{
startPosition = rectTransform.anchoredPosition;
startParent = transform.parent;
}
public void OnBeginDrag(PointerEventData eventData)
{
if (transform.parent != startParent)
{
DropZone currentZone = transform.parent.GetComponent<DropZone>();
if (currentZone != null)
currentZone.currentCard = null;
}
transform.SetParent(canvas.transform);
transform.SetAsLastSibling();
canvasGroup.blocksRaycasts = false;
}
public void OnDrag(PointerEventData eventData)
{
rectTransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
}
public void OnEndDrag(PointerEventData eventData)
{
canvasGroup.blocksRaycasts = true;
if (transform.parent == canvas.transform)
ReturnToOriginal();
}
public void ReturnToOriginal()
{
transform.SetParent(startParent);
rectTransform.anchoredPosition = startPosition;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7769a3ed7c7ff2458310b9a5f87f72b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class DropZone : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler
{
public int slotIndex;
public DraggableCard currentCard;
private Image image;
void Awake()
{
image = GetComponent<Image>();
}
public void OnDrop(PointerEventData eventData)
{
DraggableCard card = eventData.pointerDrag?.GetComponent<DraggableCard>();
if (card == null) return;
if (currentCard != null && currentCard != card)
currentCard.ReturnToOriginal();
currentCard = card;
card.transform.SetParent(transform);
card.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
}
public void OnPointerEnter(PointerEventData eventData)
{
if (image != null)
image.color = new Color(1f, 1f, 1f, 0.5f);
}
public void OnPointerExit(PointerEventData eventData)
{
if (image != null)
image.color = new Color(1f, 1f, 1f, 0.2f);
}
public void SetCorrect()
{
if (image != null) image.color = new Color(0f, 1f, 0f, 0.5f);
}
public void SetWrong()
{
if (image != null) image.color = new Color(1f, 0f, 0f, 0.5f);
}
public void ResetColor()
{
if (image != null) image.color = new Color(1f, 1f, 1f, 0.2f);
currentCard = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b64c56a9db655184c896c54f26354cf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,140 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExosphereEffects : MonoBehaviour
{
[Header("Ñóïóòíèêè")]
public ThermosphereEffects thermosphereEffects;
[Header("Âèò³êàííÿ àòìîñôåðè")]
public Material leakMaterial;
public float leakRadius = 55f;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
private ParticleSystem leakSystem;
void Start()
{
CreateLeakEffect();
}
void CreateLeakEffect()
{
GameObject obj = new GameObject("AtmosphericLeak");
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one;
leakSystem = obj.AddComponent<ParticleSystem>();
var main = leakSystem.main;
main.loop = true;
main.playOnAwake = false;
main.maxParticles = 50000;
main.startLifetime = new ParticleSystem.MinMaxCurve(8f, 15f);
main.startSpeed = new ParticleSystem.MinMaxCurve(10f, 30f);
main.startSize = new ParticleSystem.MinMaxCurve(1.2f, 1.8f);
main.gravityModifier = -0.3f;
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.2f, 0.5f, 1.0f, 1f),
new Color(0.4f, 0.8f, 1.0f, 0.9f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
var emission = leakSystem.emission;
emission.rateOverTime = 0f;
var shape = leakSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = leakRadius * 0.5f;
shape.radiusThickness = 0f;
var colorOverLifetime = leakSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.2f, 0.5f, 1.0f), 0f),
new GradientColorKey(new Color(0.4f, 0.8f, 1.0f), 0.5f),
new GradientColorKey(new Color(0.1f, 0.1f, 0.4f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.6f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var sizeOverLifetime = leakSystem.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve sizeCurve = new AnimationCurve();
sizeCurve.AddKey(0f, 0f);
sizeCurve.AddKey(0.1f, 1f);
sizeCurve.AddKey(0.8f, 0.8f);
sizeCurve.AddKey(1f, 0f);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, sizeCurve);
var psRenderer = leakSystem.GetComponent<ParticleSystemRenderer>();
psRenderer.renderMode = ParticleSystemRenderMode.Billboard;
psRenderer.sortingFudge = 5f;
if (leakMaterial != null)
psRenderer.material = leakMaterial;
}
void UpdateLeak()
{
if (leakSystem == null) return;
var emission = leakSystem.emission;
if (exosphereLevel <= 0f)
{
emission.rateOverTime = 0f;
leakSystem.gameObject.SetActive(false);
return;
}
leakSystem.gameObject.SetActive(true);
if (exosphereLevel <= 0.7f)
{
float t = Mathf.InverseLerp(0.7f, 0f, exosphereLevel);
emission.rateOverTime = Mathf.Lerp(100f, 2000f, t);
if (!leakSystem.isPlaying)
leakSystem.Play();
}
else
{
emission.rateOverTime = 0f;
}
}
void Update()
{
if (!Application.isPlaying) return;
UpdateGPS();
UpdateLeak();
}
void Awake()
{
enabled = false;
}
void UpdateGPS()
{
if (thermosphereEffects == null) return;
if (exosphereLevel < 0.3f)
thermosphereEffects.DropAllSatellites();
}
public void SetExosphereLevel(float level)
{
exosphereLevel = level;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2fc2a307a2125b94aab0e38abc5560ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,825 @@
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;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5fb672d5a84c0d4aad9efa1f738c59a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,150 @@
using UnityEngine;
[ExecuteAlways]
public class JupiterAtmosphereSystem : MonoBehaviour
{
public float jupiterRadiusUnits = 7.1492f;
public float heightMultiplier = 8f;
[Header("Òåêñòóðè äëÿ òðîïîñôåðè ³ ñòðàòîñôåðè")]
public Texture2D jupiterTexture1;
public Texture2D jupiterTexture2;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateTextureLayer("Layer_Troposphere", 300f,
new Color(0.7f, 0.4f, 0.15f),
new Color(0.5f, 0.25f, 0.08f),
2.0f, 0.6f, 0.02f, -0.01f);
CreateTextureLayer("Layer_Stratosphere", 600f,
new Color(0.85f, 0.7f, 0.4f),
new Color(0.6f, 0.5f, 0.2f),
1.5f, 0.4f, 0.015f, -0.008f);
CreateSimpleLayer("Layer_Thermosphere", 900f,
new Color(0.4f, 0.3f, 0.8f),
new Color(0.2f, 0.1f, 0.5f),
1.0f, 0.2f);
CreateSimpleLayer("Layer_Exosphere", 1200f,
new Color(0.6f, 0.5f, 0.9f),
new Color(0.3f, 0.2f, 0.6f),
0.6f, 0.1f);
}
void CreateTextureLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity,
float scrollSpeed1, float scrollSpeed2)
{
float radiusUnits = jupiterRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/JupiterAtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_ScrollSpeed1", scrollSpeed1);
mat.SetFloat("_ScrollSpeed2", scrollSpeed2);
mat.SetFloat("_PulseSpeed", 0.3f);
mat.SetFloat("_PulseStrength", 0.1f);
mat.SetFloat("_TextureBlend", 0.5f);
mat.SetFloat("_TextureInfluence", 0.5f);
if (jupiterTexture1 != null) mat.SetTexture("_MainTex", jupiterTexture1);
if (jupiterTexture2 != null) mat.SetTexture("_SecondTex", jupiterTexture2);
obj.GetComponent<Renderer>().material = mat;
}
void CreateSimpleLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity)
{
float radiusUnits = jupiterRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_PulseSpeed", 0.3f);
mat.SetFloat("_PulseStrength", 0.1f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetLayerIntensity(string layerName, float level)
{
Transform layer = transform.Find(layerName);
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
float rimBase = 0f;
float coreBase = 0f;
switch (layerName)
{
case "Layer_Troposphere": rimBase = 2.0f; coreBase = 0.6f; break;
case "Layer_Stratosphere": rimBase = 1.5f; coreBase = 0.4f; break;
case "Layer_Thermosphere": rimBase = 1.0f; coreBase = 0.2f; break;
case "Layer_Exosphere": rimBase = 0.6f; coreBase = 0.1f; break;
}
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, rimBase, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, coreBase, level));
}
public void SetLayerActive(string layerName, bool active)
{
Transform layer = transform.Find(layerName);
if (layer != null) layer.gameObject.SetActive(active);
}
public void SetIntensity(float level)
{
SetLayerIntensity("Layer_Troposphere", level);
SetLayerIntensity("Layer_Stratosphere", level);
SetLayerIntensity("Layer_Thermosphere", level);
SetLayerIntensity("Layer_Exosphere", level);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74c16b7f5f651c94e92a406e4b8e4756
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,88 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JupiterDeath : MonoBehaviour
{
[Header("Òåêñòóðè òðîïîñôåðè")]
public Texture2D tropo100;
public Texture2D tropo70;
public Texture2D tropo50;
public Texture2D tropo30;
public Texture2D tropo0;
public Texture2D deadTexture;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float stratosphereLevel = 1f;
public float thermosphereLevel = 1f;
public float exosphereLevel = 1f;
private Renderer planetRenderer;
private Material mat;
private float prevLevel = -1f;
private Texture2D originalTexture;
void Start()
{
planetRenderer = GetComponent<Renderer>();
if (planetRenderer == null)
planetRenderer = GetComponentInChildren<Renderer>();
if (planetRenderer != null)
{
mat = planetRenderer.material;
originalTexture = (Texture2D)mat.GetTexture("_BaseMap");
}
}
public void ResetTexture()
{
troposphereLevel = 1f;
stratosphereLevel = 1f;
thermosphereLevel = 1f;
exosphereLevel = 1f;
prevLevel = -1f;
if (mat != null && originalTexture != null)
{
mat.SetTexture("_BaseMap", originalTexture);
mat.SetTexture("_BaseMap2", originalTexture);
}
}
void Update()
{
if (mat == null) return;
UpdateTexture();
}
void UpdateTexture()
{
float worst = Mathf.Min(troposphereLevel, stratosphereLevel, thermosphereLevel, exosphereLevel);
if (worst >= 1f)
{
if (mat != null && originalTexture != null)
{
mat.SetTexture("_BaseMap", originalTexture);
mat.SetTexture("_BaseMap2", originalTexture);
}
return;
}
Texture2D tex = worst <= 0f ? deadTexture : GetTexture(worst);
if (tex != null)
{
mat.SetTexture("_BaseMap", tex);
mat.SetTexture("_BaseMap2", tex);
}
}
Texture2D GetTexture(float level)
{
if (level >= 0.7f) return tropo100;
else if (level >= 0.5f) return tropo70;
else if (level >= 0.3f) return tropo50;
else if (level > 0f) return tropo30;
else return tropo0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd3ab6f5026138847982c5bfd58a92b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,353 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JupiterExosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material tailMaterial;
public Material radiationMaterial;
public float planetRadius = 72f;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem tailSystem;
private ParticleSystem radiationBeltSystem;
private ParticleSystem solarCaptureSystem;
private bool deathTriggered = false;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (radiationBeltSystem != null) Destroy(radiationBeltSystem.gameObject);
if (solarCaptureSystem != null) Destroy(solarCaptureSystem.gameObject);
tailSystem = null;
radiationBeltSystem = null;
solarCaptureSystem = null;
deathTriggered = false;
exosphereLevel = 1f;
previousLevel = 1f;
CreateTail();
CreateRadiationBelt();
CreateSolarCapture();
}
void CreateTail()
{
GameObject obj = new GameObject("JupiterTail");
obj.transform.parent = null;
obj.transform.position = transform.position;
tailSystem = obj.AddComponent<ParticleSystem>();
var main = tailSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(3f, 8f);
main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.5f, 0.7f, 1f, 0.3f),
new Color(0.3f, 0.5f, 1f, 0.15f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = tailSystem.emission;
emission.rateOverTime = 0f;
var shape = tailSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 0.9f;
shape.radiusThickness = 1f;
var vel = tailSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.x = new ParticleSystem.MinMaxCurve(5f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = tailSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.5f, 0.7f, 1f), 0f),
new GradientColorKey(new Color(0.3f, 0.5f, 1f), 0.5f),
new GradientColorKey(new Color(0.2f, 0.3f, 0.8f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.3f, 0f),
new GradientAlphaKey(0.15f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = tailSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Stretch;
renderer.velocityScale = 0.2f;
renderer.lengthScale = 3f;
renderer.sortingFudge = 3f;
if (tailMaterial != null)
renderer.material = tailMaterial;
tailSystem.Play();
}
void CreateRadiationBelt()
{
GameObject obj = new GameObject("JupiterRadiationBelt");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
radiationBeltSystem = obj.AddComponent<ParticleSystem>();
var main = radiationBeltSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.6f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.8f, 0.4f, 1f, 0.4f),
new Color(0.6f, 0.2f, 0.8f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = radiationBeltSystem.emission;
emission.rateOverTime = 200f;
var shape = radiationBeltSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = planetRadius * 2.5f;
shape.donutRadius = 3f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = radiationBeltSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(4f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = radiationBeltSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.8f, 0.4f, 1f), 0f),
new GradientColorKey(new Color(0.6f, 0.2f, 0.8f), 0.5f),
new GradientColorKey(new Color(0.4f, 0.1f, 0.6f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.4f, 0.1f),
new GradientAlphaKey(0.2f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = radiationBeltSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (radiationMaterial != null)
renderer.material = radiationMaterial;
radiationBeltSystem.Play();
}
void CreateSolarCapture()
{
GameObject obj = new GameObject("JupiterSolarCapture");
obj.transform.parent = null;
obj.transform.position = transform.position;
solarCaptureSystem = obj.AddComponent<ParticleSystem>();
var main = solarCaptureSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 3000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 8f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.15f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.8f, 0.3f, 0.3f),
new Color(0.8f, 0.6f, 0.2f, 0.15f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = solarCaptureSystem.emission;
emission.rateOverTime = 150f;
var shape = solarCaptureSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 3f;
shape.radiusThickness = 0.3f;
var vel = solarCaptureSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = solarCaptureSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.8f, 0.3f), 0f),
new GradientColorKey(new Color(0.8f, 0.6f, 0.2f), 0.5f),
new GradientColorKey(new Color(0.6f, 0.4f, 0.1f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.3f, 0.1f),
new GradientAlphaKey(0.15f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = solarCaptureSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 1f;
if (radiationMaterial != null)
renderer.material = radiationMaterial;
solarCaptureSystem.Play();
}
void UpdateTail()
{
if (tailSystem == null) return;
var e = tailSystem.emission;
if (exosphereLevel >= 1f)
{
e.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(0f, 500f, t);
var main = tailSystem.main;
float speedMin = Mathf.Lerp(3f, 15f, t);
float speedMax = Mathf.Lerp(8f, 30f, t);
main.startSpeed = new ParticleSystem.MinMaxCurve(speedMin, speedMax);
}
void UpdateRadiationBelt()
{
if (radiationBeltSystem == null) return;
var e = radiationBeltSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(200f, 0f, t);
}
void UpdateSolarCapture()
{
if (solarCaptureSystem == null) return;
var e = solarCaptureSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(150f, 0f, t);
}
IEnumerator DeathBurst()
{
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 3000f;
var m = tailSystem.main;
m.startSpeed = new ParticleSystem.MinMaxCurve(20f, 50f);
}
if (radiationBeltSystem != null)
{
var e = radiationBeltSystem.emission;
e.rateOverTime = 0f;
}
yield return new WaitForSeconds(2f);
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 0f;
var m = tailSystem.main;
m.startSpeed = new ParticleSystem.MinMaxCurve(3f, 8f);
}
}
void Update()
{
if (!Application.isPlaying) return;
if (exosphereLevel >= 1f && previousLevel < 1f)
{
InitState();
deathTriggered = false;
}
previousLevel = exosphereLevel;
if (exosphereLevel <= 0f && !deathTriggered)
{
deathTriggered = true;
StartCoroutine(DeathBurst());
return;
}
if (deathTriggered) return;
UpdateTail();
UpdateRadiationBelt();
UpdateSolarCapture();
}
public void CleanUp()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (radiationBeltSystem != null) Destroy(radiationBeltSystem.gameObject);
if (solarCaptureSystem != null) Destroy(solarCaptureSystem.gameObject);
tailSystem = null;
radiationBeltSystem = null;
solarCaptureSystem = null;
deathTriggered = false;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 064884085e9e6c74ea5281264c55efca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,250 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JupiterStratosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material cloudMaterial;
public Material lightningMaterial;
public float planetRadius = 72f;
public ParticleSystem jupiterGlow;
[Range(0f, 1f)]
public float stratosphereLevel = 1f;
public float previousLevel = 1f;
private List<ParticleSystem> cloudClusters = new List<ParticleSystem>();
private List<GameObject> lightningObjects = new List<GameObject>();
private Coroutine lightningCoroutine;
void Awake()
{
enabled = false;
}
public void InitState()
{
foreach (var ps in cloudClusters)
if (ps != null) Destroy(ps.gameObject);
cloudClusters.Clear();
foreach (var obj in lightningObjects)
if (obj != null) Destroy(obj);
lightningObjects.Clear();
if (lightningCoroutine != null)
StopCoroutine(lightningCoroutine);
stratosphereLevel = 1f;
previousLevel = 1f;
CreateClouds();
lightningCoroutine = StartCoroutine(SpawnLightning());
if (jupiterGlow != null)
{
var e = jupiterGlow.emission;
e.rateOverTime = 100f;
if (!jupiterGlow.isPlaying) jupiterGlow.Play();
}
}
void CreateClouds()
{
float[] latitudes = { -40f, -15f, 15f, 40f };
Color[] colors =
{
new Color(0.75f, 0.5f, 0.25f),
new Color(0.85f, 0.65f, 0.35f),
new Color(0.8f, 0.6f, 0.3f),
new Color(0.7f, 0.45f, 0.2f)
};
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("JupiterCloud_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 1500;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(1.5f, 4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(colors[i].r, colors[i].g, colors[i].b, 0.35f),
new Color(colors[i].r * 0.8f, colors[i].g * 0.8f, colors[i].b * 0.8f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 80f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.1f;
shape.radiusThickness = 0.05f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(i % 2 == 0 ? 2f : -2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(colors[i], 0f),
new GradientColorKey(colors[i] * 0.8f, 0.5f),
new GradientColorKey(colors[i] * 0.6f, 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.35f, 0.15f),
new GradientAlphaKey(0.25f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.4f;
noise.frequency = 0.2f;
noise.scrollSpeed = 0.1f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 4f;
if (cloudMaterial != null)
renderer.material = cloudMaterial;
ps.Play();
cloudClusters.Add(ps);
}
}
IEnumerator SpawnLightning()
{
while (enabled)
{
if (stratosphereLevel < 1f)
{
float interval = Mathf.Lerp(0.3f, 2f, stratosphereLevel);
yield return new WaitForSeconds(interval);
Vector3 dir = Random.onUnitSphere;
Vector3 pos = transform.position + dir * planetRadius * 1.05f;
GameObject lightObj = new GameObject("JupiterLightning");
lightObj.transform.position = pos;
Light light = lightObj.AddComponent<Light>();
light.type = LightType.Point;
light.color = new Color(0.8f, 0.9f, 1f);
light.intensity = Mathf.Lerp(50f, 200f, 1f - stratosphereLevel);
light.range = planetRadius * 3f;
lightningObjects.Add(lightObj);
yield return new WaitForSeconds(0.1f);
if (lightObj != null) Destroy(lightObj);
lightningObjects.Remove(lightObj);
}
else
{
yield return new WaitForSeconds(0.5f);
}
}
}
void UpdateClouds()
{
foreach (var ps in cloudClusters)
{
if (ps == null) continue;
var emission = ps.emission;
if (stratosphereLevel >= 1f)
emission.rateOverTime = 80f;
else if (stratosphereLevel >= 0.7f)
emission.rateOverTime = Mathf.Lerp(80f, 50f, Mathf.InverseLerp(1f, 0.7f, stratosphereLevel));
else if (stratosphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(50f, 20f, Mathf.InverseLerp(0.7f, 0.5f, stratosphereLevel));
else if (stratosphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(20f, 5f, Mathf.InverseLerp(0.5f, 0.3f, stratosphereLevel));
else
emission.rateOverTime = 0f;
}
}
void UpdateGlow()
{
if (jupiterGlow == null) return;
var glowEmission = jupiterGlow.emission;
if (stratosphereLevel >= 1f)
glowEmission.rateOverTime = 100f;
else if (stratosphereLevel >= 0.7f)
glowEmission.rateOverTime = Mathf.Lerp(100f, 60f, Mathf.InverseLerp(1f, 0.7f, stratosphereLevel));
else if (stratosphereLevel >= 0.5f)
glowEmission.rateOverTime = Mathf.Lerp(60f, 30f, Mathf.InverseLerp(0.7f, 0.5f, stratosphereLevel));
else if (stratosphereLevel >= 0.3f)
glowEmission.rateOverTime = Mathf.Lerp(30f, 10f, Mathf.InverseLerp(0.5f, 0.3f, stratosphereLevel));
else if (stratosphereLevel > 0f)
glowEmission.rateOverTime = Mathf.Lerp(10f, 0f, Mathf.InverseLerp(0.3f, 0f, stratosphereLevel));
else
{
glowEmission.rateOverTime = 0f;
jupiterGlow.Stop();
}
}
void Update()
{
if (!Application.isPlaying) return;
if (stratosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = stratosphereLevel;
UpdateClouds();
UpdateGlow();
}
public void CleanUp()
{
foreach (var ps in cloudClusters)
if (ps != null) Destroy(ps.gameObject);
cloudClusters.Clear();
foreach (var obj in lightningObjects)
if (obj != null) Destroy(obj);
lightningObjects.Clear();
if (lightningCoroutine != null)
StopCoroutine(lightningCoroutine);
if (jupiterGlow != null)
{
var e = jupiterGlow.emission;
e.rateOverTime = 100f;
jupiterGlow.Play();
}
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2c0a77c2a944af4a9bf1f65cd317aa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,369 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JupiterThermosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material auroraMaterial;
public Material solarWindMaterial;
public float planetRadius = 72f;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem auroraSystemNorth;
private ParticleSystem auroraSystemSouth;
private ParticleSystem ionizationSystem;
private ParticleSystem solarWindSystem;
private Light auroraGlowNorth;
private Light auroraGlowSouth;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (auroraSystemNorth != null) Destroy(auroraSystemNorth.gameObject);
if (auroraSystemSouth != null) Destroy(auroraSystemSouth.gameObject);
if (ionizationSystem != null) Destroy(ionizationSystem.gameObject);
if (solarWindSystem != null) Destroy(solarWindSystem.gameObject);
if (auroraGlowNorth != null) Destroy(auroraGlowNorth.gameObject);
if (auroraGlowSouth != null) Destroy(auroraGlowSouth.gameObject);
auroraSystemNorth = null;
auroraSystemSouth = null;
ionizationSystem = null;
solarWindSystem = null;
auroraGlowNorth = null;
auroraGlowSouth = null;
thermosphereLevel = 1f;
previousLevel = 1f;
CreateAurora();
CreateIonization();
CreateSolarWind();
}
void CreateAurora()
{
auroraSystemNorth = CreateAuroraSystem("JupiterAuroraNorth", Vector3.up);
auroraSystemSouth = CreateAuroraSystem("JupiterAuroraSouth", Vector3.down);
GameObject glowNorthObj = new GameObject("AuroraGlowNorth");
glowNorthObj.transform.parent = null;
glowNorthObj.transform.position = transform.position + Vector3.up * planetRadius * 1.1f;
auroraGlowNorth = glowNorthObj.AddComponent<Light>();
auroraGlowNorth.type = LightType.Point;
auroraGlowNorth.color = new Color(0.3f, 0.5f, 1f);
auroraGlowNorth.intensity = 15f;
auroraGlowNorth.range = planetRadius * 6f;
GameObject glowSouthObj = new GameObject("AuroraGlowSouth");
glowSouthObj.transform.parent = null;
glowSouthObj.transform.position = transform.position + Vector3.down * planetRadius * 1.1f;
auroraGlowSouth = glowSouthObj.AddComponent<Light>();
auroraGlowSouth.type = LightType.Point;
auroraGlowSouth.color = new Color(0.3f, 0.5f, 1f);
auroraGlowSouth.intensity = 15f;
auroraGlowSouth.range = planetRadius * 6f;
}
ParticleSystem CreateAuroraSystem(string name, Vector3 poleDir)
{
GameObject obj = new GameObject(name);
obj.transform.parent = null;
obj.transform.position = transform.position + poleDir * (planetRadius * 0.9f);
obj.transform.up = poleDir;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 3000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 4f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(2f, 6f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.4f, 0.1f, 1f, 1f),
new Color(0.1f, 0.8f, 0.5f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 200f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = planetRadius * 0.4f;
shape.donutRadius = planetRadius * 0.05f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.Local;
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(5f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve sizeCurve = new AnimationCurve(
new Keyframe(0f, 0.3f),
new Keyframe(0.2f, 1f),
new Keyframe(0.8f, 0.8f),
new Keyframe(1f, 0f)
);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, sizeCurve);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.4f, 0.1f, 1f), 0f),
new GradientColorKey(new Color(0.2f, 0.6f, 1f), 0.3f),
new GradientColorKey(new Color(0.1f, 0.9f, 0.5f), 0.6f),
new GradientColorKey(new Color(0.3f, 0.2f, 1f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(1f, 0.1f),
new GradientAlphaKey(0.8f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 2f;
noise.frequency = 0.3f;
noise.scrollSpeed = 0.5f;
noise.octaveCount = 2;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (auroraMaterial != null)
renderer.material = auroraMaterial;
ps.Play();
return ps;
}
void CreateIonization()
{
GameObject obj = new GameObject("JupiterIonization");
obj.transform.parent = null;
obj.transform.position = transform.position;
ionizationSystem = obj.AddComponent<ParticleSystem>();
var main = ionizationSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 8f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.3f, 0.4f, 1f, 0.6f),
new Color(0.2f, 0.3f, 0.8f, 0.4f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ionizationSystem.emission;
emission.rateOverTime = 300f;
var shape = ionizationSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.15f;
shape.radiusThickness = 0.05f;
var vel = ionizationSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ionizationSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.3f, 0.4f, 1f), 0f),
new GradientColorKey(new Color(0.2f, 0.3f, 0.8f), 0.5f),
new GradientColorKey(new Color(0.1f, 0.2f, 0.6f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.6f, 0.15f),
new GradientAlphaKey(0.4f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = ionizationSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (auroraMaterial != null)
renderer.material = auroraMaterial;
ionizationSystem.Play();
}
void CreateSolarWind()
{
GameObject obj = new GameObject("JupiterSolarWind");
obj.transform.parent = null;
obj.transform.position = transform.position;
solarWindSystem = obj.AddComponent<ParticleSystem>();
var main = solarWindSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f, 6f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.5f, 1.5f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.9f, 0.5f, 0.7f),
new Color(1f, 0.7f, 0.3f, 0.5f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = solarWindSystem.emission;
emission.rateOverTime = 400f;
var shape = solarWindSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 2.9f;
shape.radiusThickness = 0.05f;
var vel = solarWindSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(5f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = solarWindSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.9f, 0.5f), 0f),
new GradientColorKey(new Color(1f, 0.7f, 0.3f), 0.5f),
new GradientColorKey(new Color(0.8f, 0.5f, 0.2f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.7f, 0.1f),
new GradientAlphaKey(0.5f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = solarWindSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (solarWindMaterial != null)
renderer.material = solarWindMaterial;
solarWindSystem.Play();
}
void UpdateAurora()
{
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
if (auroraSystemNorth != null)
{
var e = auroraSystemNorth.emission;
e.rateOverTime = Mathf.Lerp(100f, 0f, t);
}
if (auroraSystemSouth != null)
{
var e = auroraSystemSouth.emission;
e.rateOverTime = Mathf.Lerp(100f, 0f, t);
}
if (auroraGlowNorth != null)
auroraGlowNorth.intensity = Mathf.Lerp(3f, 0f, t);
if (auroraGlowSouth != null)
auroraGlowSouth.intensity = Mathf.Lerp(3f, 0f, t);
}
void UpdateIonization()
{
if (ionizationSystem == null) return;
var e = ionizationSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
e.rateOverTime = Mathf.Lerp(150f, 400f, t);
}
void UpdateSolarWind()
{
if (solarWindSystem == null) return;
var e = solarWindSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
e.rateOverTime = Mathf.Lerp(200f, 600f, t);
}
void Update()
{
if (!Application.isPlaying) return;
if (thermosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = thermosphereLevel;
UpdateAurora();
UpdateIonization();
UpdateSolarWind();
}
public void CleanUp()
{
if (auroraSystemNorth != null) Destroy(auroraSystemNorth.gameObject);
if (auroraSystemSouth != null) Destroy(auroraSystemSouth.gameObject);
if (ionizationSystem != null) Destroy(ionizationSystem.gameObject);
if (solarWindSystem != null) Destroy(solarWindSystem.gameObject);
if (auroraGlowNorth != null) Destroy(auroraGlowNorth.gameObject);
if (auroraGlowSouth != null) Destroy(auroraGlowSouth.gameObject);
auroraSystemNorth = null;
auroraSystemSouth = null;
ionizationSystem = null;
solarWindSystem = null;
auroraGlowNorth = null;
auroraGlowSouth = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56083e81da404a942a50b36c8178ce9d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,353 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JupiterTroposphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material stormMaterial;
public Material ringMaterial;
public Material redSpotMaterial;
public float planetRadius = 72f;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float previousLevel = 1f;
private List<ParticleSystem> bandClusters = new List<ParticleSystem>();
private ParticleSystem ringSystem;
private ParticleSystem redSpotSystem;
private Light redSpotGlow;
void Awake()
{
enabled = false;
}
public void InitState()
{
foreach (var ps in bandClusters)
if (ps != null) Destroy(ps.gameObject);
bandClusters.Clear();
if (ringSystem != null) Destroy(ringSystem.gameObject);
if (redSpotSystem != null) Destroy(redSpotSystem.gameObject);
if (redSpotGlow != null) Destroy(redSpotGlow.gameObject);
ringSystem = null;
redSpotSystem = null;
redSpotGlow = null;
troposphereLevel = 1f;
previousLevel = 1f;
CreateBands();
CreateRing();
CreateRedSpot();
}
void CreateBands()
{
float[] latitudes = { -55f, -25f, -8f, 8f, 25f, 55f };
float[] speeds = { 4f, -3f, 5f, -5f, 3f, -4f };
Color[] colors =
{
new Color(0.7f, 0.45f, 0.2f),
new Color(0.85f, 0.6f, 0.3f),
new Color(0.75f, 0.5f, 0.22f),
new Color(0.8f, 0.55f, 0.25f),
new Color(0.72f, 0.48f, 0.2f),
new Color(0.68f, 0.42f, 0.18f)
};
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("JupiterBand_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 2000;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 10f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(colors[i].r, colors[i].g, colors[i].b, 0.4f),
new Color(colors[i].r * 0.8f, colors[i].g * 0.8f, colors[i].b * 0.8f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 0f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius;
shape.radiusThickness = 0.02f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(speeds[i]);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(colors[i], 0f),
new GradientColorKey(colors[i] * 0.8f, 0.5f),
new GradientColorKey(colors[i] * 0.6f, 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.4f, 0.15f),
new GradientAlphaKey(0.3f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.5f;
noise.frequency = 0.2f;
noise.scrollSpeed = 0.1f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 4f;
if (stormMaterial != null)
renderer.material = stormMaterial;
ps.Play();
bandClusters.Add(ps);
}
}
void CreateRing()
{
float ringRadius = planetRadius * 1.8f;
GameObject obj = new GameObject("JupiterRing");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
ringSystem = obj.AddComponent<ParticleSystem>();
var main = ringSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.5f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.35f, 0.28f, 0.2f, 0.35f),
new Color(0.28f, 0.22f, 0.15f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ringSystem.emission;
emission.rateOverTime = 150f;
var shape = ringSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = ringRadius;
shape.donutRadius = 1.5f;
shape.radiusThickness = 1f;
shape.arc = 360f;
shape.rotation = new Vector3(0f, 0f, 0f);
var vel = ringSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ringSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.4f, 0.32f, 0.22f), 0f),
new GradientColorKey(new Color(0.35f, 0.27f, 0.18f), 0.5f),
new GradientColorKey(new Color(0.28f, 0.22f, 0.15f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.35f, 0.1f),
new GradientAlphaKey(0.25f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = ringSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (ringMaterial != null)
renderer.material = ringMaterial;
else if (stormMaterial != null)
renderer.material = stormMaterial;
ringSystem.Play();
}
void CreateRedSpot()
{
Vector3 redSpotDir = new Vector3(0.2f, -0.15f, 0.97f).normalized;
Vector3 redSpotPos = transform.position + redSpotDir * (planetRadius * 1.02f);
GameObject obj = new GameObject("JupiterRedSpot");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.up = Vector3.up;
redSpotSystem = obj.AddComponent<ParticleSystem>();
var main = redSpotSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 3000;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f, 6f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.95f, 0.15f, 0.05f, 0.9f),
new Color(0.8f, 0.1f, 0.02f, 0.6f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = redSpotSystem.emission;
emission.rateOverTime = 200f;
var shape = redSpotSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 0.12f;
shape.radiusThickness = 1f;
shape.position = redSpotDir * (planetRadius * 1.02f);
var vel = redSpotSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(-6f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = redSpotSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.95f, 0.15f, 0.05f), 0f),
new GradientColorKey(new Color(0.8f, 0.1f, 0.02f), 0.4f),
new GradientColorKey(new Color(0.6f, 0.08f, 0.01f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.9f, 0f),
new GradientAlphaKey(0.6f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = redSpotSystem.noise;
noise.enabled = true;
noise.strength = 0.8f;
noise.frequency = 0.3f;
noise.scrollSpeed = 0.2f;
noise.octaveCount = 2;
var renderer = redSpotSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (redSpotMaterial != null)
renderer.material = redSpotMaterial;
else if (stormMaterial != null)
renderer.material = stormMaterial;
redSpotSystem.Play();
GameObject glowObj = new GameObject("RedSpotGlow");
glowObj.transform.parent = null;
glowObj.transform.position = redSpotPos;
redSpotGlow = glowObj.AddComponent<Light>();
redSpotGlow.type = LightType.Point;
redSpotGlow.color = new Color(0.95f, 0.15f, 0.05f);
redSpotGlow.intensity = 5f;
redSpotGlow.range = planetRadius * 6f;
}
void UpdateRedSpot()
{
if (redSpotSystem == null) return;
var redEmission = redSpotSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, troposphereLevel);
redEmission.rateOverTime = Mathf.Lerp(200f, 0f, t);
if (redSpotGlow != null)
redSpotGlow.intensity = Mathf.Lerp(5f, 0f, t);
}
public void CleanUp()
{
foreach (var ps in bandClusters)
if (ps != null) Destroy(ps.gameObject);
bandClusters.Clear();
if (ringSystem != null) Destroy(ringSystem.gameObject);
if (redSpotSystem != null) Destroy(redSpotSystem.gameObject);
if (redSpotGlow != null) Destroy(redSpotGlow.gameObject);
ringSystem = null;
redSpotSystem = null;
redSpotGlow = null;
enabled = false;
}
void UpdateBands()
{
foreach (var ps in bandClusters)
{
if (ps == null) continue;
var emission = ps.emission;
if (troposphereLevel >= 0.7f)
emission.rateOverTime = 0f;
else if (troposphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(0f, 50f, Mathf.InverseLerp(0.7f, 0.5f, troposphereLevel));
else if (troposphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(50f, 150f, Mathf.InverseLerp(0.5f, 0.3f, troposphereLevel));
else
emission.rateOverTime = Mathf.Lerp(150f, 300f, Mathf.InverseLerp(0.3f, 0f, troposphereLevel));
}
}
void Update()
{
if (!Application.isPlaying) return;
if (troposphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = troposphereLevel;
UpdateBands();
UpdateRedSpot();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0797a99a2d7e6f4ea83e61c2b8d7a91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class LayerOrderController : MonoBehaviour
{
public static LayerOrderController Instance;
public TextMeshProUGUI taskDescriptionText;
[Header("Êàðòêè")]
public DraggableCard[] dragCards;
[Header("Ñëîòè")]
public DropZone[] dropZones;
[Header("Êíîïêà ïåðåâ³ðêè")]
public UnityEngine.UI.Button checkButton;
private string[] correctOrder = new string[]
{
"Òðîïîñôåðà",
"Ñòðàòîñôåðà",
"Ìåçîñôåðà",
"Òåðìîñôåðà",
"Åêçîñôåðà"
};
void Awake()
{
Instance = this;
}
public void SetupForPlanet(PlanetDatabase.PlanetInfo planetInfo)
{
if (taskDescriptionText != null)
taskDescriptionText.text = "Ðîçòàøóé øàðè àòìîñôåðè ó ïðàâèëüíîìó ïîðÿäêó â³ä ïîâåðõí³ ïëàíåòè äî êîñìîñó. Øàð 1 º íàéáëèæ÷èì äî ïîâåðõí³.";
if (planetInfo.layers == null) return;
string[] names = new string[planetInfo.layers.Length];
for (int i = 0; i < planetInfo.layers.Length; i++)
names[i] = planetInfo.layers[i].name;
ShuffleArray(names);
for (int i = 0; i < dragCards.Length && i < names.Length; i++)
{
dragCards[i].layerName = names[i];
var text = dragCards[i].GetComponentInChildren<TextMeshProUGUI>();
if (text != null) text.text = names[i];
dragCards[i].gameObject.SetActive(true);
}
foreach (var zone in dropZones)
{
zone.currentCard = null;
zone.ResetColor();
}
correctOrder = new string[planetInfo.layers.Length];
for (int i = 0; i < planetInfo.layers.Length; i++)
correctOrder[i] = planetInfo.layers[i].name;
}
void ShuffleArray(string[] arr)
{
for (int i = arr.Length - 1; i > 0; i--)
{
int j = Random.Range(0, i + 1);
string tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
public void CheckOrder()
{
bool allCorrect = true;
for (int i = 0; i < dropZones.Length; i++)
{
if (dropZones[i].currentCard == null)
{
allCorrect = false;
dropZones[i].SetWrong();
continue;
}
string expected = correctOrder[i];
string actual = dropZones[i].currentCard.layerName;
if (actual == expected)
dropZones[i].SetCorrect();
else
{
dropZones[i].SetWrong();
allCorrect = false;
}
}
if (allCorrect)
GameManager.Instance.OnLayerOrderComplete();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de8e5365838a9b74d83c7c336a018741
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
using UnityEngine;
[ExecuteAlways]
public class MarsAtmosphereSystem : MonoBehaviour
{
public float marsRadiusUnits = 3.3895f;
public float heightMultiplier = 8f;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateLayer("Layer_Troposphere", 200f, new Color(0.9f, 0.5f, 0.2f), new Color(0.7f, 0.3f, 0.1f), 1.5f, 0.4f);
CreateLayer("Layer_Mesosphere", 400f, new Color(0.85f, 0.45f, 0.15f), new Color(0.6f, 0.25f, 0.08f), 1.2f, 0.3f);
CreateLayer("Layer_Thermosphere", 600f, new Color(0.8f, 0.4f, 0.12f), new Color(0.5f, 0.2f, 0.06f), 0.9f, 0.2f);
CreateLayer("Layer_Exosphere", 800f, new Color(0.7f, 0.35f, 0.1f), new Color(0.4f, 0.15f, 0.04f), 0.6f, 0.1f);
}
void CreateLayer(string layerName, float heightKm, Color rimColor, Color coreColor, float rimIntensity, float coreIntensity)
{
float radiusUnits = marsRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.5f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_PulseSpeed", 0.3f);
mat.SetFloat("_PulseStrength", 0.1f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetLayerIntensity(string layerName, float level)
{
Transform layer = transform.Find(layerName);
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
float rimBase = 0f;
float coreBase = 0f;
switch (layerName)
{
case "Layer_Troposphere": rimBase = 1.5f; coreBase = 0.4f; break;
case "Layer_Mesosphere": rimBase = 1.2f; coreBase = 0.3f; break;
case "Layer_Thermosphere": rimBase = 0.9f; coreBase = 0.2f; break;
case "Layer_Exosphere": rimBase = 0.6f; coreBase = 0.1f; break;
}
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, rimBase, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, coreBase, level));
}
public void SetLayerActive(string layerName, bool active)
{
Transform layer = transform.Find(layerName);
if (layer != null) layer.gameObject.SetActive(active);
}
public void SetIntensity(float level)
{
SetLayerIntensity("Layer_Troposphere", level);
SetLayerIntensity("Layer_Mesosphere", level);
SetLayerIntensity("Layer_Thermosphere", level);
SetLayerIntensity("Layer_Exosphere", level);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e0cab0401c7ebb4780830aaf95624f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

129
Assets/Scripts/MarsDeath.cs Normal file
View File

@@ -0,0 +1,129 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarsDeath : MonoBehaviour
{
[Header("Òåêñòóðè")]
public Texture2D mars100;
public Texture2D mars70;
public Texture2D mars50;
public Texture2D mars30;
public Texture2D mars0;
[Header("Òåðìîñôåðà")]
public Texture2D thermo100;
public Texture2D thermo70;
public Texture2D thermo50;
public Texture2D thermo30;
public Texture2D thermo0;
[Header("Ìåðòâà ïëàíåòà")]
public Texture2D deadTexture;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
[Range(0f, 1f)]
public float mesosphereLevel = 1f;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
private Renderer planetRenderer;
private Material mat;
private float prevTropo = -1f;
private float prevMeso = -1f;
private float prevThermo = -1f;
private bool deadApplied = false;
private Texture2D originalTexture;
void Start()
{
planetRenderer = GetComponent<Renderer>();
if (planetRenderer == null)
planetRenderer = GetComponentInChildren<Renderer>();
if (planetRenderer != null)
{
mat = planetRenderer.material;
originalTexture = (Texture2D)mat.GetTexture("_BaseMap");
}
}
public void ResetTexture()
{
troposphereLevel = 1f;
mesosphereLevel = 1f;
thermosphereLevel = 1f;
prevTropo = -1f;
prevMeso = -1f;
prevThermo = -1f;
deadApplied = false;
if (mat != null && originalTexture != null)
mat.SetTexture("_BaseMap", originalTexture);
}
void Update()
{
if (mat == null) return;
if ((mesosphereLevel <= 0f || thermosphereLevel <= 0f) && !deadApplied)
{
deadApplied = true;
if (deadTexture != null)
mat.SetTexture("_BaseMap", deadTexture);
return;
}
if (Mathf.Approximately(troposphereLevel, prevTropo) &&
Mathf.Approximately(mesosphereLevel, prevMeso) &&
Mathf.Approximately(thermosphereLevel, prevThermo)) return;
prevTropo = troposphereLevel;
prevMeso = mesosphereLevel;
prevThermo = thermosphereLevel;
UpdateTexture();
}
void UpdateTexture()
{
if (thermosphereLevel < 1f)
{
SetTexture(GetThermoTexture(thermosphereLevel));
return;
}
if (troposphereLevel < 1f)
{
SetTexture(GetTropoTexture(troposphereLevel));
return;
}
}
void SetTexture(Texture2D tex)
{
if (tex != null)
mat.SetTexture("_BaseMap", tex);
}
Texture2D GetTropoTexture(float level)
{
if (level >= 0.7f) return mars100;
else if (level >= 0.5f) return mars70;
else if (level >= 0.3f) return mars50;
else if (level > 0f) return mars30;
else return mars0;
}
Texture2D GetThermoTexture(float level)
{
if (level >= 0.7f) return thermo100;
else if (level >= 0.5f) return thermo70;
else if (level >= 0.3f) return thermo50;
else if (level > 0f) return thermo30;
else return thermo0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: feac5c98854989540ac85ca7e44c9c8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,262 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarsEffects : MonoBehaviour
{
[Header("Ïèë")]
public Material dustMaterial;
public float planetRadius = 6.779f;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float previousLevel = 1f;
private List<ParticleSystem> dustClusters = new List<ParticleSystem>();
private Light nightLight;
private bool initialized = false;
private const int DUST_COUNT = 20;
void Awake()
{
enabled = false;
}
public void InitState()
{
foreach (var ps in dustClusters)
if (ps != null) Destroy(ps.gameObject);
dustClusters.Clear();
if (nightLight != null)
{
Destroy(nightLight.gameObject);
nightLight = null;
}
troposphereLevel = 1f;
previousLevel = 1f;
initialized = false;
CreateDustSystem();
CreateNightLight();
initialized = true;
}
void CreateDustSystem()
{
for (int i = 0; i < DUST_COUNT; i++)
{
Vector3 dir = Random.onUnitSphere;
Vector3 pos = transform.position + dir * (planetRadius + Random.Range(0.5f, 2f));
GameObject obj = new GameObject("DustCluster_" + i);
obj.transform.parent = null;
obj.transform.position = pos;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 200;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0.5f);
main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.5f, 0.2f, 0.5f),
new Color(0.7f, 0.35f, 0.1f, 0.3f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 20f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = 1.5f;
shape.radiusThickness = 1f;
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.9f, 0.5f, 0.2f), 0f),
new GradientColorKey(new Color(0.7f, 0.35f, 0.1f), 0.5f),
new GradientColorKey(new Color(0.5f, 0.25f, 0.08f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.5f, 0.2f),
new GradientAlphaKey(0.3f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.8f;
noise.frequency = 0.3f;
noise.scrollSpeed = 0.2f;
noise.octaveCount = 2;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (dustMaterial != null)
renderer.material = dustMaterial;
ps.Play();
dustClusters.Add(ps);
StartCoroutine(OrbitDust(obj.transform, dir, planetRadius + Random.Range(0.5f, 2f)));
}
}
void CreateNightLight()
{
GameObject lightObj = new GameObject("MarsNightLight");
lightObj.transform.parent = null;
lightObj.transform.position = transform.position + Vector3.right * (planetRadius * 3f);
nightLight = lightObj.AddComponent<Light>();
nightLight.type = LightType.Spot;
nightLight.color = new Color(0.8f, 0.3f, 0.1f);
nightLight.intensity = 0f;
nightLight.range = planetRadius * 400f;
nightLight.spotAngle = 170f;
nightLight.shadows = LightShadows.None;
StartCoroutine(OrbitLight(lightObj.transform));
}
IEnumerator OrbitDust(Transform dust, Vector3 axis, float radius)
{
Vector3 orbitAxis = Vector3.Cross(axis, Random.onUnitSphere).normalized;
float speed = Random.Range(1f, 4f);
float wobbleSpeed = Random.Range(0.1f, 0.3f);
float wobbleAmount = Random.Range(0.1f, 0.3f);
while (dust != null)
{
dust.RotateAround(transform.position, orbitAxis, speed * Time.deltaTime);
float wobble = Mathf.Sin(Time.time * wobbleSpeed) * wobbleAmount;
dust.position = transform.position +
(dust.position - transform.position).normalized * (radius + wobble);
yield return null;
}
}
void UpdateDust()
{
float level = troposphereLevel;
foreach (var ps in dustClusters)
{
if (ps == null) continue;
var emission = ps.emission;
var main = ps.main;
if (level >= 0.7f)
{
float t = Mathf.InverseLerp(1f, 0.7f, level);
emission.rateOverTime = Mathf.Lerp(20f, 12f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.5f, 0.2f, Mathf.Lerp(0.5f, 0.35f, t)),
new Color(0.7f, 0.35f, 0.1f, Mathf.Lerp(0.3f, 0.2f, t))
);
}
else if (level >= 0.5f)
{
float t = Mathf.InverseLerp(0.7f, 0.5f, level);
emission.rateOverTime = Mathf.Lerp(12f, 5f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.5f, 0.2f, Mathf.Lerp(0.35f, 0.15f, t)),
new Color(0.7f, 0.35f, 0.1f, Mathf.Lerp(0.2f, 0.08f, t))
);
}
else if (level >= 0.3f)
{
float t = Mathf.InverseLerp(0.5f, 0.3f, level);
emission.rateOverTime = Mathf.Lerp(5f, 1f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.5f, 0.2f, Mathf.Lerp(0.15f, 0.03f, t)),
new Color(0.7f, 0.35f, 0.1f, Mathf.Lerp(0.08f, 0.01f, t))
);
}
else
{
emission.rateOverTime = 0f;
}
}
}
void UpdateNightLight()
{
if (nightLight == null) return;
if (troposphereLevel >= 1f)
nightLight.intensity = 0f;
else if (troposphereLevel >= 0.7f)
nightLight.intensity = Mathf.Lerp(200f, 400f, Mathf.InverseLerp(1f, 0.7f, troposphereLevel));
else if (troposphereLevel >= 0.5f)
nightLight.intensity = Mathf.Lerp(400f, 450f, Mathf.InverseLerp(0.7f, 0.5f, troposphereLevel));
else if (troposphereLevel >= 0.3f)
nightLight.intensity = Mathf.Lerp(450f, 500f, Mathf.InverseLerp(0.5f, 0.3f, troposphereLevel));
else
nightLight.intensity = Mathf.Lerp(500f, 600f, Mathf.InverseLerp(0.3f, 0f, troposphereLevel));
}
IEnumerator OrbitLight(Transform lightTransform)
{
float angle = 0f;
float speed = 60f;
while (lightTransform != null && nightLight != null)
{
angle += speed * Time.deltaTime;
float rad = angle * Mathf.Deg2Rad;
lightTransform.position = transform.position +
new Vector3(Mathf.Cos(rad), 0.3f, Mathf.Sin(rad)) * (planetRadius * 3f);
lightTransform.LookAt(transform.position);
nightLight.range = planetRadius * 400f;
nightLight.spotAngle = 170f;
yield return null;
}
}
void Update()
{
if (!Application.isPlaying) return;
if (troposphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = troposphereLevel;
UpdateDust();
UpdateNightLight();
}
public void CleanUp()
{
foreach (var ps in dustClusters)
if (ps != null) Destroy(ps.gameObject);
dustClusters.Clear();
if (nightLight != null)
{
Destroy(nightLight.gameObject);
nightLight = null;
}
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7691094ec3645f7488095e71fe148474
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,211 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarsExosphereEffects : MonoBehaviour
{
public Material ruptureMaterial;
public Material escapeMaterial;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
private float previousLevel = 1f;
private ParticleSystem ruptureSystem;
private ParticleSystem escapeSystem;
private bool deathTriggered = false;
private MarsDeath marsDeath;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (ruptureSystem != null) Destroy(ruptureSystem.gameObject);
if (escapeSystem != null) Destroy(escapeSystem.gameObject);
ruptureSystem = null;
escapeSystem = null;
marsDeath = GetComponentInParent<MarsDeath>();
exosphereLevel = 1f;
previousLevel = 1f;
deathTriggered = false;
CreateSystems();
}
void Update()
{
if (!Application.isPlaying) return;
if (exosphereLevel >= 1f && previousLevel < 1f)
ResetState();
previousLevel = exosphereLevel;
if (exosphereLevel <= 0f && !deathTriggered)
{
deathTriggered = true;
if (marsDeath != null)
marsDeath.mesosphereLevel = 0f;
StartCoroutine(DeathBurst());
return;
}
if (deathTriggered) return;
UpdateRupture();
UpdateEscape();
}
void ResetState()
{
deathTriggered = false;
if (marsDeath != null)
marsDeath.ResetTexture();
if (ruptureSystem != null)
{
var e = ruptureSystem.emission;
e.rateOverTime = 0;
}
if (escapeSystem != null)
{
var e = escapeSystem.emission;
e.rateOverTime = 0;
}
}
void CreateSystems()
{
GameObject r = new GameObject("Rupture");
r.transform.position = transform.position;
ruptureSystem = r.AddComponent<ParticleSystem>();
var mainR = ruptureSystem.main;
mainR.loop = true;
mainR.startLifetime = new ParticleSystem.MinMaxCurve(0.4f, 1.2f);
mainR.startSpeed = new ParticleSystem.MinMaxCurve(6f, 14f);
mainR.startSize = new ParticleSystem.MinMaxCurve(0.05f, 0.2f);
mainR.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.4f, 0.05f, 0.05f),
new Color(0.7f, 0.1f, 0.1f)
);
mainR.simulationSpace = ParticleSystemSimulationSpace.World;
var emissionR = ruptureSystem.emission;
emissionR.rateOverTime = 0;
var shapeR = ruptureSystem.shape;
shapeR.enabled = true;
shapeR.shapeType = ParticleSystemShapeType.Sphere;
shapeR.radius = 3.5f;
shapeR.radiusThickness = 0.05f;
var noiseR = ruptureSystem.noise;
noiseR.enabled = true;
noiseR.strength = 2f;
var velR = ruptureSystem.velocityOverLifetime;
velR.enabled = true;
velR.space = ParticleSystemSimulationSpace.World;
velR.z = new ParticleSystem.MinMaxCurve(10f);
if (ruptureMaterial != null)
ruptureSystem.GetComponent<ParticleSystemRenderer>().material = ruptureMaterial;
ruptureSystem.Play();
GameObject e = new GameObject("Escape");
e.transform.position = transform.position;
escapeSystem = e.AddComponent<ParticleSystem>();
var mainE = escapeSystem.main;
mainE.loop = true;
mainE.startLifetime = new ParticleSystem.MinMaxCurve(2f, 5f);
mainE.startSpeed = new ParticleSystem.MinMaxCurve(15f, 40f);
mainE.startSize = new ParticleSystem.MinMaxCurve(0.03f, 0.15f);
mainE.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.3f, 0.05f, 0.05f),
new Color(0.8f, 0.1f, 0.1f)
);
mainE.simulationSpace = ParticleSystemSimulationSpace.World;
var emissionE = escapeSystem.emission;
emissionE.rateOverTime = 0;
var shapeE = escapeSystem.shape;
shapeE.enabled = true;
shapeE.shapeType = ParticleSystemShapeType.Sphere;
shapeE.radius = 3.6f;
shapeE.radiusThickness = 0.1f;
var velE = escapeSystem.velocityOverLifetime;
velE.enabled = true;
velE.space = ParticleSystemSimulationSpace.World;
velE.z = new ParticleSystem.MinMaxCurve(25f);
if (escapeMaterial != null)
escapeSystem.GetComponent<ParticleSystemRenderer>().material = escapeMaterial;
escapeSystem.Play();
}
void UpdateRupture()
{
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
var e = ruptureSystem.emission;
e.rateOverTime = Mathf.Lerp(0, 2000, t);
if (Random.value < t * 0.5f)
ruptureSystem.Emit(20);
}
void UpdateEscape()
{
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
var e = escapeSystem.emission;
e.rateOverTime = Mathf.Lerp(0, 5000, t);
}
IEnumerator DeathBurst()
{
var e1 = ruptureSystem.emission;
e1.rateOverTime = 7000;
var e2 = escapeSystem.emission;
e2.rateOverTime = 12000;
yield return new WaitForSeconds(0.5f);
var e3 = ruptureSystem.emission;
e3.rateOverTime = 0;
var e4 = escapeSystem.emission;
e4.rateOverTime = 0;
}
public void CleanUp()
{
if (ruptureSystem != null) Destroy(ruptureSystem.gameObject);
if (escapeSystem != null) Destroy(escapeSystem.gameObject);
if (marsDeath != null)
marsDeath.ResetTexture();
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9288a1d63f57da445839df5f5141e7c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,424 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarsMesosphereEffects : MonoBehaviour
{
[Header("Ïèë")]
public Material dustMaterial;
public float planetRadius = 6.779f;
public float mesosphereHeight = 3f;
[Header("Ìåòåîðèòè")]
public GameObject[] asteroidPrefabs;
public GameObject explosionPrefab;
public Material craterMaterial;
public float spawnRadius = 80f;
public float spawnInterval = 3f;
[Range(0f, 1f)]
public float mesosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem dustRingSystem;
private List<GameObject> craters = new List<GameObject>();
private List<ParticleSystem> dustDevils = new List<ParticleSystem>();
private float spawnTimer = 0f;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (dustRingSystem != null) Destroy(dustRingSystem.gameObject);
dustRingSystem = null;
foreach (var c in craters)
if (c != null) Destroy(c);
craters.Clear();
foreach (var d in dustDevils)
if (d != null) Destroy(d.gameObject);
dustDevils.Clear();
mesosphereLevel = 1f;
previousLevel = 1f;
spawnTimer = 0f;
CreateDustRing();
CreateDustDevils();
}
void CreateDustRing()
{
GameObject obj = new GameObject("MarsDustRing");
obj.transform.parent = null;
obj.transform.position = transform.position;
dustRingSystem = obj.AddComponent<ParticleSystem>();
var main = dustRingSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 8000;
main.startLifetime = new ParticleSystem.MinMaxCurve(8f, 16f);
main.startSpeed = new ParticleSystem.MinMaxCurve(1.5f, 4.0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.08f, 0.35f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.45f, 0.15f, 0.5f),
new Color(0.65f, 0.3f, 0.08f, 0.3f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = dustRingSystem.emission;
emission.rateOverTime = 300f;
var shape = dustRingSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius + mesosphereHeight;
shape.radiusThickness = 0.4f;
var vel = dustRingSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.x = new ParticleSystem.MinMaxCurve(-0.5f, 0.5f);
vel.y = new ParticleSystem.MinMaxCurve(-0.3f, 0.3f);
vel.z = new ParticleSystem.MinMaxCurve(-0.5f, 0.5f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f, 0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(1.5f, 2.5f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f, 0f);
var sizeOverLifetime = dustRingSystem.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve sizeCurve = new AnimationCurve(
new Keyframe(0f, 0f),
new Keyframe(0.1f, 1f),
new Keyframe(0.8f, 0.8f),
new Keyframe(1f, 0f)
);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, sizeCurve);
var colorOverLifetime = dustRingSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.85f, 0.45f, 0.15f), 0f),
new GradientColorKey(new Color(0.65f, 0.3f, 0.08f), 0.5f),
new GradientColorKey(new Color(0.45f, 0.2f, 0.05f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.5f, 0.15f),
new GradientAlphaKey(0.3f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = dustRingSystem.noise;
noise.enabled = true;
noise.strength = 0.8f;
noise.frequency = 0.4f;
noise.scrollSpeed = 0.2f;
noise.octaveCount = 2;
var renderer = dustRingSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (dustMaterial != null)
renderer.material = dustMaterial;
dustRingSystem.Play();
}
void CreateDustDevils()
{
int count = 7;
for (int i = 0; i < count; i++)
{
Vector3 dir = Random.onUnitSphere;
Vector3 pos = transform.position + dir * planetRadius;
GameObject obj = new GameObject("DustDevil_" + i);
obj.transform.parent = null;
obj.transform.position = pos;
obj.transform.up = dir;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 500;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f, 6f);
main.startSpeed = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startSize = new ParticleSystem.MinMaxCurve(0.12f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.5f, 0.2f, 0.6f),
new Color(0.7f, 0.35f, 0.1f, 0.4f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 80f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Cone;
shape.angle = 25f;
shape.radius = 0.6f;
shape.radiusThickness = 0.5f;
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.Local;
vel.x = new ParticleSystem.MinMaxCurve(-1.0f, 1.0f);
vel.y = new ParticleSystem.MinMaxCurve(2.0f, 5.0f);
vel.z = new ParticleSystem.MinMaxCurve(-1.0f, 1.0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f, 0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(8f, 12f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f, 0f);
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve sizeCurve = new AnimationCurve(
new Keyframe(0f, 0.2f),
new Keyframe(0.3f, 1f),
new Keyframe(1f, 0f)
);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, sizeCurve);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.9f, 0.5f, 0.2f), 0f),
new GradientColorKey(new Color(0.7f, 0.35f, 0.1f), 0.5f),
new GradientColorKey(new Color(0.5f, 0.25f, 0.08f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.6f, 0f),
new GradientAlphaKey(0.4f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.7f;
noise.frequency = 1.2f;
noise.scrollSpeed = 0.6f;
noise.octaveCount = 2;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 4f;
if (dustMaterial != null)
renderer.material = dustMaterial;
ps.Play();
dustDevils.Add(ps);
StartCoroutine(RotateDustDevil(obj.transform, dir));
}
}
IEnumerator RotateDustDevil(Transform devil, Vector3 surfaceNormal)
{
float orbitSpeed = Random.Range(3f, 8f);
Vector3 orbitAxis = surfaceNormal;
while (devil != null)
{
devil.RotateAround(transform.position, orbitAxis, orbitSpeed * Time.deltaTime);
yield return null;
}
}
void UpdateDustRing()
{
if (dustRingSystem == null) return;
var emission = dustRingSystem.emission;
var main = dustRingSystem.main;
if (mesosphereLevel >= 0.7f)
{
float t = Mathf.InverseLerp(1f, 0.7f, mesosphereLevel);
emission.rateOverTime = Mathf.Lerp(300f, 120f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.45f, 0.15f, Mathf.Lerp(0.5f, 0.35f, t)),
new Color(0.65f, 0.3f, 0.08f, Mathf.Lerp(0.3f, 0.2f, t))
);
}
else if (mesosphereLevel >= 0.5f)
{
float t = Mathf.InverseLerp(0.7f, 0.5f, mesosphereLevel);
emission.rateOverTime = Mathf.Lerp(120f, 50f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.45f, 0.15f, Mathf.Lerp(0.35f, 0.15f, t)),
new Color(0.65f, 0.3f, 0.08f, Mathf.Lerp(0.2f, 0.08f, t))
);
}
else if (mesosphereLevel >= 0.3f)
{
float t = Mathf.InverseLerp(0.5f, 0.3f, mesosphereLevel);
emission.rateOverTime = Mathf.Lerp(50f, 5f, t);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.45f, 0.15f, Mathf.Lerp(0.15f, 0.03f, t)),
new Color(0.65f, 0.3f, 0.08f, Mathf.Lerp(0.08f, 0.01f, t))
);
}
else
{
emission.rateOverTime = 0f;
}
}
void UpdateDustDevils()
{
foreach (var ps in dustDevils)
{
if (ps == null) continue;
var emission = ps.emission;
emission.rateOverTime = mesosphereLevel >= 0.3f ?
Mathf.Lerp(0f, 80f, mesosphereLevel) : 0f;
}
}
void UpdateAsteroids()
{
if (mesosphereLevel >= 1f) return;
if (mesosphereLevel <= 0f) return;
spawnTimer += Time.deltaTime;
float adjustedInterval;
if (mesosphereLevel >= 0.7f)
adjustedInterval = spawnInterval;
else if (mesosphereLevel >= 0.5f)
adjustedInterval = spawnInterval * 0.6f;
else if (mesosphereLevel >= 0.3f)
adjustedInterval = spawnInterval * 0.3f;
else
adjustedInterval = 0.5f;
if (spawnTimer >= adjustedInterval)
{
spawnTimer = 0f;
SpawnAsteroid();
}
}
void SpawnAsteroid()
{
if (asteroidPrefabs == null || asteroidPrefabs.Length == 0) return;
Vector3 direction = Random.onUnitSphere;
Vector3 spawnPos = transform.position + direction * spawnRadius;
Vector3 flyDir = -direction;
GameObject prefab = asteroidPrefabs[Random.Range(0, asteroidPrefabs.Length)];
GameObject asteroid = Instantiate(prefab, spawnPos, Random.rotation);
asteroid.transform.localScale = Vector3.one * Random.Range(0.2f, 0.6f);
StartCoroutine(MoveAsteroid(asteroid, flyDir));
}
IEnumerator MoveAsteroid(GameObject asteroid, Vector3 flyDir)
{
float speed = Random.Range(4f, 8f);
while (asteroid != null)
{
asteroid.transform.position += flyDir * speed * Time.deltaTime;
asteroid.transform.Rotate(Vector3.one * 60f * Time.deltaTime);
float distFromCenter = Vector3.Distance(asteroid.transform.position, transform.position);
if (distFromCenter <= planetRadius + 0.2f)
{
Vector3 hitPos = transform.position + (-flyDir) * planetRadius;
if (explosionPrefab != null)
{
GameObject exp = Instantiate(explosionPrefab, hitPos, Quaternion.identity);
exp.transform.localScale = Vector3.one * Random.Range(0.2f, 0.5f);
Destroy(exp, 3f);
}
SpawnCrater(hitPos, -flyDir);
Destroy(asteroid);
yield break;
}
if (distFromCenter > spawnRadius * 2f)
{
Destroy(asteroid);
yield break;
}
yield return null;
}
}
void SpawnCrater(Vector3 pos, Vector3 flyDir)
{
if (craterMaterial == null) return;
Vector3 center = transform.position;
Vector3 dirFromCenter = (pos - center).normalized;
Vector3 surfacePos = center + dirFromCenter * (planetRadius + 0.02f);
GameObject crater = GameObject.CreatePrimitive(PrimitiveType.Quad);
crater.name = "Crater";
crater.transform.position = surfacePos;
crater.transform.rotation = Quaternion.LookRotation(-dirFromCenter, Vector3.up);
float size = Random.Range(0.3f, 0.8f);
crater.transform.localScale = new Vector3(size, size, size);
Destroy(crater.GetComponent<Collider>());
Renderer r = crater.GetComponent<Renderer>();
r.material = craterMaterial;
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
craters.Add(crater);
}
void Update()
{
if (!Application.isPlaying) return;
if (mesosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = mesosphereLevel;
UpdateDustRing();
UpdateDustDevils();
UpdateAsteroids();
}
public void CleanUp()
{
if (dustRingSystem != null) Destroy(dustRingSystem.gameObject);
dustRingSystem = null;
foreach (var c in craters)
if (c != null) Destroy(c);
craters.Clear();
foreach (var d in dustDevils)
if (d != null) Destroy(d.gameObject);
dustDevils.Clear();
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e95faa80855bb34595aafa0126fa30c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,451 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarsThermosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material tailMaterial;
public Material solarWindMaterial;
public Material auroraMaterial;
public float planetRadius = 3.39f;
public Transform sunTransform;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem tailSystem;
private ParticleSystem solarWindSystem;
private ParticleSystem auroraSystem;
private GameObject auroraGlow;
private bool deathTriggered = false;
void Update()
{
if (!Application.isPlaying) return;
if (thermosphereLevel >= 1f && previousLevel < 1f)
{
InitState();
deathTriggered = false;
}
previousLevel = thermosphereLevel;
if (thermosphereLevel <= 0f && !deathTriggered)
{
deathTriggered = true;
StartCoroutine(DeathBurst());
return;
}
if (deathTriggered) return;
UpdateTail();
UpdateSolarWind();
UpdateAurora();
}
IEnumerator DeathBurst()
{
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 2000f;
var m = tailSystem.main;
m.startSpeed = new ParticleSystem.MinMaxCurve(20f, 50f);
}
if (solarWindSystem != null)
{
var e = solarWindSystem.emission;
e.rateOverTime = 3000f;
}
if (auroraSystem != null)
{
var e = auroraSystem.emission;
e.rateOverTime = 500f;
}
yield return new WaitForSeconds(2f);
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 0f;
}
if (solarWindSystem != null)
{
var e = solarWindSystem.emission;
e.rateOverTime = 0f;
}
if (auroraSystem != null)
{
var e = auroraSystem.emission;
e.rateOverTime = 0f;
}
}
void Awake()
{
enabled = false;
}
public void InitState()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (solarWindSystem != null) Destroy(solarWindSystem.gameObject);
if (auroraSystem != null) Destroy(auroraSystem.gameObject);
if (auroraGlow != null) Destroy(auroraGlow);
tailSystem = null;
solarWindSystem = null;
auroraSystem = null;
auroraGlow = null;
thermosphereLevel = 1f;
previousLevel = 1f;
CreateAtmosphericTail();
CreateSolarWind();
CreateAurora();
var e1 = tailSystem.emission;
e1.rateOverTime = 0f;
var e2 = solarWindSystem.emission;
e2.rateOverTime = 0f;
var e3 = auroraSystem.emission;
e3.rateOverTime = 0f;
}
Vector3 GetSunDirection()
{
if (sunTransform != null)
return (transform.position - sunTransform.position).normalized;
Light[] lights = FindObjectsOfType<Light>();
foreach (var l in lights)
if (l.type == LightType.Directional)
return -l.transform.forward;
return Vector3.right;
}
void CreateAtmosphericTail()
{
Vector3 sunDir = GetSunDirection();
Vector3 tailDir = sunDir;
GameObject obj = new GameObject("MarsTail");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.LookRotation(tailDir);
tailSystem = obj.AddComponent<ParticleSystem>();
var main = tailSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 8000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 10f);
main.startSpeed = new ParticleSystem.MinMaxCurve(3f, 8f);
main.startSize = new ParticleSystem.MinMaxCurve(0.05f, 0.2f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.6f, 0.8f, 1f, 0.4f),
new Color(0.4f, 0.6f, 1f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = tailSystem.emission;
emission.rateOverTime = 0f;
var shape = tailSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 0.8f;
shape.radiusThickness = 1f;
var velocityOverLifetime = tailSystem.velocityOverLifetime;
velocityOverLifetime.enabled = true;
velocityOverLifetime.space = ParticleSystemSimulationSpace.World;
velocityOverLifetime.x = new ParticleSystem.MinMaxCurve(tailDir.x * 8f);
velocityOverLifetime.y = new ParticleSystem.MinMaxCurve(tailDir.y * 8f);
velocityOverLifetime.z = new ParticleSystem.MinMaxCurve(tailDir.z * 8f);
var noise = tailSystem.noise;
noise.enabled = true;
noise.strength = 0.3f;
noise.frequency = 0.5f;
noise.scrollSpeed = 0.3f;
var colorOverLifetime = tailSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.6f, 0.8f, 1f), 0f),
new GradientColorKey(new Color(0.4f, 0.6f, 1f), 0.5f),
new GradientColorKey(new Color(0.2f, 0.3f, 0.8f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.4f, 0f),
new GradientAlphaKey(0.2f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = tailSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Stretch;
renderer.velocityScale = 0.3f;
renderer.lengthScale = 3f;
renderer.sortingFudge = 3f;
if (tailMaterial != null)
renderer.material = tailMaterial;
tailSystem.Play();
}
void CreateSolarWind()
{
GameObject obj = new GameObject("MarsSolarWind");
obj.transform.parent = null;
obj.transform.position = transform.position;
solarWindSystem = obj.AddComponent<ParticleSystem>();
var main = solarWindSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 30000;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f, 5f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.15f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.7f, 0.1f, 1f),
new Color(1f, 0.5f, 0.0f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = solarWindSystem.emission;
emission.rateOverTime = 800f;
var shape = solarWindSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 6.5f;
shape.radiusThickness = 0.3f;
var velocityOverLifetime = solarWindSystem.velocityOverLifetime;
velocityOverLifetime.enabled = true;
velocityOverLifetime.space = ParticleSystemSimulationSpace.World;
velocityOverLifetime.orbitalX = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.orbitalY = new ParticleSystem.MinMaxCurve(12f);
velocityOverLifetime.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.x = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.y = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = solarWindSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.9f, 0.5f), 0f),
new GradientColorKey(new Color(1f, 0.7f, 0.3f), 0.5f),
new GradientColorKey(new Color(0.8f, 0.5f, 0.2f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.8f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = solarWindSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (solarWindMaterial != null)
renderer.material = solarWindMaterial;
solarWindSystem.Play();
}
void CreateAurora()
{
Vector3 auroraDir = new Vector3(0.5f, -0.8f, 0.3f).normalized;
Vector3 auroraPos = transform.position + auroraDir * (planetRadius * 1.05f);
GameObject obj = new GameObject("MarsAurora");
obj.transform.parent = null;
obj.transform.position = auroraPos;
obj.transform.up = auroraDir;
auroraSystem = obj.AddComponent<ParticleSystem>();
var main = auroraSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 1000;
main.startLifetime = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0.5f, 2f);
main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.1f, 1f, 0.5f, 0.8f),
new Color(0.0f, 0.8f, 1f, 0.5f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = auroraSystem.emission;
emission.rateOverTime = 60f;
var shape = auroraSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Circle;
shape.radius = planetRadius * 0.3f;
shape.radiusThickness = 0.5f;
var velocityOverLifetime = auroraSystem.velocityOverLifetime;
velocityOverLifetime.enabled = true;
velocityOverLifetime.space = ParticleSystemSimulationSpace.Local;
velocityOverLifetime.x = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.y = new ParticleSystem.MinMaxCurve(2f);
velocityOverLifetime.z = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.orbitalX = new ParticleSystem.MinMaxCurve(0f);
velocityOverLifetime.orbitalY = new ParticleSystem.MinMaxCurve(4f);
velocityOverLifetime.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = auroraSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.1f, 1f, 0.5f), 0f),
new GradientColorKey(new Color(0.0f, 0.8f, 1f), 0.5f),
new GradientColorKey(new Color(0.2f, 0.4f, 1f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.8f, 0f),
new GradientAlphaKey(0.4f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = auroraSystem.noise;
noise.enabled = true;
noise.strength = 0.4f;
noise.frequency = 0.8f;
noise.scrollSpeed = 0.5f;
var renderer = auroraSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (auroraMaterial != null)
renderer.material = auroraMaterial;
auroraSystem.Play();
auroraGlow = new GameObject("AuroraGlow");
auroraGlow.transform.parent = null;
auroraGlow.transform.position = auroraPos;
Light glow = auroraGlow.AddComponent<Light>();
glow.type = LightType.Point;
glow.color = new Color(0.1f, 1f, 0.5f);
glow.intensity = 0f;
glow.range = planetRadius * 2f;
}
void UpdateTail()
{
if (tailSystem == null) return;
var emission = tailSystem.emission;
if (thermosphereLevel >= 1f)
{
emission.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
emission.rateOverTime = Mathf.Lerp(0f, 500f, t);
var main = tailSystem.main;
main.startSpeed = new ParticleSystem.MinMaxCurve(
Mathf.Lerp(3f, 15f, t),
Mathf.Lerp(8f, 30f, t)
);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.6f, 0.8f, 1f, Mathf.Lerp(0.1f, 0.6f, t)),
new Color(0.4f, 0.6f, 1f, Mathf.Lerp(0.05f, 0.3f, t))
);
}
void UpdateSolarWind()
{
if (solarWindSystem == null) return;
var emission = solarWindSystem.emission;
if (thermosphereLevel >= 1f)
{
emission.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
emission.rateOverTime = Mathf.Lerp(0f, 800f, t);
var main = solarWindSystem.main;
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.7f, 0.1f, Mathf.Lerp(0.3f, 1f, t)),
new Color(1f, 0.5f, 0.0f, Mathf.Lerp(0.2f, 0.8f, t))
);
}
void UpdateAurora()
{
if (auroraSystem == null) return;
var emission = auroraSystem.emission;
if (thermosphereLevel >= 0.7f)
{
emission.rateOverTime = Mathf.Lerp(0f, 20f, Mathf.InverseLerp(1f, 0.7f, thermosphereLevel));
}
else if (thermosphereLevel >= 0.3f)
{
emission.rateOverTime = Mathf.Lerp(20f, 60f, Mathf.InverseLerp(0.7f, 0.3f, thermosphereLevel));
}
else
{
emission.rateOverTime = 0f;
if (auroraGlow != null)
auroraGlow.GetComponent<Light>().intensity = 0f;
return;
}
if (auroraGlow != null)
auroraGlow.GetComponent<Light>().intensity =
Mathf.Lerp(0f, 0.5f, Mathf.InverseLerp(1f, 0.3f, thermosphereLevel));
}
public void CleanUp()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (solarWindSystem != null) Destroy(solarWindSystem.gameObject);
if (auroraSystem != null) Destroy(auroraSystem.gameObject);
if (auroraGlow != null) Destroy(auroraGlow);
tailSystem = null;
solarWindSystem = null;
auroraSystem = null;
auroraGlow = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1eece922649f63043865c87eed1a14f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
using UnityEngine;
[ExecuteAlways]
public class MercuryAtmosphereSystem : MonoBehaviour
{
public float mercuryRadiusUnits = 2.4395f;
public float heightMultiplier = 8f;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateLayer();
}
void CreateLayer()
{
float radiusUnits = mercuryRadiusUnits + (2000f / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = "Layer_Exosphere";
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", new Color(1f, 0.75f, 0.2f));
mat.SetColor("_CoreColor", new Color(0.8f, 0.4f, 0.0f));
mat.SetFloat("_RimPower", 1.8f);
mat.SetFloat("_RimIntensity", 4f);
mat.SetFloat("_CoreIntensity", 0.8f);
mat.SetFloat("_PulseSpeed", 0.5f);
mat.SetFloat("_PulseStrength", 0.3f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetIntensity(float level)
{
Transform layer = transform.Find("Layer_Exosphere");
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, 4f, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, 0.8f, level));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f924bb7f1c168454694495d3d94adf09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MercuryDeath : MonoBehaviour
{
[Header("Òåêñòóðè")]
public Texture2D mercury100;
public Texture2D mercury70;
public Texture2D mercury50;
public Texture2D mercury30;
public Texture2D mercury0;
[Header("Ìåðòâà ïëàíåòà")]
public Texture2D deadTexture;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
private Renderer planetRenderer;
private Material mat;
private float prevLevel = -1f;
void Start()
{
planetRenderer = GetComponent<Renderer>();
if (planetRenderer == null)
planetRenderer = GetComponentInChildren<Renderer>();
if (planetRenderer != null)
mat = planetRenderer.material;
}
public void ResetTexture()
{
exosphereLevel = 1f;
prevLevel = -1f;
if (mat != null && mercury100 != null)
mat.SetTexture("_BaseMap", mercury100);
}
void Update()
{
if (mat == null) return;
if (Mathf.Approximately(exosphereLevel, prevLevel)) return;
prevLevel = exosphereLevel;
UpdateTexture();
}
void UpdateTexture()
{
Texture2D tex = exosphereLevel <= 0f ? deadTexture : GetTexture(exosphereLevel);
if (tex != null)
mat.SetTexture("_BaseMap", tex);
}
Texture2D GetTexture(float level)
{
if (level >= 0.7f) return mercury100;
else if (level >= 0.5f) return mercury70;
else if (level >= 0.3f) return mercury50;
else if (level > 0f) return mercury30;
else return mercury0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76d2114b8f8a79047aa651259e045431
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,353 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MercuryEffects : MonoBehaviour
{
[Header("Ìåòåîðèòè")]
public GameObject[] asteroidPrefabs;
public GameObject explosionPrefab;
public Material craterMaterial;
public float spawnRadius = 80f;
public float planetRadius = 4.879f;
public float spawnInterval = 2f;
public Transform mercuryTransform;
[Header("Ñîíÿ÷íèé â³òåð")]
public Transform sunTransform;
public Material solarWindMaterial;
[Header("Íàòð³ºâå ñâ³ò³ííÿ")]
public Material sodiumGlowMaterial;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
private float spawnTimer = 0f;
private List<GameObject> craters = new List<GameObject>();
private ParticleSystem sodiumGlowSystem;
private ParticleSystem solarWindSystem;
public float previousLevel = 1f;
public ParticleSystem SodiumGlowSystem => sodiumGlowSystem;
public ParticleSystem SolarWindSystem => solarWindSystem;
void Awake()
{
enabled = false;
}
public void InitState()
{
foreach (GameObject crater in craters)
if (crater != null) Destroy(crater);
craters.Clear();
if (solarWindSystem != null) Destroy(solarWindSystem.gameObject);
if (sodiumGlowSystem != null) Destroy(sodiumGlowSystem.gameObject);
solarWindSystem = null;
sodiumGlowSystem = null;
exosphereLevel = 1f;
previousLevel = 1f;
spawnTimer = 0f;
CreateSodiumGlow();
CreateSolarWind();
}
void CreateSodiumGlow()
{
GameObject obj = new GameObject("SodiumGlow");
obj.transform.parent = null;
obj.transform.position = this.transform.position;
obj.transform.localScale = Vector3.one * 2f;
sodiumGlowSystem = obj.AddComponent<ParticleSystem>();
var main = sodiumGlowSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 10000;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 10f);
main.startSpeed = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startSize = new ParticleSystem.MinMaxCurve(0.3f, 0.8f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.9f, 0.2f, 0.8f),
new Color(1f, 0.7f, 0.1f, 0.5f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = sodiumGlowSystem.emission;
emission.rateOverTime = 300f;
var shape = sodiumGlowSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.2f;
shape.radiusThickness = 0.2f;
var colorOverLifetime = sodiumGlowSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.9f, 0.2f), 0f),
new GradientColorKey(new Color(1f, 0.7f, 0.1f), 0.5f),
new GradientColorKey(new Color(1f, 0.5f, 0.0f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.8f, 0.2f),
new GradientAlphaKey(0.5f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = sodiumGlowSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (sodiumGlowMaterial != null)
renderer.material = sodiumGlowMaterial;
sodiumGlowSystem.Play();
}
void CreateSolarWind()
{
GameObject obj = new GameObject("SolarWind");
obj.transform.parent = null;
obj.transform.position = this.transform.position;
obj.transform.localScale = Vector3.one * 3f;
solarWindSystem = obj.AddComponent<ParticleSystem>();
var main = solarWindSystem.main;
main.loop = true;
main.playOnAwake = false;
main.maxParticles = 20000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 4f);
main.startSpeed = new ParticleSystem.MinMaxCurve(20f, 40f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.6f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.6f, 0.1f, 1f),
new Color(1f, 0.8f, 0.3f, 0.7f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = solarWindSystem.emission;
emission.rateOverTime = 0f;
var shape = solarWindSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Cone;
shape.angle = 20f;
shape.radius = 15f;
var colorOverLifetime = solarWindSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.8f, 0.3f), 0f),
new GradientColorKey(new Color(1f, 0.4f, 0.1f), 0.5f),
new GradientColorKey(new Color(0.8f, 0.2f, 0.0f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.5f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = solarWindSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (solarWindMaterial != null)
renderer.material = solarWindMaterial;
}
void Update()
{
if (!Application.isPlaying) return;
if (exosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = exosphereLevel;
UpdateMercuryDeath();
UpdateSodiumGlow();
UpdateSolarWind();
UpdateMeteorSpawn();
}
void UpdateMercuryDeath()
{
if (mercuryTransform == null) return;
MercuryDeath md = mercuryTransform.GetComponent<MercuryDeath>();
if (md == null) md = mercuryTransform.GetComponentInChildren<MercuryDeath>();
if (md != null) md.exosphereLevel = exosphereLevel;
}
void UpdateSodiumGlow()
{
if (sodiumGlowSystem == null) return;
var emission = sodiumGlowSystem.emission;
if (exosphereLevel >= 1f)
emission.rateOverTime = 300f;
else if (exosphereLevel >= 0.7f)
{
float t = Mathf.InverseLerp(1f, 0.7f, exosphereLevel);
emission.rateOverTime = Mathf.Lerp(300f, 150f, t);
}
else if (exosphereLevel >= 0.5f)
{
float t = Mathf.InverseLerp(0.7f, 0.5f, exosphereLevel);
emission.rateOverTime = Mathf.Lerp(150f, 50f, t);
}
else if (exosphereLevel >= 0.3f)
{
float t = Mathf.InverseLerp(0.5f, 0.3f, exosphereLevel);
emission.rateOverTime = Mathf.Lerp(50f, 10f, t);
}
else
emission.rateOverTime = 0f;
var main = sodiumGlowSystem.main;
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.9f, 0.2f, exosphereLevel * 0.8f),
new Color(1f, 0.7f, 0.1f, exosphereLevel * 0.5f)
);
}
void UpdateSolarWind()
{
if (solarWindSystem == null) return;
if (sunTransform == null) return;
Vector3 sunDir = (this.transform.position - sunTransform.position).normalized;
solarWindSystem.transform.position = sunTransform.position + sunDir * 50f;
solarWindSystem.transform.rotation = Quaternion.LookRotation(sunDir);
var emission = solarWindSystem.emission;
if (exosphereLevel <= 0.5f)
{
float t = Mathf.InverseLerp(0.5f, 0f, exosphereLevel);
emission.rateOverTime = Mathf.Lerp(0f, 2000f, t);
if (!solarWindSystem.isPlaying)
solarWindSystem.Play();
}
else
emission.rateOverTime = 0f;
}
void UpdateMeteorSpawn()
{
if (exosphereLevel >= 1f) return;
if (exosphereLevel <= 0f) return;
spawnTimer += Time.deltaTime;
float adjustedInterval;
if (exosphereLevel >= 0.7f)
adjustedInterval = spawnInterval;
else if (exosphereLevel >= 0.5f)
adjustedInterval = spawnInterval * 0.6f;
else if (exosphereLevel >= 0.3f)
adjustedInterval = spawnInterval * 0.3f;
else
adjustedInterval = 0.3f;
if (spawnTimer >= adjustedInterval)
{
spawnTimer = 0f;
SpawnAsteroid();
}
}
void SpawnAsteroid()
{
if (asteroidPrefabs == null || asteroidPrefabs.Length == 0) return;
Vector3 direction = Random.onUnitSphere;
Vector3 spawnPos = transform.position + direction * spawnRadius;
Vector3 flyDir = -direction;
GameObject prefab = asteroidPrefabs[Random.Range(0, asteroidPrefabs.Length)];
GameObject asteroid = Instantiate(prefab, spawnPos, Random.rotation);
asteroid.transform.localScale = Vector3.one * Random.Range(0.2f, 0.6f);
StartCoroutine(MoveAsteroid(asteroid, flyDir));
}
IEnumerator MoveAsteroid(GameObject asteroid, Vector3 flyDir)
{
float speed = Random.Range(4f, 8f);
while (asteroid != null)
{
asteroid.transform.position += flyDir * speed * Time.deltaTime;
asteroid.transform.Rotate(Vector3.one * 60f * Time.deltaTime);
float distFromCenter = Vector3.Distance(asteroid.transform.position, transform.position);
if (distFromCenter <= planetRadius + 0.2f)
{
Vector3 hitPos = transform.position + (-flyDir) * planetRadius;
if (explosionPrefab != null)
{
GameObject exp = Instantiate(explosionPrefab, hitPos, Quaternion.identity);
exp.transform.localScale = Vector3.one * Random.Range(0.2f, 0.5f);
Destroy(exp, 3f);
}
SpawnCrater(hitPos, -flyDir);
Destroy(asteroid);
yield break;
}
if (distFromCenter > spawnRadius * 2f)
{
Destroy(asteroid);
yield break;
}
yield return null;
}
}
void SpawnCrater(Vector3 pos, Vector3 flyDir)
{
if (craterMaterial == null) return;
Vector3 center = mercuryTransform != null ? mercuryTransform.position : transform.position;
Vector3 dirFromCenter = (pos - center).normalized;
Vector3 surfacePos = center + dirFromCenter * (planetRadius + 0.02f);
GameObject crater = GameObject.CreatePrimitive(PrimitiveType.Quad);
crater.name = "Crater";
crater.transform.position = surfacePos;
crater.transform.rotation = Quaternion.LookRotation(-dirFromCenter, Vector3.up);
float size = Random.Range(0.3f, 0.8f);
crater.transform.localScale = new Vector3(size, size, size);
Destroy(crater.GetComponent<Collider>());
Renderer r = crater.GetComponent<Renderer>();
r.material = craterMaterial;
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
craters.Add(crater);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d29982437295134a97f47f212e00c26
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,145 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MesosphereEffects : MonoBehaviour
{
[Header("Àñòåðî¿äè")]
public GameObject[] asteroidPrefabs;
public GameObject explosionPrefab;
public GameObject firePrefab;
public Material craterMaterial;
[Header("Íàëàøòóâàííÿ")]
public float planetRadius = 6.371f;
public float spawnRadius = 60f;
public float mesosphereRadius = 10f;
[Range(0f, 1f)]
public float mesosphereLevel = 1f;
[Header("×àñòîòà")]
public float spawnInterval = 3f;
public Transform earthTransform;
private float spawnTimer = 0f;
private List<GameObject> craters = new List<GameObject>();
void Update()
{
if (!Application.isPlaying) return;
spawnTimer += Time.deltaTime;
float adjustedInterval = Mathf.Lerp(0.5f, spawnInterval, mesosphereLevel);
if (spawnTimer >= adjustedInterval)
{
spawnTimer = 0f;
SpawnAsteroid();
}
}
void Awake()
{
enabled = false;
}
void SpawnAsteroid()
{
if (asteroidPrefabs == null || asteroidPrefabs.Length == 0) return;
Vector3 direction = Random.onUnitSphere;
Vector3 spawnPos = transform.position + direction * spawnRadius;
Vector3 flyDir = -direction;
GameObject prefab = asteroidPrefabs[Random.Range(0, asteroidPrefabs.Length)];
GameObject asteroid = Instantiate(prefab, spawnPos, Random.rotation);
asteroid.transform.localScale = Vector3.one * Random.Range(0.3f, 0.8f);
StartCoroutine(MoveAsteroid(asteroid, spawnPos, flyDir));
}
IEnumerator MoveAsteroid(GameObject asteroid, Vector3 from, Vector3 flyDir)
{
float speed = Random.Range(3f, 6f);
bool passedMesosphere = false;
while (asteroid != null)
{
asteroid.transform.position += flyDir * speed * Time.deltaTime;
asteroid.transform.Rotate(Vector3.one * 50f * Time.deltaTime);
float distFromCenter = Vector3.Distance(asteroid.transform.position, transform.position);
if (!passedMesosphere && distFromCenter <= mesosphereRadius)
{
float burnChance = Mathf.Clamp01((mesosphereLevel - 0.3f) / 0.7f);
if (Random.value < burnChance)
{
if (firePrefab != null)
{
GameObject burn = Instantiate(firePrefab, asteroid.transform.position, Quaternion.identity);
burn.transform.localScale = Vector3.one * 0.2f;
Destroy(burn, 3f);
}
Destroy(asteroid);
yield break;
}
passedMesosphere = true;
}
if (distFromCenter <= planetRadius + 0.3f)
{
Vector3 hitPos = transform.position + (-flyDir) * planetRadius;
if (explosionPrefab != null)
{
GameObject exp = Instantiate(explosionPrefab, hitPos, Quaternion.identity);
exp.transform.localScale = Vector3.one * Random.Range(0.3f, 0.6f);
Destroy(exp, 4f);
}
SpawnCrater(hitPos, -flyDir);
Destroy(asteroid);
yield break;
}
if (distFromCenter > spawnRadius * 2f)
{
Destroy(asteroid);
yield break;
}
yield return null;
}
}
void SpawnCrater(Vector3 pos, Vector3 normal)
{
if (craterMaterial == null) return;
Vector3 center = earthTransform != null ? earthTransform.position : transform.position;
Vector3 dirFromCenter = (pos - center).normalized;
Vector3 surfacePos = center + dirFromCenter * planetRadius;
GameObject crater = GameObject.CreatePrimitive(PrimitiveType.Sphere);
crater.name = "Crater";
crater.transform.position = surfacePos;
crater.transform.rotation = Quaternion.FromToRotation(Vector3.up, dirFromCenter);
float size = Random.Range(0.2f, 0.6f);
crater.transform.localScale = new Vector3(size, 0.03f, size);
Destroy(crater.GetComponent<Collider>());
Renderer r = crater.GetComponent<Renderer>();
r.material = craterMaterial;
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
craters.Add(crater);
}
public void SetMesosphereLevel(float level)
{
mesosphereLevel = level;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e618853cf7ab28e4a9d2607f768aa287
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class NeonTextAnimation : MonoBehaviour
{
public TextMeshProUGUI text;
public Color color1 = new Color(0.8f, 0f, 1f);
public Color color2 = new Color(0f, 0.8f, 1f);
public float speed = 1f;
void Update()
{
float t = (Mathf.Sin(Time.time * speed) + 1f) * 0.5f;
text.color = Color.Lerp(color1, color2, t);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b65141584d4b2b2418b4a97b03844109
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,143 @@
using UnityEngine;
[ExecuteAlways]
public class NeptuneAtmosphereSystem : MonoBehaviour
{
public float neptuneRadiusUnits = 7.1492f;
public float heightMultiplier = 8f;
[Header("Òåêñòóðè")]
public Texture2D neptuneTexture1;
public Texture2D neptuneTexture2;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateTextureLayer("Layer_Troposphere", 300f,
new Color(0.15f, 0.35f, 1f),
new Color(0.05f, 0.15f, 0.7f),
2.8f, 0.8f, 0.012f, -0.009f);
CreateSimpleLayer("Layer_Stratosphere", 600f,
new Color(0.6f, 0.4f, 0.9f),
new Color(0.3f, 0.15f, 0.6f),
1.3f, 0.4f);
CreateSimpleLayer("Layer_Thermosphere", 900f,
new Color(0.2f, 0.5f, 1f),
new Color(0.05f, 0.2f, 0.6f),
0.8f, 0.18f);
}
void CreateTextureLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity,
float scrollSpeed1, float scrollSpeed2)
{
float radiusUnits = neptuneRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/JupiterAtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_ScrollSpeed1", scrollSpeed1);
mat.SetFloat("_ScrollSpeed2", scrollSpeed2);
mat.SetFloat("_PulseSpeed", 0.5f);
mat.SetFloat("_PulseStrength", 0.12f);
mat.SetFloat("_TextureBlend", 0.5f);
mat.SetFloat("_TextureInfluence", 0.5f);
if (neptuneTexture1 != null) mat.SetTexture("_MainTex", neptuneTexture1);
if (neptuneTexture2 != null) mat.SetTexture("_SecondTex", neptuneTexture2);
obj.GetComponent<Renderer>().material = mat;
}
void CreateSimpleLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity)
{
float radiusUnits = neptuneRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_PulseSpeed", 0.5f);
mat.SetFloat("_PulseStrength", 0.12f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetLayerIntensity(string layerName, float level)
{
Transform layer = transform.Find(layerName);
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
float rimBase = 0f;
float coreBase = 0f;
switch (layerName)
{
case "Layer_Troposphere": rimBase = 2.8f; coreBase = 0.8f; break;
case "Layer_Stratosphere": rimBase = 1.3f; coreBase = 0.4f; break;
case "Layer_Thermosphere": rimBase = 0.8f; coreBase = 0.18f; break;
}
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, rimBase, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, coreBase, level));
}
public void SetLayerActive(string layerName, bool active)
{
Transform layer = transform.Find(layerName);
if (layer != null) layer.gameObject.SetActive(active);
}
public void SetIntensity(float level)
{
SetLayerIntensity("Layer_Troposphere", level);
SetLayerIntensity("Layer_Stratosphere", level);
SetLayerIntensity("Layer_Thermosphere", level);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44e7934a8ab27d34bbd926adf51f81e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NeptuneDeath : MonoBehaviour
{
[Header("Òåêñòóðè òðîïîñôåðè")]
public Texture2D tropo100;
public Texture2D tropo70;
public Texture2D tropo50;
public Texture2D tropo30;
public Texture2D tropo0;
public Texture2D deadTexture;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float stratosphereLevel = 1f;
public float thermosphereLevel = 1f;
private Renderer _planetRenderer;
private Material _planetMat;
private Texture2D _originalTexture;
void Start()
{
_planetRenderer = GetComponent<Renderer>();
if (_planetRenderer == null)
_planetRenderer = GetComponentInChildren<Renderer>();
if (_planetRenderer != null)
{
_planetMat = _planetRenderer.material;
_originalTexture = (Texture2D)_planetMat.GetTexture("_BaseMap");
}
}
public void ResetTexture()
{
troposphereLevel = 1f;
stratosphereLevel = 1f;
thermosphereLevel = 1f;
if (_planetMat != null && _originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
}
void Update()
{
if (_planetMat == null) return;
UpdatePlanetTexture();
}
void UpdatePlanetTexture()
{
float worst = Mathf.Min(troposphereLevel, stratosphereLevel, thermosphereLevel);
if (worst >= 1f)
{
if (_originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
return;
}
Texture2D tex = worst <= 0f ? deadTexture : GetPlanetTexture(worst);
if (tex != null)
_planetMat.SetTexture("_BaseMap", tex);
}
Texture2D GetPlanetTexture(float level)
{
if (level >= 0.7f) return tropo100;
else if (level >= 0.5f) return tropo70;
else if (level >= 0.3f) return tropo50;
else if (level > 0f) return tropo30;
else return tropo0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de4abd79f67835046b88b6dcbfa2c159
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,202 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NeptuneStratosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material fogMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float stratosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem _fogSystem;
private ParticleSystem _flashSystem;
private Coroutine _flashCoroutine;
void Awake() { enabled = false; }
public void InitState()
{
if (_fogSystem != null) Destroy(_fogSystem.gameObject);
if (_flashSystem != null) Destroy(_flashSystem.gameObject);
if (_flashCoroutine != null) StopCoroutine(_flashCoroutine);
_fogSystem = null;
_flashSystem = null;
stratosphereLevel = 1f;
previousLevel = 1f;
CreateFog();
CreateFlash();
_flashCoroutine = StartCoroutine(SpawnFlashes());
}
void CreateFog()
{
float r = planetRadius * transform.lossyScale.x;
GameObject obj = new GameObject("NeptuneStratoFog");
obj.transform.parent = null;
obj.transform.position = transform.position;
_fogSystem = obj.AddComponent<ParticleSystem>();
var main = _fogSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 6000;
main.startLifetime = new ParticleSystem.MinMaxCurve(8f, 15f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.03f, r * 0.08f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.4f, 0.2f, 0.8f, 0.15f),
new Color(0.3f, 0.1f, 0.6f, 0.08f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = _fogSystem.emission;
emission.rateOverTime = 120f;
var shape = _fogSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 1.1f;
shape.radiusThickness = 0.05f;
var vel = _fogSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0.8f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = _fogSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.4f, 0.2f, 0.8f), 0f),
new GradientColorKey(new Color(0.3f, 0.1f, 0.6f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.15f, 0.2f),
new GradientAlphaKey(0.08f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = _fogSystem.noise;
noise.enabled = true;
noise.strength = 1f;
noise.frequency = 0.12f;
noise.scrollSpeed = 0.08f;
var renderer = _fogSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (fogMaterial != null) renderer.material = fogMaterial;
_fogSystem.Play();
}
void CreateFlash()
{
float r = planetRadius * transform.lossyScale.x;
GameObject obj = new GameObject("NeptuneFlash");
obj.transform.parent = null;
obj.transform.position = transform.position;
_flashSystem = obj.AddComponent<ParticleSystem>();
var main = _flashSystem.main;
main.loop = false;
main.playOnAwake = false;
main.maxParticles = 50;
main.startLifetime = new ParticleSystem.MinMaxCurve(0.1f, 0.3f);
main.startSpeed = new ParticleSystem.MinMaxCurve(r * 0.005f, r * 0.015f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.01f, r * 0.03f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.6f, 0.4f, 1f, 1f),
new Color(0.8f, 0.6f, 1f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
var shape = _flashSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 0.05f;
var renderer = _flashSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 6f;
if (fogMaterial != null) renderer.material = fogMaterial;
}
IEnumerator SpawnFlashes()
{
while (enabled)
{
if (stratosphereLevel < 1f)
{
float interval = Mathf.Lerp(0.3f, 3f, stratosphereLevel);
yield return new WaitForSeconds(interval);
if (_flashSystem != null)
{
float r = planetRadius * transform.lossyScale.x;
_flashSystem.transform.position = transform.position + Random.onUnitSphere * r * 1.08f;
_flashSystem.Play();
GameObject lightObj = new GameObject("NeptuneFlashLight");
lightObj.transform.position = _flashSystem.transform.position;
Light l = lightObj.AddComponent<Light>();
l.type = LightType.Point;
l.color = new Color(0.6f, 0.4f, 1f);
l.intensity = Mathf.Lerp(20f, 120f, 1f - stratosphereLevel);
l.range = r * 2f;
Destroy(lightObj, 0.15f);
}
}
else
{
yield return new WaitForSeconds(0.5f);
}
}
}
void UpdateFog()
{
if (_fogSystem == null) return;
var e = _fogSystem.emission;
if (stratosphereLevel <= 0f) { e.rateOverTime = 0f; return; }
float t = Mathf.InverseLerp(1f, 0f, stratosphereLevel);
e.rateOverTime = Mathf.Lerp(120f, 600f, t);
}
void Update()
{
if (!Application.isPlaying) return;
if (stratosphereLevel >= 1f && previousLevel < 1f) InitState();
previousLevel = stratosphereLevel;
UpdateFog();
}
public void CleanUp()
{
if (_fogSystem != null) Destroy(_fogSystem.gameObject);
if (_flashSystem != null) Destroy(_flashSystem.gameObject);
if (_flashCoroutine != null) StopCoroutine(_flashCoroutine);
_fogSystem = null;
_flashSystem = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 12448a2c926cc8543a47a69e21dd9805
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,264 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NeptuneThermosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material auroraMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem _auroraNorth;
private ParticleSystem _auroraSouth;
private ParticleSystem _ionizationSystem;
private Light _auroraGlowNorth;
private Light _auroraGlowSouth;
void Awake() { enabled = false; }
public void InitState()
{
if (_auroraNorth != null) Destroy(_auroraNorth.gameObject);
if (_auroraSouth != null) Destroy(_auroraSouth.gameObject);
if (_ionizationSystem != null) Destroy(_ionizationSystem.gameObject);
if (_auroraGlowNorth != null) Destroy(_auroraGlowNorth.gameObject);
if (_auroraGlowSouth != null) Destroy(_auroraGlowSouth.gameObject);
_auroraNorth = null;
_auroraSouth = null;
_ionizationSystem = null;
_auroraGlowNorth = null;
_auroraGlowSouth = null;
thermosphereLevel = 1f;
previousLevel = 1f;
CreateAurora();
CreateIonization();
}
void CreateAurora()
{
float r = planetRadius * transform.lossyScale.x;
_auroraNorth = CreateAuroraSystem("NeptuneAuroraNorth", r, Vector3.up);
_auroraSouth = CreateAuroraSystem("NeptuneAuroraSouth", r, Vector3.down);
GameObject glowN = new GameObject("NeptuneAuroraGlowNorth");
glowN.transform.position = transform.position + Vector3.up * r * 1.1f;
_auroraGlowNorth = glowN.AddComponent<Light>();
_auroraGlowNorth.type = LightType.Point;
_auroraGlowNorth.color = new Color(0.2f, 0.5f, 1f);
_auroraGlowNorth.intensity = 80f;
_auroraGlowNorth.range = r * 5f;
GameObject glowS = new GameObject("NeptuneAuroraGlowSouth");
glowS.transform.position = transform.position + Vector3.down * r * 1.1f;
_auroraGlowSouth = glowS.AddComponent<Light>();
_auroraGlowSouth.type = LightType.Point;
_auroraGlowSouth.color = new Color(0.5f, 0.2f, 1f);
_auroraGlowSouth.intensity = 80f;
_auroraGlowSouth.range = r * 5f;
}
ParticleSystem CreateAuroraSystem(string name, float r, Vector3 poleDir)
{
GameObject obj = new GameObject(name);
obj.transform.parent = null;
obj.transform.position = transform.position + poleDir * r * 0.85f;
obj.transform.up = poleDir;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 8000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.02f, r * 0.06f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.1f, 0.4f, 1f, 1f),
new Color(0.5f, 0.2f, 1f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 400f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = r * 0.35f;
shape.donutRadius = r * 0.06f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.Local;
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(r * 0.012f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve sizeCurve = new AnimationCurve(
new Keyframe(0f, 0.2f),
new Keyframe(0.15f, 1f),
new Keyframe(0.7f, 0.8f),
new Keyframe(1f, 0f)
);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, sizeCurve);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.1f, 0.4f, 1f), 0f),
new GradientColorKey(new Color(0.3f, 0.7f, 1f), 0.3f),
new GradientColorKey(new Color(0.6f, 0.2f, 1f), 0.7f),
new GradientColorKey(new Color(0.2f, 0.5f, 1f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(1f, 0.1f),
new GradientAlphaKey(0.8f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 2f;
noise.frequency = 0.25f;
noise.scrollSpeed = 0.4f;
noise.octaveCount = 2;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (auroraMaterial != null) renderer.material = auroraMaterial;
ps.Play();
return ps;
}
void CreateIonization()
{
float r = planetRadius * transform.lossyScale.x;
GameObject obj = new GameObject("NeptuneIonization");
obj.transform.parent = null;
obj.transform.position = transform.position;
_ionizationSystem = obj.AddComponent<ParticleSystem>();
var main = _ionizationSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 6000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 8f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.005f, r * 0.012f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.2f, 0.5f, 1f, 0.8f),
new Color(0.5f, 0.2f, 0.9f, 0.5f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = _ionizationSystem.emission;
emission.rateOverTime = 600f;
var shape = _ionizationSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 1.2f;
shape.radiusThickness = 0.03f;
var vel = _ionizationSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = _ionizationSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.2f, 0.5f, 1f), 0f),
new GradientColorKey(new Color(0.5f, 0.2f, 0.9f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.8f, 0.1f),
new GradientAlphaKey(0.5f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = _ionizationSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (auroraMaterial != null) renderer.material = auroraMaterial;
_ionizationSystem.Play();
}
void UpdateAurora()
{
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
if (_auroraNorth != null) { var e = _auroraNorth.emission; e.rateOverTime = thermosphereLevel <= 0f ? 0f : Mathf.Lerp(400f, 0f, t); }
if (_auroraSouth != null) { var e = _auroraSouth.emission; e.rateOverTime = thermosphereLevel <= 0f ? 0f : Mathf.Lerp(400f, 0f, t); }
if (_auroraGlowNorth != null) _auroraGlowNorth.intensity = thermosphereLevel <= 0f ? 0f : Mathf.Lerp(80f, 0f, t);
if (_auroraGlowSouth != null) _auroraGlowSouth.intensity = thermosphereLevel <= 0f ? 0f : Mathf.Lerp(80f, 0f, t);
}
void UpdateIonization()
{
if (_ionizationSystem == null) return;
var e = _ionizationSystem.emission;
if (thermosphereLevel <= 0f) { e.rateOverTime = 0f; return; }
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
e.rateOverTime = Mathf.Lerp(600f, 3000f, t);
}
void Update()
{
if (!Application.isPlaying) return;
if (thermosphereLevel >= 1f && previousLevel < 1f) InitState();
previousLevel = thermosphereLevel;
UpdateAurora();
UpdateIonization();
}
public void CleanUp()
{
if (_auroraNorth != null) Destroy(_auroraNorth.gameObject);
if (_auroraSouth != null) Destroy(_auroraSouth.gameObject);
if (_ionizationSystem != null) Destroy(_ionizationSystem.gameObject);
if (_auroraGlowNorth != null) Destroy(_auroraGlowNorth.gameObject);
if (_auroraGlowSouth != null) Destroy(_auroraGlowSouth.gameObject);
_auroraNorth = null;
_auroraSouth = null;
_ionizationSystem = null;
_auroraGlowNorth = null;
_auroraGlowSouth = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 716d929a47acbff4bbd116761c6c7a3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,342 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NeptuneTroposphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material stormMaterial;
public Material cloudMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float previousLevel = 1f;
private List<ParticleSystem> _stormClusters = new List<ParticleSystem>();
private ParticleSystem _darkSpotSystem;
private List<ParticleSystem> _cloudClusters = new List<ParticleSystem>();
private Light _stormGlow;
void Awake() { enabled = false; }
public void InitState()
{
foreach (var ps in _stormClusters)
if (ps != null) Destroy(ps.gameObject);
_stormClusters.Clear();
foreach (var ps in _cloudClusters)
if (ps != null) Destroy(ps.gameObject);
_cloudClusters.Clear();
if (_darkSpotSystem != null) Destroy(_darkSpotSystem.gameObject);
if (_stormGlow != null) Destroy(_stormGlow.gameObject);
_darkSpotSystem = null;
_stormGlow = null;
troposphereLevel = 1f;
previousLevel = 1f;
CreateStorms();
CreateDarkSpot();
CreateClouds();
}
void CreateStorms()
{
float r = planetRadius * transform.lossyScale.x;
float[] latitudes = { -45f, -20f, 0f, 20f, 45f };
float[] speeds = { 25f, -30f, 28f, -25f, 22f };
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("NeptuneStorm_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.008f, r * 0.02f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.2f, 0.4f, 0.9f, 0.5f),
new Color(0.1f, 0.2f, 0.7f, 0.3f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 0f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 1.01f;
shape.radiusThickness = 0.01f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(speeds[i]);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.2f, 0.4f, 0.9f), 0f),
new GradientColorKey(new Color(0.1f, 0.2f, 0.7f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.5f, 0.1f),
new GradientAlphaKey(0.3f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 1f;
noise.frequency = 0.2f;
noise.scrollSpeed = 0.1f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (stormMaterial != null) renderer.material = stormMaterial;
ps.Play();
_stormClusters.Add(ps);
}
}
void CreateDarkSpot()
{
float r = planetRadius * transform.lossyScale.x;
GameObject obj = new GameObject("NeptuneDarkSpot");
obj.transform.parent = null;
obj.transform.position = transform.position;
_darkSpotSystem = obj.AddComponent<ParticleSystem>();
var main = _darkSpotSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.02f, r * 0.06f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.05f, 0.05f, 0.3f, 0.9f),
new Color(0.1f, 0.1f, 0.5f, 0.7f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = _darkSpotSystem.emission;
emission.rateOverTime = 200f;
var shape = _darkSpotSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = r * 0.2f;
shape.donutRadius = r * 0.05f;
shape.radiusThickness = 1f;
shape.arc = 360f;
shape.position = new Vector3(0f, r * 0.3f, 0f);
var vel = _darkSpotSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.Local;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(-8f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = _darkSpotSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.05f, 0.05f, 0.3f), 0f),
new GradientColorKey(new Color(0.1f, 0.1f, 0.5f), 0.5f),
new GradientColorKey(new Color(0.05f, 0.05f, 0.2f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.9f, 0f),
new GradientAlphaKey(0.7f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = _darkSpotSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 5f;
if (stormMaterial != null) renderer.material = stormMaterial;
_darkSpotSystem.Play();
GameObject glowObj = new GameObject("NeptuneStormGlow");
glowObj.transform.parent = null;
glowObj.transform.position = transform.position + Vector3.up * r * 0.3f;
_stormGlow = glowObj.AddComponent<Light>();
_stormGlow.type = LightType.Point;
_stormGlow.color = new Color(0.1f, 0.2f, 0.8f);
_stormGlow.intensity = 40f;
_stormGlow.range = r * 3f;
}
void CreateClouds()
{
float r = planetRadius * transform.lossyScale.x;
float[] latitudes = { -30f, 0f, 30f };
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("NeptuneCloud_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 2000;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f, 6f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.015f, r * 0.04f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.9f, 1f, 0.7f),
new Color(0.7f, 0.8f, 0.95f, 0.5f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 40f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 1.02f;
shape.radiusThickness = 0.01f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(i % 2 == 0 ? 20f : -20f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.9f, 0.95f, 1f), 0f),
new GradientColorKey(new Color(0.7f, 0.8f, 0.95f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.7f, 0.2f),
new GradientAlphaKey(0.5f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 4f;
if (cloudMaterial != null) renderer.material = cloudMaterial;
ps.Play();
_cloudClusters.Add(ps);
}
}
void UpdateStorms()
{
foreach (var ps in _stormClusters)
{
if (ps == null) continue;
var e = ps.emission;
if (troposphereLevel <= 0f) { e.rateOverTime = 0f; continue; }
if (troposphereLevel >= 0.7f) e.rateOverTime = 0f;
else if (troposphereLevel >= 0.5f) e.rateOverTime = Mathf.Lerp(0f, 300f, Mathf.InverseLerp(0.7f, 0.5f, troposphereLevel));
else if (troposphereLevel >= 0.3f) e.rateOverTime = Mathf.Lerp(300f, 800f, Mathf.InverseLerp(0.5f, 0.3f, troposphereLevel));
else e.rateOverTime = Mathf.Lerp(800f, 2000f, Mathf.InverseLerp(0.3f, 0f, troposphereLevel));
}
}
void UpdateDarkSpot()
{
if (_darkSpotSystem == null) return;
var e = _darkSpotSystem.emission;
if (troposphereLevel <= 0f) { e.rateOverTime = 0f; if (_stormGlow != null) _stormGlow.intensity = 0f; return; }
float t = Mathf.InverseLerp(1f, 0f, troposphereLevel);
e.rateOverTime = Mathf.Lerp(200f, 0f, t);
if (_stormGlow != null) _stormGlow.intensity = Mathf.Lerp(40f, 0f, t);
}
void UpdateClouds()
{
foreach (var ps in _cloudClusters)
{
if (ps == null) continue;
var e = ps.emission;
if (troposphereLevel <= 0f) { e.rateOverTime = 0f; continue; }
float t = Mathf.InverseLerp(1f, 0f, troposphereLevel);
e.rateOverTime = Mathf.Lerp(40f, 0f, t);
}
}
void Update()
{
if (!Application.isPlaying) return;
if (troposphereLevel >= 1f && previousLevel < 1f) InitState();
previousLevel = troposphereLevel;
UpdateStorms();
UpdateDarkSpot();
UpdateClouds();
}
public void CleanUp()
{
foreach (var ps in _stormClusters)
if (ps != null) Destroy(ps.gameObject);
_stormClusters.Clear();
foreach (var ps in _cloudClusters)
if (ps != null) Destroy(ps.gameObject);
_cloudClusters.Clear();
if (_darkSpotSystem != null) Destroy(_darkSpotSystem.gameObject);
if (_stormGlow != null) Destroy(_stormGlow.gameObject);
_darkSpotSystem = null;
_stormGlow = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6901f18b5cf13a428bcfb35e8267d2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,417 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlanetDatabase : MonoBehaviour
{
public class QuestionItem
{
public string text;
public bool isYesCorrect;
}
public class PlanetInfo
{
public string name;
public string mainInfo;
public bool hasAtmosphere;
public LayerInfo[] layers;
public string questionText;
public bool questionCorrectAnswer;
public QuestionItem[] questions;
public AnswerSelectionController.AnswerQuestion answerQuestion;
}
public class LayerInfo
{
public string name;
public string description;
public string importance;
public string threat;
public string howToProtect;
}
public static Dictionary<string, PlanetInfo> Data = new Dictionary<string, PlanetInfo>
{
{
"Earth", new PlanetInfo
{
name = "Земля",
mainInfo = "Земля є третьою планетою від Сонця і єдиною відомою планетою де існує життя. Діаметр 12 742 км. Вік 4.54 мільярда років. 71% поверхні вкрито водою. Середня температура поверхні +15°C. Земля має магнітне поле яке захищає від сонячного вітру. Один природний супутник Місяць. Атмосфера складається з 78% азоту та 21% кисню і ділиться на 5 шарів.",
hasAtmosphere = true,
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск: 1 атм. Висота: 0-12 км. Тут є весь кисень яким ми дихаємо, всі хмари і дощ. 75% маси атмосфери знаходиться тут. Температура падає на 6.5°C кожен кілометр вгору. Хмари рухаються, йде дощ, туман стелиться після злив.",
importance = "Тиск впав до 0.7 атм, це як на висоті 3000 м. Людина відчуває задишку і слабкість. Серце б'ється швидше. Дощів стає менше і починаються посухи. Хмари рідшають. Водяний цикл порушується.",
threat = "Тиск 0.5 атм, це як на висоті 5500 м. Без кисневої маски людина непритомніє за 10 хвилин. Дощ зупинився. Річки міліють. Ґрунти тріскаються. Врожаї гинуть.",
howToProtect = "Тиск 0.2 атм. Двигуни літаків не працюють. Людина гине за секунди без скафандра. Температура +60°C. Земля перетворюється на безводну пустелю."
},
new LayerInfo
{
name = "Стратосфера",
description = "Тиск: 0.001 атм, це в 1000 разів менше ніж біля поверхні. Висота: 12-50 км. Озоновий шар поглинає 99% ультрафіолету від Сонця. Тут температура зростає з висотою бо озон поглинає сонячну енергію і нагрівається. Літаки летять тут бо немає турбулентності.",
importance = "Тиск 0.001 атм але озон втратив 30%. Ультрафіолет проникає глибше. Ризик раку шкіри зростає. Фітопланктон в океані починає гинути, а він виробляє половину кисню на планеті.",
threat = "Тиск 0.001 атм. Озон знищений наполовину. Ультрафіолет небезпечний навіть за 10 хвилин на сонці. Рослини горять. Фітопланктон гине і кисню стає менше. Пожежі охоплюють ліси.",
howToProtect = "Тиск 0.001 атм. Озоновий шар знищений. Ультрафіолет руйнує ДНК всього живого. Вихід надвір без захисту смертельний. Пожежі на всіх континентах. Без озону неможливе жодне наземне життя."
},
new LayerInfo
{
name = "Мезосфера",
description = "Тиск: 0.00001 атм, це майже вакуум. Висота: 50-85 км. Температура -90°C, це найхолодніше місце на Землі. Щодня тут згорають від 40 до 100 тонн метеоритів. При такому низькому тиску молекули повітря ще достатньо щільні щоб тертя спалювало каміння.",
importance = "Тиск 0.00001 атм. Мезосфера ослабла. Перші метеорити проходять крізь шар. З'являються перші кратери на поверхні. При ударах піднімається пил. Нічні хмари що світяться на висоті 80 км стають частішими.",
threat = "Тиск 0.00001 атм. Захист знищений наполовину. Метеорити постійно б'ють по поверхні. Пил від ударів блокує сонячне світло. Рослини гинуть без фотосинтезу. Температура на поверхні падає.",
howToProtect = "Тиск 0.00001 атм. Мезосфера знищена. Планета під постійним метеоритним бомбардуванням. Пил викликає ядерну зиму, температура -40°C на поверхні. Без сонця гинуть всі рослини і весь харчовий ланцюг."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск: 0.0000001 атм. Висота: 85-600 км. Температура +2500°C але повітря настільки розріджене що ти б не відчув тепла. МКС летить тут на висоті 400 км. Іоносфера відбиває радіохвилі і тому GPS точний до метра і працює мобільний зв'язок.",
importance = "Тиск 0.0000001 атм. Іоносфера ослабла. GPS дає похибку 10 м, це небезпечно для авіації і суден. Полярне сяйво блякне. Супутники поступово знижують орбіту. Мобільний зв'язок стає нестабільним.",
threat = "Тиск 0.0000001 атм. Половина термосфери зруйнована. Супутники падають. GPS не працює. Літаки без навігації втрачають курс. Інтернет і мобільний зв'язок зникли по всьому світу.",
howToProtect = "Тиск 0.0000001 атм. Термосфера знищена. Всі супутники впали. GPS, інтернет і зв'язок зникли. Сонячний вітер без захисту іоносфери б'є напряму в нижні шари і прискорює руйнування всієї атмосфери."
},
new LayerInfo
{
name = "Екзосфера",
description = "Тиск: практично 0 атм. Висота: 600-10000 км. Перехід між атмосферою і космосом. При такому тиску молекули водню і гелію рухаються так швидко що назавжди покидають Землю. GPS супутники летять тут на висоті 20200 км.",
importance = "Тиск наближається до 0 атм. Екзосфера ослабла. Атмосфера починає повільно витікати в космос. GPS супутники деградують і стають неточними.",
threat = "Тиск 0 атм. Половина екзосфери зруйнована. Атмосфера витікає стрімко. Небо темніє. GPS супутники падають. Тиск на поверхні починає падати нижче норми.",
howToProtect = "Тиск 0 атм. Екзосфера знищена. Атмосфера розсіюється в космосі. Тиск на поверхні падає до критичного. Вода випаровується і йде у космос. Земля перетворюється на холодну суху пустелю без повітря і без життя."
}
}
}
},
{
"Mercury", new PlanetInfo
{
name = "Меркурій",
mainInfo = "Меркурій найменша планета Сонячної системи і найближча до Сонця. Діаметр 4879 км. Рік триває 88 земних днів але доба 59 земних днів тому сонячна доба довша за рік. Немає атмосфери лише надтонка екзосфера з атомів водню гелію кисню натрію і калію. Через відсутність атмосфери добовий перепад температур найбільший у Сонячній системі: від +430°C вдень до -180°C вночі. Залізне ядро займає 85% радіусу планети. Поверхня вкрита кратерами.",
hasAtmosphere = true,
questionText = "Через великий атмосферний тиск на Меркурії метеорити згорають ще в небі. Правда чи ні?",
questionCorrectAnswer = false,
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Екзосфера",
description = "Тиск: 0.00000000000001 атм повний вакуум. Екзосфера складається з окремих атомів натрію водню і кисню. Натрій створює слабке жовте світіння навколо планети. Сонячний вітер постійно здуває атоми в космос але поверхня поповнює їх знову. Без скафандра тут неможливо вижити жодну секунду.",
importance = "Тиск 0.00000000000001 атм екзосфера слабшає. Сонячний вітер здуває більше атомів ніж поверхня встигає поповнити. Перші метеорити починають досягати поверхні і залишати кратери. Радіація від Сонця зростає поверхня нагрівається ще сильніше.",
threat = "Тиск майже нуль половина екзосфери знищена. Метеорити постійно б'ють по поверхні. Сонячний вітер б'є напряму в породу і розпилює поверхневі атоми в космос. Температурний контраст між освітленим і темним боком досягає максимуму.",
howToProtect = "Тиск нуль екзосфера майже зникла. Меркурій під постійним метеоритним бомбардуванням. Сонячний вітер розпилює поверхню. Радіація смертельна. Планета перетворюється на голий розпечений камінь у космосі."
}
}
}
},
{ "Venus", new PlanetInfo
{
name = "Венера",
mainInfo = "Венера друга планета від Сонця і найближча до Землі. Діаметр 12104 км. Найгарячіша планета Сонячної системи: температура поверхні +465°C незважаючи на те що Меркурій ближчий до Сонця. Причина некерований парниковий ефект від атмосфери з 96.5% CO2. Тиск на поверхні 92 атмосфери. Планета обертається у зворотному напрямку і дуже повільно доба довша за рік. Суцільний хмарний покрив із сірчаної кислоти повністю приховує поверхню.",
hasAtmosphere = true,
questions = new QuestionItem[]
{
new QuestionItem
{
text = "Тиск на поверхні Венери у 92 рази більший ніж на Землі. Правда чи ні?",
isYesCorrect = true
},
new QuestionItem
{
text = "Температура на Венері вночі значно нижча ніж вдень. Правда чи ні?",
isYesCorrect = false
},
new QuestionItem
{
text = "Атмосфера Венери складається переважно з кисню. Правда чи ні?",
isYesCorrect = false
}
},
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 92 атм як на глибині 900 метрів під водою. CO2 96.5% тримає тепло як ковдра +465°C однаково вдень і вночі, на полюсах і на екваторі. Хмари із сірчаної кислоти на висоті 45-70 км повністю приховують поверхню.",
importance = "Тиск впав до 64 атм. Теплова ковдра слабшає вперше за мільярди років з'являється різниця між днем і ніччю. День +380°C, ніч +150°C. Хмари рідшають.",
threat = "Тиск 46 атм. День +280°C, ніч 0°C. Хмари майже зникли поверхня вперше видна з космосу. Парниковий ефект втрачає силу.",
howToProtect = "Тиск 28 атм. День +180°C, ніч -80°C. Атмосфера розсіюється стрімко. Венера починає нагадувати Марс холодна суха пустеля."
},
new LayerInfo
{
name = "Мезосфера",
description = "Тиск 0.001 атм у мільйон разів менший ніж на поверхні. Висота 65-120 км. Суцільний шар хмар із сірчаної кислоти товщиною 20 км. Відбиває назад у космос 70% сонячного світла саме тому Венера така яскрава на нічному небі. Температура -43°C.",
importance = "Тиск 0.001 атм незмінний але хмарний шар рідшає. Все більше сонячного світла проходить крізь нього і нагріває поверхню. Кислотні дощі слабшають краплі випаровуються ще в повітрі не досягаючи поверхні.",
threat = "Тиск 0.001 атм половина хмарного шару зникла. Планета поглинає на 35% більше сонячної енергії. Температура на поверхні зростає. Кислотні хмари збираються в окремі острови з порожнечею між ними.",
howToProtect = "Тиск 0.001 атм хмари майже зникли. Венера втратила природний сонячний щит. Без хмар планета поглинає майже все сонячне світло. Поверхня розпечена до абсолютного максимуму."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск 0.000000001 атм у мільярд разів менший ніж на поверхні. Висота 120-220 км. Сонячне UV і рентгенівське випромінювання іонізують гази. Венера не має магнітного поля термосфера єдиний бар'єр проти жорсткого випромінювання.",
importance = "Тиск 0.000000001 атм термосфера слабшає. UV проникає глибше в атмосферу. Молекули CO2 починають розщеплюватись під дією випромінювання. Атмосфера повільно змінює склад.",
threat = "Тиск 0.000000001 атм половина термосфери зруйнована. UV б'є напряму в нижні шари. CO2 розщеплюється швидше атмосфера втрачає густину. Сонячний вітер починає здувати верхні шари.",
howToProtect = "Тиск 0.000000001 атм термосфера майже знищена. Жорстке випромінювання руйнує всю атмосферу зсередини. Сонячний вітер здуває молекули напряму. Венера прискорено втрачає атмосферу."
},
new LayerInfo
{
name = "Екзосфера",
description = "Тиск практично нуль. Висота 220+ км. Перехідна зона між атмосферою і космосом. Атоми водню і кисню рухаються так швидко що назавжди покидають планету. Венера щороку втрачає частину атмосфери через цей шар.",
importance = "Екзосфера слабшає. Атмосфера починає витікати в космос швидше. Сонячний вітер зустрічає менше опору і проникає глибше.",
threat = "Половина екзосфери зруйнована. Втрата атмосфери прискорилась у рази. Сонячний вітер б'є напряму в термосферу і прискорює руйнування нижніх шарів.",
howToProtect = "Екзосфера знищена. Сонячний вітер здуває атмосферу без жодного захисту. Венера повторює долю Марса за мільйони років від атмосфери не залишиться нічого."
}
}
}
},
{
"Moon", new PlanetInfo
{
name = "Місяць",
mainInfo = "Місяць єдиний природний супутник Землі.\n\nТиск тут майже відсутній: лише 3*0.000000000000001 атм. Це майже повний вакуум. Без атмосфери людина без скафандра не виживе.\n\nЧерез відсутність атмосфери тут немає звуку, небо навіть удень чорне, а метеорити вільно врізаються в поверхню й залишають кратери.\n\nСаме Місяць викликає припливи й відпливи на Землі та допомагає стабілізувати нахил її осі.",
hasAtmosphere = false
}
},
{
"Mars", new PlanetInfo
{
name = "Марс",
mainInfo = "Марс четверта планета від Сонця. Діаметр 6779 км вдвічі менший за Землю. Рік триває 687 земних днів. Атмосфера складається з 95% CO2 але надзвичайно тонка тиск лише 0.006 атм або 0.6% від земного. Через пил в атмосфері небо Марса рожево-помаранчеве. Середня температура -63°C. На Марсі знаходиться гора Олімп найвища в Сонячній системі висотою 27 км. Марс головний кандидат для пілотованих місій у 2030-х роках.",
hasAtmosphere = true,
answerQuestion = new AnswerSelectionController.AnswerQuestion
{
questionText = "Що є на Землі але немає на Марсі?",
answers = new string[]
{
"Магнітосфера",
"Океани",
"Кисень",
"Озон",
"Гравітація",
"Азот"
},
correctIndices = new int[] { 0, 1, 2, 3 }
},
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 0.006 атм у 170 разів менший ніж на Землі. На Землі тиск 1 атм, на Марсі як на висоті 35 км над Землею. CO2 95%, азот 3%. Через пил в атмосфері небо Марса рожево-помаранчеве а не синє. Температура -63°C середня.",
importance = "Тиск впав до 0.004 атм. Пилових бур стає менше менше пилу тримається в повітрі. Небо темніє. На Землі при такому тиску людина непритомніє за секунди.",
threat = "Тиск 0.003 атм. Температура починає різко коливатись між днем і ніччю вдень +20°C, вночі -120°C. На Землі такого немає бо атмосфера тримає тепло.",
howToProtect = "Тиск 0.001 атм майже вакуум. Пил осів. Небо чорне. Перепад температур +50°C вдень і -140°C вночі."
},
new LayerInfo
{
name = "Мезосфера",
description = "Тиск 0.00001 атм у 100 000 разів менший ніж на поверхні Землі. Висота 50-100 км. На Землі мезосфера спалює від 40 до 100 тонн метеоритів щодня температура -90°C створює достатній опір. На Марсі мезосфера надто тонка метеорити проходять крізь неї без жодного опору. Пилові бурі піднімають частинки до цього шару і вони висять тижнями.",
importance = "Тиск 0.00001 атм мезосфера слабшає. Пил більше не піднімається так високо. На Землі пилові бурі рідкісні і слабкі на Марсі вони покривали всю планету місяцями. Тепер навіть ці слабкі бурі зникають. Перші метеорити починають долітати до поверхні.",
threat = "Тиск 0.00001 атм половина мезосфери зруйнована. На Землі метеорити згорають на Марсі вони б'ють по поверхні постійно. Кратери з'являються один за одним. Пилові вихори зникли. Небо темніє.",
howToProtect = "Тиск 0.00001 атм мезосфера знищена. Марс під постійним метеоритним бомбардуванням як Місяць. На Землі без мезосфери міста були б знищені метеоритами щодня. Поверхня Марса вкрита свіжими кратерами."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск мізерний 0.000000001 атм. Висота 100-200 км. UV і рентгенівське випромінювання іонізують гази. Марс не має глобального магнітного поля тому сонячний вітер б'є напряму в термосферу. Марс втрачає ~100 грамів атмосфери щосекунди саме через це.",
importance = "Термосфера слабшає. Сонячний вітер проникає глибше. Марс прискорює втрату атмосфери. На Землі магнітне поле відхиляє сонячний вітер на Марсі цього захисту немає.",
threat = "Половина термосфери зруйнована. UV б'є напряму в нижні шари. CO2 розщеплюється швидше. Темп втрати атмосфери зростає у рази саме так Марс втратив свою давню товсту атмосферу мільярди років тому.",
howToProtect = "Термосфера знищена. Сонячний вітер здуває залишки атмосфери без жодного захисту. Марс повторює свою давню долю повільне перетворення на мертву пустелю."
},
new LayerInfo
{
name = "Екзосфера",
description = "Тиск практично нуль. Висота 200+ км. Атоми водню і кисню рухаються так швидко що назавжди покидають планету. Саме через екзосферу Марс колись втратив всю свою воду молекули води розщеплювались UV і водень тікав у космос.",
importance = "Екзосфера слабшає. Атмосфера витікає в космос швидше. Сонячний вітер зустрічає менше опору. Втрата атмосфери прискорюється.",
threat = "Половина екзосфери зруйнована. Сонячний вітер б'є напряму в термосферу. Залишки водяної пари швидко тікають у космос. Марс стає все більш схожим на Місяць.",
howToProtect = "Екзосфера знищена. Марс повністю беззахисний перед космосом. Атмосфера розсіюється. Без атмосфери неможливе рідке water Марс перетворюється на холодну суху пустелю назавжди."
}
}
}
},
{
"Sun", new PlanetInfo
{
name = "Сонце",
mainInfo = "Сонце зірка в центрі Сонячної системи.\n\nУ центрі Сонця тиск сягає 250 мільярдів атмосфер. Саме такий неймовірний тиск запускає ядерний синтез.\n\nЗвичної атмосфери, як у планет, Сонце не має. Його зовнішні шари це розжарений газ. Людина не змогла б наблизитися до Сонця: смертельне випромінювання і температура знищили б її миттєво.\n\nСвітло від Сонця доходить до Землі приблизно за 8 хвилин 20 секунд.",
hasAtmosphere = false
}
},
{ "Jupiter", new PlanetInfo
{
name = "Юпітер",
mainInfo = "Юпітер найбільша планета Сонячної системи. Діаметр 142 984 км в 11.2 рази більший за Землю. Маса більша за всі інші планети разом узяті в 2.5 рази. Газовий гігант без твердої поверхні. Велика Червона Пляма антициклон більший за Землю існує понад 350 років. Юпітер має 95 офіційно підтверджених супутників.",
hasAtmosphere = true,
questionText = "Юпітер має тверду поверхню під хмарами. Правда чи ні?",
questionCorrectAnswer = false,
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 1 атм на верхній межі як на поверхні Землі. Водень 89.8%, гелій 10.2%. Температура -110°C. Вітри до 620 км/год в 6 разів швидші за найсильніші урагани Землі. Велика Червона Пляма буря більша за Землю що існує 350+ років.",
importance = "Тиск зростає вдвічі. Аміачні хмари рідшають. Вітри слабшають до 400 км/год. На Землі такі вітри знищили б міста. Велика Червона Пляма зменшується.",
threat = "Тиск 10 атм як на глибині 100 метрів під водою на Землі. Аміачні хмари зникли. Оголюються темніші шари амоній гідросульфіду. Вітри хаотичні немає структури смуг.",
howToProtect = "Тиск 100 атм водень переходить у рідкий стан. На Землі такий тиск існує на глибині 1 км під водою. Смуги зникли повністю. Велика Червона Пляма розпалась. Юпітер втрачає своє обличчя."
},
new LayerInfo
{
name = "Стратосфера",
description = "Тиск 0.1 атм в 10 разів менший ніж на поверхні Землі. Висота 50 км над хмарами. Вуглеводні етан і ацетилен утворюються коли UV руйнує метан. На Землі стратосфера містить озон який захищає від UV на Юпітері озону немає.",
importance = "Тиск 0.01 атм. UV проникає глибше. Хімічні реакції прискорюються. Органічні молекули руйнуються швидше ніж утворюються. Шар стає прозорішим.",
threat = "Тиск 0.001 атм. Стратосфера майже зникла. UV б'є напряму в тропосферу. Аміачні хмари змінюють колір стають темнішими через хімічні реакції.",
howToProtect = "Тиск 0.0001 атм. Стратосфера знищена. Юпітер втратив хімічний буфер між космосом і хмарами. UV руйнує аміак в верхніх хмарах напряму."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск 0.000001 атм мільйон разів менший ніж на Землі. Температура +725°C гаряче як розплавлене залізо. На Землі термосфера нагрівається до 2000°C від UV на Юпітері головне джерело тепла магнітне поле і авроральні явища.",
importance = "Тиск падає. Термосфера слабшає. Полярні сяйва тьмяніють вони в 1000 разів яскравіші за земні. Заряджені частинки з магнітосфери проникають глибше.",
threat = "Половина термосфери зруйнована. Іонізований шар слабшає. Радіаційні пояси Юпітера найнебезпечніші в Сонячній системі починають взаємодіяти з нижніми шарами.",
howToProtect = "Термосфера знищена. Радіація б'є напряму в стратосферу. Полярні сяйва зникли. Юпітер втратив свій іонізований захисний щит."
},
new LayerInfo
{
name = "Екзосфера",
description = "Тиск практично нуль. Висота 5000 км над хмарами. Атоми водню рухаються так швидко що тікають у космос. Юпітер захоплює частинки сонячного вітру в радіаційні пояси вони простягаються на 650 млн км далі ніж орбіта Сатурна.",
importance = "Екзосфера слабшає. Радіаційні пояси отримують менше матеріалу. Сонячний вітер проникає ближче до планети.",
threat = "Половина екзосфери зруйнована. Радіаційні пояси скорочуються. Супутники Юпітера отримують більше радіації. Іо Європа Ганімед всі під загрозою.",
howToProtect = "Екзосфера знищена. Радіаційні пояси розпались. Сонячний вітер досягає термосфери. Юпітер втратив свій зовнішній щит і перестає захищати внутрішні планети від комет і астероїдів."
}
}
}
},
{ "Saturn", new PlanetInfo
{
name = "Сатурн",
mainInfo = "Сатурн шоста планета і другий газовий гігант. Діаметр 120 536 км в 9.4 рази більший за Землю. Щільність 0.687 г/см³ менша за воду. Якби існував океан достатнього розміру Сатурн би плавав. Кільця простягаються на 80 000 км від поверхні але завтовшки лише 10-100 метрів. На північному полюсі існує стабільний шестикутний ураган розміром 25 000 км. Вітри досягають 1800 км/год в 18 разів швидші за найсильніші урагани Землі.",
hasAtmosphere = true,
questions = new QuestionItem[]
{
new QuestionItem { text = "Сатурн потонув би в океані він легший за воду. Правда чи ні?", isYesCorrect = true },
new QuestionItem { text = "Кільця Сатурна зникнуть через ~100 млн років. Правда чи ні?", isYesCorrect = true },
new QuestionItem { text = "Титан єдиний супутник в Сонячній системі з густою атмосферою. Правда чи ні?", isYesCorrect = true }
},
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 1 атм на верхній межі як на поверхні Землі. Водень 96.3%, гелій 3.25%. Температура -178°C на 193°C холодніше ніж на Землі. Вітри до 1800 км/год в 18 разів швидші за найсильніші урагани Землі. На північному полюсі стабільний шестикутний ураган розміром 25 000 км більший за Землю.",
importance = "Тиск зростає вдвічі. Аміачні хмари рідшають. Вітри слабшають до 1200 км/год. Шестикутний ураган деформується його краї розмиваються. На Землі такі вітри знищили б континенти.",
threat = "Тиск 10 атм як на глибині 100 метрів під водою на Землі. Аміачні хмари зникли. Оголюються темніші шари амоній гідросульфіду. Шестикутний ураган розпадається на хаотичні вихори.",
howToProtect = "Тиск 100 атм водень переходить у рідкий стан. На Землі такий тиск існує на глибині 1 км під водою. Смуги зникли повністю. Шестикутний ураган зник. Сатурн втрачає своє унікальне обличчя."
},
new LayerInfo
{
name = "Стратосфера",
description = "Тиск 0.1 атм в 10 разів менший ніж на поверхні Землі. Вуглеводні етан і ацетилен утворюються коли UV руйнує метан. Температура -130°C. На Землі стратосфера містить озон який захищає від UV на Сатурні озону немає. Туман з вуглеводнів огортає планету.",
importance = "Тиск 0.01 атм. UV проникає глибше. Туман рідшає. Хімічні реакції прискорюються вуглеводні руйнуються швидше ніж утворюються. Стратосфера стає прозорішою.",
threat = "Тиск 0.001 атм. Стратосфера майже зникла. UV б'є напряму в тропосферу. Туман зник повністю. Аміачні хмари змінюють колір від хімічних реакцій.",
howToProtect = "Тиск 0.0001 атм. Стратосфера знищена. Сатурн втратив хімічний буфер між космосом і хмарами. UV руйнує аміак в верхніх хмарах напряму."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск 0.000001 атм мільйон разів менший ніж на Землі. Температура +420°C гаряче як розплавлений свинець. Відкриття Cassini 2017 кільця годують термосферу водяним паром і органічними молекулами. Щодня в атмосферу падає від 400 до 4800 кг матеріалу з кілець.",
importance = "Термосфера слабшає. Полярні сяйва тьмяніють вони в 1000 разів яскравіші за земні. Потік матеріалу з кілець зменшується. Іонізований шар стає тоншим.",
threat = "Половина термосфери зруйнована. Кільця перестають живити атмосферу. Радіаційні пояси Сатурна слабшають. Полярні сяйва зникли.",
howToProtect = "Термосфера знищена. Матеріал з кілець більше не надходить. Сатурн втратив унікальний зв'язок між кільцями і атмосферою явище унікальне для Сонячної системи."
},
new LayerInfo
{
name = "Екзосфера",
description = "Тиск практично нуль. Висота 1000 км над хмарами. Частинки кілець взаємодіють з верхньою атмосферою дощ з кілець падає на планету. Кільця зникнуть через ~100 млн років за космічними мірками дуже скоро. Нам пощастило існувати саме зараз коли кільця ще є.",
importance = "Екзосфера слабшає. Дощ з кілець слабшає. Радіаційні пояси скорочуються. Сонячний вітер проникає ближче до планети.",
threat = "Половина екзосфери зруйнована. Кільця прискорено руйнуються матеріал падає в атмосферу. Титан та інші супутники отримують більше радіації.",
howToProtect = "Екзосфера знищена. Кільця розпались. Дощ з кілець зупинився. Сатурн став звичайним газовим гігантом без найкрасивіших кілець в Сонячній системі."
}
}
}
},
{
"Uranus", new PlanetInfo
{
name = "Уран",
mainInfo = "Уран сьома планета і перший крижаний гігант. Діаметр 51 118 км. Унікальний нахил осі 97.77° фактично лежить на боці. Один полюс 42 роки освітлений Сонцем а інший 42 роки в темряві. Метан надає блакитно-зеленого кольору. Температура -224°C найхолодніша атмосфера в Сонячній системі. Має 13 кілець і 28 супутників.",
hasAtmosphere = true,
questionText = "Атмосфера Урана є найхолоднішою в Сонячній системі. Правда чи ні?",
questionCorrectAnswer = true,
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 1 атм на верхній межі як на поверхні Землі. Водень 82.5%, гелій 15.2%, метан 2.3%. Температура -224°C на 239°C холодніше ніж на Землі і на 46°C холодніше ніж на Сатурні. Метанові хмари на висоті 1-2 бари. Вітри до 900 км/год. Через нахил осі 97.77° один полюс отримує сонячне світло 42 роки поспіль але тепліше від цього не стає.",
importance = "Тиск впав до 0.7 атм як на висоті 3000 м над Землею. Метанові хмари рідшають. Вітри слабшають. Температура падає ще нижче бо менше метану утримує тепло. На Землі при такому тиску людина відчуває задишку тут вона загинула б миттєво від холоду.",
threat = "Тиск 0.5 атм як на висоті 5500 м над Землею. Метанові хмари зникають. Блакитно-зелений колір планети блякне без метану Уран ставав би безбарвним. Температура -230°C. Вітри хаотичні без структури смуг.",
howToProtect = "Тиск 0.2 атм майже вакуум. Метан зник разом з ним зник блакитний колір. Температура -240°C. Вітри зупинились. Уран перетворюється на прозору крижану кулю без атмосфери."
},
new LayerInfo
{
name = "Стратосфера",
description = "Тиск 0.1 10⁻¹⁰ бар. Висота 50-4000 км. Температура зростає від -220°C до +800°C з висотою. Ацетилен і етан утворюються коли UV руйнує метан так само як на Землі UV створює озон. Але на Урані немає озонового шару UV проходить крізь нього без затримки. Хмари з ацетиленового диму огортають планету.",
importance = "Тиск падає. Ацетиленовий туман рідшає. UV проникає глибше в тропосферу і прискорює руйнування метану. На Землі без стратосфери і озону UV знищив би все живе тут немає чого знищувати але атмосфера втрачає свою хімію.",
threat = "Половина стратосфери зруйнована. Хімічні реакції зупиняються нема метану нема ацетилену. Стратосфера стає прозорою. UV б'є напряму в тропосферу. Планета втрачає свій характерний хімічний склад.",
howToProtect = "Стратосфера знищена. Уран втратив хімічний буфер між космосом і тропосферою. UV і сонячний вітер б'ють напряму в нижні шари. Без стратосфери тропосфера розсіюється в космос в рази швидше."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск 0.000000001 майже вакуум. Висота 4000-50 000 км. Температура +800°C аномально висока для планети що у 20 разів далі від Сонця ніж Земля. На Землі термосфера нагрівається UV від Сонця на Урані UV занадто слабке. Джерело нагріву досі невідоме відкрита загадка планетології. Сонячний вітер взаємодіє з магнітним полем і створює унікальні полярні сяйва.",
importance = "Термосфера слабшає. Полярні сяйва тьмяніють. Магнітне поле Урана нахилене на 59° від осі тому сонячний вітер вдаряє нерівномірно і одна сторона планети захищена гірше. Іонізований шар стає тоншим.",
threat = "Половина термосфери зруйнована. Сонячний вітер проникає глибше. Без іонізованого захисного шару UV і частинки сонячного вітру досягають стратосфери. Полярні сяйва зникли. Магнітне поле залишилось але захищати нема що.",
howToProtect = "Термосфера знищена. Сонячний вітер б'є напряму в стратосферу і прискорює руйнування всієї атмосфери. Уран втратив останній захисний шар. Без термосфери атмосфера розсіюється в космос повторюючи долю давнього Марса."
}
}
}
},
{
"Neptune", new PlanetInfo
{
name = "Нептун",
mainInfo = "Нептун восьма і найвіддаленіша планета. Відстань від Сонця 4.495 мільярда км. Діаметр 49 528 км. Рік триває 164.8 земних роки. Найсильніші вітри в Сонячній системі до 2100 км/год. Тритон єдиний великий супутник що обертається у зворотному напрямку. Нептун у 1846 році став першою планетою відкритою математичним передбаченням а не випадковим спостереженням.",
hasAtmosphere = true,
questionText = "Тиск на верхній межі атмосфери Нептуна такий самий як на поверхні Землі. Правда чи ні?",
questionCorrectAnswer = true,
layers = new LayerInfo[]
{
new LayerInfo
{
name = "Тропосфера",
description = "Тиск 1 атм на верхній межі як на поверхні Землі. Водень 80%, гелій 19%, метан 1.5%. Температура -218°C на 233°C холодніше ніж на Землі. Вітри до 2100 км/год в 21 раз швидші за найсильніші урагани Землі і найшвидші в Сонячній системі. Великий Темний Пляма ураган розміром з Землю. Унікальність Нептуна внутрішнє тепло в 2.6 рази перевищує енергію від Сонця тому атмосфера така активна незважаючи на величезну відстань.",
importance = "Тиск впав до 0.7 атм як на висоті 3000 м над Землею. Вітри слабшають до 1500 км/год. Метанові хмари рідшають синій колір планети блякне. Великий Темний Пляма зменшується. Внутрішнє тепло починає домінувати над атмосферною динамікою.",
threat = "Тиск 0.5 атм як на висоті 5500 м над Землею. Без кисневої маски людина непритомніє але тут і без того -218°C і немає кисню. Метанові хмари зникають Нептун втрачає синій колір. Вітри хаотичні без структури. Великий Темний Пляма розпадається.",
howToProtect = "Тиск 0.2 атм майже вакуум. Метан зник синій колір зник разом з ним. Вітри зупинились незважаючи на внутрішнє тепло. Температура -240°C. Нептун перетворюється на сіру безбарвну кулю без атмосфери."
},
new LayerInfo
{
name = "Стратосфера",
description = "Тиск 0.1 10⁻¹⁰ бар. Висота 50-4000 км. Температура зростає з висотою. Ацетилен етан і діацетилен утворюються коли UV руйнує метан так само як на Урані. На Землі стратосфера містить озон який поглинає UV на Нептуні озону немає і UV проходить крізь неї без затримки. На відміну від Урана стратосфера Нептуна більш активна через сильніше внутрішнє тепло.",
importance = "Тиск падає. Ацетиленовий туман рідшає. UV проникає глибше. Хімічні реакції уповільнюються нема метану нема ацетилену. На Землі без стратосфери і озону UV знищив би все живе за лічені години.",
threat = "Половина стратосфери зруйнована. Стратосфера стає прозорою. UV б'є напряму в тропосферу і прискорює руйнування метану. Нептун втрачає свій хімічний склад без метану зникає синій колір.",
howToProtect = "Стратосфера знищена. Нептун втратив хімічний буфер між космосом і тропосферою. UV і сонячний вітер б'ють напряму в нижні шари. Тропосфера розсіюється в космос в рази швидше."
},
new LayerInfo
{
name = "Термосфера",
description = "Тиск 0.000000001 майже вакуум. Висота 4000-50 000 км. Температура +750°C аномально висока як і на Урані для такої відстані від Сонця. Магнітне поле Нептуна нахилене на 47° від осі і зміщене на 55% радіуса від центру ще більш асиметричне ніж у Урана. Через це сонячний вітер вдаряє нерівномірно і полярні сяйва з'являються в незвичних місцях.",
importance = "Термосфера слабшає. Полярні сяйва тьмяніють. Асиметричне магнітне поле залишає одну сторону планети майже без захисту. Іонізований шар стає тоншим сонячний вітер проникає глибше.",
threat = "Половина термосфери зруйнована. Сонячний вітер проникає в стратосферу. UV і заряджені частинки прискорюють руйнування метану і вуглеводнів. Тритон найбільший супутник Нептуна отримує більше радіації.",
howToProtect = "Термосфера знищена. Сонячний вітер б'є напряму в стратосферу і прискорює руйнування всієї атмосфери. Нептун без термосфери як Марс без магнітного поля. Атмосфера розсіюється в космос і планета повільно перетворюється на голу крижану кулю."
}
}
}
},
{
"Pluto", new PlanetInfo
{
name = "Плутон",
mainInfo = "Плутон найвідоміша карликова планета в поясі Койпера. Діаметр 2376 км менший за Місяць. Рік триває 248 земних років. Відстань від Сонця коливається від 4.44 до 7.38 мільярда км. Має тонку атмосферу з азоту метану і CO яка частково замерзає коли Плутон відходить далі від Сонця. Серце Плутона рівнина Томба Регіо одна з наймолодших поверхонь у Сонячній системі. Місія New Horizons у липні 2015 року вперше показала Плутон у деталях.",
hasAtmosphere = false
}
}
};
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f805fe585a602744a991aee61c6c058
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,319 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlanetDeath : MonoBehaviour
{
[Header("Òåêñòóðè -- Òðîïîñôåðà")]
public Texture2D tropo100;
public Texture2D tropo70;
public Texture2D tropo50;
public Texture2D tropo30;
public Texture2D tropo0;
[Header("Òåêñòóðè -- Ñòðàòîñôåðà")]
public Texture2D strato100;
public Texture2D strato70;
public Texture2D strato50;
public Texture2D strato30;
public Texture2D strato0;
[Header("Ìåðòâà ïëàíåòà")]
public Texture2D deadPlanetTexture;
[Header("Òåêñòóðè -- Òåðìîñôåðà")]
public Texture2D thermo100;
public Texture2D thermo70;
public Texture2D thermo50;
public Texture2D thermo30;
public Texture2D thermo0;
[Header("гâí³ øàð³â")]
[Range(0f, 1f)] public float troposphereLevel = 1f;
[Range(0f, 1f)] public float stratosphereLevel = 1f;
[Range(0f, 1f)] public float mesosphereLevel = 1f;
[Range(0f, 1f)] public float thermosphereLevel = 1f;
[Range(0f, 1f)] public float exosphereLevel = 1f;
[Header("Çâ'ÿçêè")]
public TroposphereEffects troposphere;
public GameObject troposphereLayerObject;
public GameObject stratosphereLayerObject;
public GameObject mesosphereLayerObject;
public GameObject thermosphereLayerObject;
public GameObject exosphereLayerObject;
[Header("Âèïàðîâóâàííÿ")]
public bool showEvaporation = true;
public Material evaporationMaterial;
private Renderer planetRenderer;
private Material mat;
private ParticleSystem evaporationSystem;
private Texture2D currentBlended;
private float prevTropo = -1f;
private float prevStrato = -1f;
private float prevThermo = -1f;
void Start()
{
planetRenderer = GetComponent<Renderer>();
mat = planetRenderer.material;
currentBlended = new Texture2D(tropo100.width, tropo100.height, TextureFormat.RGB24, false);
if (showEvaporation)
CreateEvaporationEffect();
}
public void ResetTextureCache()
{
prevTropo = -1f;
prevStrato = -1f;
prevThermo = -1f;
}
void Update()
{
if (mat == null) return;
UpdateTexture();
UpdateAtmosphereLayers();
UpdateWeather();
UpdateEvaporation();
StratosphereDeath strato = stratosphereLayerObject?.GetComponent<StratosphereDeath>();
if (strato != null) strato.stratosphereLevel = stratosphereLevel;
MesosphereEffects meso = mesosphereLayerObject?.GetComponent<MesosphereEffects>();
if (meso != null) meso.mesosphereLevel = mesosphereLevel;
ThermosphereEffects thermo = thermosphereLayerObject?.GetComponent<ThermosphereEffects>();
if (thermo != null) thermo.thermosphereLevel = thermosphereLevel;
ExosphereEffects exo = exosphereLayerObject?.GetComponent<ExosphereEffects>();
if (exo != null) exo.exosphereLevel = exosphereLevel;
}
void UpdateTexture()
{
bool isDead = troposphereLevel <= 0f || stratosphereLevel <= 0f || thermosphereLevel <= 0f;
if (isDead)
{
if (deadPlanetTexture != null)
mat.mainTexture = deadPlanetTexture;
UpdateLayerMaterial(troposphereLayerObject, 0f);
UpdateLayerMaterial(stratosphereLayerObject, 0f);
UpdateLayerMaterial(mesosphereLayerObject, 0f);
UpdateLayerMaterial(thermosphereLayerObject, 0f);
UpdateLayerMaterial(exosphereLayerObject, 0f);
return;
}
else
{
troposphereLayerObject?.SetActive(true);
stratosphereLayerObject?.SetActive(true);
mesosphereLayerObject?.SetActive(true);
thermosphereLayerObject?.SetActive(true);
exosphereLayerObject?.SetActive(true);
}
if (Mathf.Approximately(troposphereLevel, prevTropo) &&
Mathf.Approximately(stratosphereLevel, prevStrato) &&
Mathf.Approximately(thermosphereLevel, prevThermo)) return;
prevTropo = troposphereLevel;
prevStrato = stratosphereLevel;
prevThermo = thermosphereLevel;
Texture2D tropoTex = GetLayerTexture(troposphereLevel, tropo100, tropo70, tropo50, tropo30, tropo0);
Texture2D stratoTex = GetLayerTexture(stratosphereLevel, strato100, strato70, strato50, strato30, strato0);
Texture2D thermoTex = GetLayerTexture(thermosphereLevel, thermo100, thermo70, thermo50, thermo30, thermo0);
if (tropoTex == null || stratoTex == null) return;
Color[] tropoPixels = tropoTex.GetPixels();
Color[] stratoPixels = stratoTex.GetPixels();
Color[] thermoPixels = thermoTex != null ? thermoTex.GetPixels() : null;
Color[] basePixels = tropo100.GetPixels();
Color[] output = new Color[tropoPixels.Length];
for (int i = 0; i < output.Length; i++)
{
Color col = basePixels[i];
if (troposphereLevel < 1f)
col = Color.Lerp(col, tropoPixels[i], 1f - troposphereLevel);
if (stratosphereLevel < 1f)
col = Color.Lerp(col, stratoPixels[i], 1f - stratosphereLevel);
if (thermosphereLevel < 1f && thermoPixels != null)
col = Color.Lerp(col, thermoPixels[i], 1f - thermosphereLevel);
output[i] = col;
}
currentBlended.SetPixels(output);
currentBlended.Apply();
mat.mainTexture = currentBlended;
}
Texture2D GetLayerTexture(float level, Texture2D t100, Texture2D t70, Texture2D t50, Texture2D t30, Texture2D t0)
{
if (level >= 0.85f) return Blend(t100, t70, Mathf.InverseLerp(1.0f, 0.85f, level));
else if (level >= 0.6f) return Blend(t70, t50, Mathf.InverseLerp(0.85f, 0.6f, level));
else if (level >= 0.4f) return Blend(t50, t30, Mathf.InverseLerp(0.6f, 0.4f, level));
else return Blend(t30, t0, Mathf.InverseLerp(0.4f, 0f, level));
}
Texture2D Blend(Texture2D a, Texture2D b, float t)
{
if (t <= 0f || a == null) return a;
if (t >= 1f || b == null) return b;
if (t < 0.5f) return a;
return b;
}
void UpdateAtmosphereLayers()
{
bool isDead = troposphereLevel <= 0f || stratosphereLevel <= 0f ||
thermosphereLevel <= 0f || exosphereLevel <= 0f;
if (isDead)
{
UpdateLayerMaterial(troposphereLayerObject, 0f);
UpdateLayerMaterial(stratosphereLayerObject, 0f);
UpdateLayerMaterial(mesosphereLayerObject, 0f);
UpdateLayerMaterial(thermosphereLayerObject, 0f);
UpdateLayerMaterial(exosphereLayerObject, 0f);
return;
}
UpdateLayerMaterial(troposphereLayerObject, troposphereLevel);
UpdateLayerMaterial(stratosphereLayerObject, stratosphereLevel);
UpdateLayerMaterial(mesosphereLayerObject, mesosphereLevel);
UpdateLayerMaterial(thermosphereLayerObject, thermosphereLevel);
UpdateLayerMaterial(exosphereLayerObject, exosphereLevel);
}
void UpdateLayerMaterial(GameObject layerObj, float level)
{
if (layerObj == null) return;
Renderer r = layerObj.GetComponent<Renderer>();
if (r == null) return;
Material layerMat = r.material;
layerMat.SetFloat("_RimIntensity", Mathf.Lerp(0f, 2.5f, level));
layerMat.SetFloat("_CoreIntensity", Mathf.Lerp(0f, 0.4f, level));
}
void UpdateWeather()
{
if (troposphere == null) return;
bool isDead = troposphereLevel <= 0f || stratosphereLevel <= 0f ||
mesosphereLevel <= 0f || thermosphereLevel <= 0f ||
exosphereLevel <= 0f;
if (isDead)
{
troposphere.SetRainEnabled(false);
troposphere.SetCloudsEnabled(false);
return;
}
float combinedLevel = Mathf.Min(troposphereLevel, stratosphereLevel);
if (combinedLevel < 0.5f)
troposphere.SetRainEnabled(false);
else
troposphere.SetRainEnabled(troposphereLevel >= 0.8f);
if (combinedLevel < 0.4f)
troposphere.SetCloudsEnabled(false);
else
troposphere.SetCloudsEnabled(troposphereLevel >= 0.6f);
if (combinedLevel < 0.2f)
troposphere.gameObject.SetActive(false);
else
troposphere.gameObject.SetActive(true);
}
void UpdateEvaporation()
{
if (evaporationSystem == null) return;
var emission = evaporationSystem.emission;
var main = evaporationSystem.main;
if (troposphereLevel <= 0.5f && troposphereLevel > 0.05f)
{
float t = Mathf.InverseLerp(0.5f, 0.05f, troposphereLevel);
emission.rateOverTime = Mathf.Lerp(100f, 10000f, t);
main.startSize = new ParticleSystem.MinMaxCurve(
Mathf.Lerp(0.02f, 0.15f, t),
Mathf.Lerp(0.08f, 0.3f, t)
);
}
else
{
emission.rateOverTime = 0f;
}
}
void CreateEvaporationEffect()
{
GameObject obj = new GameObject("EvaporationParticles");
obj.transform.parent = null;
obj.transform.position = this.transform.position;
evaporationSystem = obj.AddComponent<ParticleSystem>();
var main = evaporationSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 20000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startSpeed = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startSize = new ParticleSystem.MinMaxCurve(0.05f, 0.15f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.4f, 0.7f, 1.0f, 1f),
new Color(0.6f, 0.85f, 1.0f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = evaporationSystem.emission;
emission.rateOverTime = 0f;
var shape = evaporationSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = 6.4f;
shape.radiusThickness = 0f;
var colorOverLifetime = evaporationSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.4f, 0.7f, 1.0f), 0f),
new GradientColorKey(new Color(0.8f, 0.9f, 1.0f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var psRenderer = evaporationSystem.GetComponent<ParticleSystemRenderer>();
psRenderer.renderMode = ParticleSystemRenderMode.Billboard;
psRenderer.sortingFudge = 5f;
if (evaporationMaterial != null)
psRenderer.material = evaporationMaterial;
evaporationSystem.Play();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a50ce90883a9fd84d92aa018a2c9eb07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections;
public class QuestionController : MonoBehaviour
{
public static QuestionController Instance;
[Header("UI")]
public GameObject questionPanel;
public TextMeshProUGUI questionText;
public Button yesButton;
public Button noButton;
private bool correctAnswer;
private QuestionData[] questions;
private int currentQuestionIndex = 0;
public class QuestionData
{
public string text;
public bool isYesCorrect;
}
void Awake()
{
Instance = this;
if (questionPanel != null) questionPanel.SetActive(false);
}
public void ShowQuestion(string question, bool isYesCorrect)
{
questions = new QuestionData[]
{
new QuestionData { text = question, isYesCorrect = isYesCorrect }
};
currentQuestionIndex = 0;
ShowCurrentQuestion();
}
public void ShowQuestions(QuestionData[] questionList)
{
questions = questionList;
currentQuestionIndex = 0;
ShowCurrentQuestion();
}
void ShowCurrentQuestion()
{
if (questions == null || currentQuestionIndex >= questions.Length) return;
correctAnswer = questions[currentQuestionIndex].isYesCorrect;
questionText.text = questions[currentQuestionIndex].text;
questionPanel.SetActive(true);
yesButton.GetComponent<Image>().color = Color.white;
noButton.GetComponent<Image>().color = Color.white;
yesButton.interactable = true;
noButton.interactable = true;
}
public void OnYesPressed()
{
if (correctAnswer)
OnCorrect(yesButton);
else
OnWrong(yesButton);
}
public void OnNoPressed()
{
if (!correctAnswer)
OnCorrect(noButton);
else
OnWrong(noButton);
}
void OnCorrect(Button btn)
{
btn.GetComponent<Image>().color = new Color(0.3f, 1f, 0.3f);
yesButton.interactable = false;
noButton.interactable = false;
StartCoroutine(NextAfterDelay());
}
void OnWrong(Button btn)
{
btn.GetComponent<Image>().color = new Color(1f, 0.3f, 0.3f);
}
IEnumerator NextAfterDelay()
{
yield return new WaitForSeconds(1f);
currentQuestionIndex++;
if (currentQuestionIndex < questions.Length)
ShowCurrentQuestion();
else
{
questionPanel.SetActive(false);
GameManager.Instance.OnQuestionComplete();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c0cafa1b17e3da4982a74ed8e914a7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RainDirector : MonoBehaviour
{
public Vector3 planetCenter;
void Start()
{
ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem ps in systems)
{
Vector3 dirToCenter = (planetCenter - transform.position).normalized;
var velocityOverLifetime = ps.velocityOverLifetime;
velocityOverLifetime.enabled = true;
velocityOverLifetime.space = ParticleSystemSimulationSpace.World;
velocityOverLifetime.x = dirToCenter.x * 20f;
velocityOverLifetime.y = dirToCenter.y * 20f;
velocityOverLifetime.z = dirToCenter.z * 20f;
var main = ps.main;
main.gravityModifier = 0f;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9a34afb4697bc5488d03e2652a54222
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,157 @@
using UnityEngine;
[ExecuteAlways]
public class SaturnAtmosphereSystem : MonoBehaviour
{
public float saturnRadiusUnits = 7.1492f;
public float heightMultiplier = 8f;
[Header("Òåêñòóðè äëÿ òðîïîñôåðè ³ ñòðàòîñôåðè")]
public Texture2D saturnTexture1;
public Texture2D saturnTexture2;
public Texture2D saturnFogTexture;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateTextureLayer("Layer_Troposphere", 300f,
new Color(0.85f, 0.75f, 0.45f),
new Color(0.65f, 0.55f, 0.25f),
new Color(0.95f, 0.9f, 0.75f),
1.5f, 0.3f, 0.01f, -0.007f, 0.003f);
CreateTextureLayer("Layer_Stratosphere", 600f,
new Color(0.9f, 0.82f, 0.55f),
new Color(0.7f, 0.62f, 0.35f),
new Color(0.95f, 0.92f, 0.8f),
1.0f, 0.2f, 0.008f, -0.005f, 0.004f);
CreateSimpleLayer("Layer_Thermosphere", 900f,
new Color(0.6f, 0.5f, 0.8f),
new Color(0.4f, 0.3f, 0.6f),
0.5f, 0.12f);
CreateSimpleLayer("Layer_Exosphere", 1200f,
new Color(0.55f, 0.45f, 0.75f),
new Color(0.35f, 0.25f, 0.55f),
0.3f, 0.06f);
}
void CreateTextureLayer(string layerName, float heightKm,
Color rimColor, Color coreColor, Color fogColor,
float rimIntensity, float coreIntensity,
float scrollSpeed1, float scrollSpeed2, float fogScrollSpeed)
{
float radiusUnits = saturnRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/SaturnAtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetColor("_FogColor", fogColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_ScrollSpeed1", scrollSpeed1);
mat.SetFloat("_ScrollSpeed2", scrollSpeed2);
mat.SetFloat("_FogScrollSpeed", fogScrollSpeed);
mat.SetFloat("_PulseSpeed", 0.4f);
mat.SetFloat("_PulseStrength", 0.08f);
mat.SetFloat("_TextureBlend", 0.5f);
mat.SetFloat("_TextureInfluence", 0.5f);
mat.SetFloat("_FogInfluence", 0.3f);
if (saturnTexture1 != null) mat.SetTexture("_MainTex", saturnTexture1);
if (saturnTexture2 != null) mat.SetTexture("_SecondTex", saturnTexture2);
if (saturnFogTexture != null) mat.SetTexture("_FogTex", saturnFogTexture);
obj.GetComponent<Renderer>().material = mat;
}
void CreateSimpleLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity)
{
float radiusUnits = saturnRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_PulseSpeed", 0.4f);
mat.SetFloat("_PulseStrength", 0.08f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetLayerIntensity(string layerName, float level)
{
Transform layer = transform.Find(layerName);
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
float rimBase = 0f;
float coreBase = 0f;
switch (layerName)
{
case "Layer_Troposphere": rimBase = 1.5f; coreBase = 0.3f; break;
case "Layer_Stratosphere": rimBase = 1.0f; coreBase = 0.2f; break;
case "Layer_Thermosphere": rimBase = 0.5f; coreBase = 0.12f; break;
case "Layer_Exosphere": rimBase = 0.3f; coreBase = 0.06f; break;
}
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, rimBase, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, coreBase, level));
}
public void SetLayerActive(string layerName, bool active)
{
Transform layer = transform.Find(layerName);
if (layer != null) layer.gameObject.SetActive(active);
}
public void SetIntensity(float level)
{
SetLayerIntensity("Layer_Troposphere", level);
SetLayerIntensity("Layer_Stratosphere", level);
SetLayerIntensity("Layer_Thermosphere", level);
SetLayerIntensity("Layer_Exosphere", level);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9526bcecdf375c345bb9c7164d710d9d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,158 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaturnDeath : MonoBehaviour
{
[Header("Òåêñòóðè òðîïîñôåðè (BaseMap)")]
public Texture2D tropo100;
public Texture2D tropo70;
public Texture2D tropo50;
public Texture2D tropo30;
public Texture2D tropo0;
public Texture2D deadTexture;
[Header("Òåêñòóðè òðîïîñôåðè (BaseMap2)")]
public Texture2D tropo100B;
public Texture2D tropo70B;
public Texture2D tropo50B;
public Texture2D tropo30B;
public Texture2D tropo0B;
public Texture2D deadTextureB;
[Header("Òåêñòóðè ê³ëåöü")]
public Texture2D rings100;
public Texture2D rings70;
public Texture2D rings50;
public Texture2D rings30;
public Texture2D rings0;
[Header("ʳëüöÿ")]
public Renderer ringsRenderer;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float stratosphereLevel = 1f;
public float thermosphereLevel = 1f;
public float exosphereLevel = 1f;
private Renderer _planetRenderer;
private Material _planetMat;
private Material _ringsMat;
private Texture2D _originalTexture;
private Texture2D _originalTexture2;
private Texture2D _originalRingsTexture;
void Start()
{
_planetRenderer = GetComponent<Renderer>();
if (_planetRenderer == null)
_planetRenderer = GetComponentInChildren<Renderer>();
if (_planetRenderer != null)
{
_planetMat = _planetRenderer.material;
_originalTexture = (Texture2D)_planetMat.GetTexture("_BaseMap");
_originalTexture2 = (Texture2D)_planetMat.GetTexture("_BaseMap2");
}
if (ringsRenderer != null)
{
_ringsMat = ringsRenderer.material;
_originalRingsTexture = (Texture2D)_ringsMat.GetTexture("_BaseMap");
}
}
public void ResetTexture()
{
troposphereLevel = 1f;
stratosphereLevel = 1f;
thermosphereLevel = 1f;
exosphereLevel = 1f;
if (_planetMat != null)
{
if (_originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
if (_originalTexture2 != null)
_planetMat.SetTexture("_BaseMap2", _originalTexture2);
}
if (_ringsMat != null && _originalRingsTexture != null)
_ringsMat.SetTexture("_BaseMap", _originalRingsTexture);
}
void Update()
{
if (_planetMat == null) return;
UpdatePlanetTexture();
UpdateRingsTexture();
}
void UpdatePlanetTexture()
{
float worst = Mathf.Min(troposphereLevel, stratosphereLevel, thermosphereLevel, exosphereLevel);
if (worst >= 1f)
{
if (_originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
if (_originalTexture2 != null)
_planetMat.SetTexture("_BaseMap2", _originalTexture2);
return;
}
Texture2D tex = worst <= 0f ? deadTexture : GetPlanetTexture(worst);
Texture2D tex2 = worst <= 0f ? deadTextureB : GetPlanetTexture2(worst);
if (tex != null)
_planetMat.SetTexture("_BaseMap", tex);
if (tex2 != null)
_planetMat.SetTexture("_BaseMap2", tex2);
}
void UpdateRingsTexture()
{
if (_ringsMat == null) return;
float worst = Mathf.Min(troposphereLevel, stratosphereLevel, thermosphereLevel, exosphereLevel);
if (worst >= 1f)
{
if (_originalRingsTexture != null)
_ringsMat.SetTexture("_BaseMap", _originalRingsTexture);
return;
}
Texture2D tex = worst <= 0f ? rings0 : GetRingsTexture(worst);
if (tex != null)
_ringsMat.SetTexture("_BaseMap", tex);
}
Texture2D GetPlanetTexture(float level)
{
if (level >= 0.7f) return tropo100;
else if (level >= 0.5f) return tropo70;
else if (level >= 0.3f) return tropo50;
else if (level > 0f) return tropo30;
else return tropo0;
}
Texture2D GetPlanetTexture2(float level)
{
if (level >= 0.7f) return tropo100B;
else if (level >= 0.5f) return tropo70B;
else if (level >= 0.3f) return tropo50B;
else if (level > 0f) return tropo30B;
else return tropo0B;
}
Texture2D GetRingsTexture(float level)
{
if (level >= 0.7f) return rings100;
else if (level >= 0.5f) return rings70;
else if (level >= 0.3f) return rings50;
else if (level > 0f) return rings30;
else return rings0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a06092b36e2b3494baa6d97df0e66a4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,372 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaturnExosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material tailMaterial;
public Material ringDustMaterial;
public Material radiationMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float exosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem tailSystem;
private ParticleSystem ringDustSystem;
private ParticleSystem radiationBeltSystem;
private bool deathTriggered = false;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (ringDustSystem != null) Destroy(ringDustSystem.gameObject);
if (radiationBeltSystem != null) Destroy(radiationBeltSystem.gameObject);
tailSystem = null;
ringDustSystem = null;
radiationBeltSystem = null;
deathTriggered = false;
exosphereLevel = 1f;
previousLevel = 1f;
CreateTail();
CreateRingDust();
CreateRadiationBelt();
}
void CreateTail()
{
GameObject obj = new GameObject("SaturnTail");
obj.transform.parent = null;
obj.transform.position = transform.position;
tailSystem = obj.AddComponent<ParticleSystem>();
var main = tailSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(3f, 8f);
main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 0.4f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.85f, 0.8f, 0.6f, 0.3f),
new Color(0.7f, 0.65f, 0.45f, 0.15f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = tailSystem.emission;
emission.rateOverTime = 0f;
var shape = tailSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 0.9f;
shape.radiusThickness = 1f;
var vel = tailSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.x = new ParticleSystem.MinMaxCurve(5f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = tailSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.85f, 0.8f, 0.6f), 0f),
new GradientColorKey(new Color(0.7f, 0.65f, 0.45f), 0.5f),
new GradientColorKey(new Color(0.5f, 0.45f, 0.3f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.3f, 0f),
new GradientAlphaKey(0.15f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = tailSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Stretch;
renderer.velocityScale = 0.2f;
renderer.lengthScale = 3f;
renderer.sortingFudge = 3f;
if (tailMaterial != null)
renderer.material = tailMaterial;
tailSystem.Play();
}
void CreateRingDust()
{
GameObject obj = new GameObject("SaturnRingDust");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
ringDustSystem = obj.AddComponent<ParticleSystem>();
var main = ringDustSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 5000;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.6f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.8f, 0.72f, 0.5f, 0.4f),
new Color(0.65f, 0.58f, 0.38f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ringDustSystem.emission;
emission.rateOverTime = 300f;
var shape = ringDustSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = planetRadius * 2.2f;
shape.donutRadius = planetRadius * 0.8f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = ringDustSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ringDustSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.8f, 0.72f, 0.5f), 0f),
new GradientColorKey(new Color(0.65f, 0.58f, 0.38f), 0.5f),
new GradientColorKey(new Color(0.5f, 0.43f, 0.28f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.4f, 0.1f),
new GradientAlphaKey(0.25f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = ringDustSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (ringDustMaterial != null)
renderer.material = ringDustMaterial;
else if (tailMaterial != null)
renderer.material = tailMaterial;
ringDustSystem.Play();
}
void CreateRadiationBelt()
{
GameObject obj = new GameObject("SaturnRadiationBelt");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
radiationBeltSystem = obj.AddComponent<ParticleSystem>();
var main = radiationBeltSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 4000;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.5f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.6f, 0.4f, 0.9f, 0.35f),
new Color(0.4f, 0.2f, 0.7f, 0.2f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = radiationBeltSystem.emission;
emission.rateOverTime = 200f;
var shape = radiationBeltSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = planetRadius * 3.5f;
shape.donutRadius = planetRadius * 0.4f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = radiationBeltSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(3f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = radiationBeltSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.6f, 0.4f, 0.9f), 0f),
new GradientColorKey(new Color(0.4f, 0.2f, 0.7f), 0.5f),
new GradientColorKey(new Color(0.25f, 0.1f, 0.5f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.35f, 0.1f),
new GradientAlphaKey(0.2f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = radiationBeltSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 1f;
if (radiationMaterial != null)
renderer.material = radiationMaterial;
else if (tailMaterial != null)
renderer.material = tailMaterial;
radiationBeltSystem.Play();
}
void UpdateTail()
{
if (tailSystem == null) return;
var e = tailSystem.emission;
if (exosphereLevel >= 1f)
{
e.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(0f, 500f, t);
var main = tailSystem.main;
float speedMin = Mathf.Lerp(3f, 15f, t);
float speedMax = Mathf.Lerp(8f, 30f, t);
main.startSpeed = new ParticleSystem.MinMaxCurve(speedMin, speedMax);
}
void UpdateRingDust()
{
if (ringDustSystem == null) return;
var e = ringDustSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(300f, 0f, t);
}
void UpdateRadiationBelt()
{
if (radiationBeltSystem == null) return;
var e = radiationBeltSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, exosphereLevel);
e.rateOverTime = Mathf.Lerp(200f, 0f, t);
}
IEnumerator DeathBurst()
{
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 3000f;
var m = tailSystem.main;
m.startSpeed = new ParticleSystem.MinMaxCurve(20f, 50f);
}
if (ringDustSystem != null)
{
var e = ringDustSystem.emission;
e.rateOverTime = 2000f;
}
if (radiationBeltSystem != null)
{
var e = radiationBeltSystem.emission;
e.rateOverTime = 0f;
}
yield return new WaitForSeconds(2f);
if (tailSystem != null)
{
var e = tailSystem.emission;
e.rateOverTime = 0f;
var m = tailSystem.main;
m.startSpeed = new ParticleSystem.MinMaxCurve(3f, 8f);
}
if (ringDustSystem != null)
{
var e = ringDustSystem.emission;
e.rateOverTime = 0f;
}
}
void Update()
{
if (!Application.isPlaying) return;
if (exosphereLevel >= 1f && previousLevel < 1f)
{
InitState();
deathTriggered = false;
}
previousLevel = exosphereLevel;
if (exosphereLevel <= 0f && !deathTriggered)
{
deathTriggered = true;
StartCoroutine(DeathBurst());
return;
}
if (deathTriggered) return;
UpdateTail();
UpdateRingDust();
UpdateRadiationBelt();
}
public void CleanUp()
{
if (tailSystem != null) Destroy(tailSystem.gameObject);
if (ringDustSystem != null) Destroy(ringDustSystem.gameObject);
if (radiationBeltSystem != null) Destroy(radiationBeltSystem.gameObject);
tailSystem = null;
ringDustSystem = null;
radiationBeltSystem = null;
deathTriggered = false;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d93fe04f4afdd746a6212da55dd6ba2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,390 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaturnStratosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material fogMaterial;
public Material cloudMaterial;
public Material lightningMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float stratosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem fogSystem;
private List<ParticleSystem> cloudClusters = new List<ParticleSystem>();
private ParticleSystem chemicalGlowSystem;
private List<GameObject> lightningObjects = new List<GameObject>();
private Coroutine lightningCoroutine;
void Awake()
{
enabled = false;
}
public void InitState()
{
if (fogSystem != null) Destroy(fogSystem.gameObject);
foreach (var ps in cloudClusters)
if (ps != null) Destroy(ps.gameObject);
cloudClusters.Clear();
if (chemicalGlowSystem != null) Destroy(chemicalGlowSystem.gameObject);
foreach (var obj in lightningObjects)
if (obj != null) Destroy(obj);
lightningObjects.Clear();
if (lightningCoroutine != null) StopCoroutine(lightningCoroutine);
fogSystem = null;
chemicalGlowSystem = null;
stratosphereLevel = 1f;
previousLevel = 1f;
CreateFog();
CreateClouds();
CreateChemicalGlow();
lightningCoroutine = StartCoroutine(SpawnLightning());
}
void CreateFog()
{
GameObject obj = new GameObject("SaturnFog");
obj.transform.parent = null;
obj.transform.position = transform.position;
fogSystem = obj.AddComponent<ParticleSystem>();
var main = fogSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 4000;
main.startLifetime = new ParticleSystem.MinMaxCurve(8f, 15f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(3f, 8f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.92f, 0.87f, 0.7f, 0.15f),
new Color(0.85f, 0.8f, 0.62f, 0.08f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = fogSystem.emission;
emission.rateOverTime = 200f;
var shape = fogSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.12f;
shape.radiusThickness = 0.08f;
var vel = fogSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0.5f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = fogSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.92f, 0.87f, 0.7f), 0f),
new GradientColorKey(new Color(0.88f, 0.83f, 0.66f), 0.5f),
new GradientColorKey(new Color(0.82f, 0.77f, 0.6f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.15f, 0.2f),
new GradientAlphaKey(0.1f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = fogSystem.noise;
noise.enabled = true;
noise.strength = 0.3f;
noise.frequency = 0.1f;
noise.scrollSpeed = 0.05f;
var renderer = fogSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 2f;
if (fogMaterial != null)
renderer.material = fogMaterial;
fogSystem.Play();
}
void CreateClouds()
{
float[] latitudes = { -35f, -12f, 12f, 35f };
Color[] colors =
{
new Color(0.82f, 0.75f, 0.55f),
new Color(0.88f, 0.82f, 0.62f),
new Color(0.85f, 0.78f, 0.58f),
new Color(0.8f, 0.73f, 0.52f)
};
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("SaturnCloud_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 1500;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(2f, 5f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(colors[i].r, colors[i].g, colors[i].b, 0.3f),
new Color(colors[i].r * 0.85f, colors[i].g * 0.85f, colors[i].b * 0.85f, 0.15f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 60f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.1f;
shape.radiusThickness = 0.05f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(i % 2 == 0 ? 1.5f : -1.5f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(colors[i], 0f),
new GradientColorKey(colors[i] * 0.85f, 0.5f),
new GradientColorKey(colors[i] * 0.65f, 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.3f, 0.15f),
new GradientAlphaKey(0.2f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.3f;
noise.frequency = 0.15f;
noise.scrollSpeed = 0.08f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (cloudMaterial != null)
renderer.material = cloudMaterial;
ps.Play();
cloudClusters.Add(ps);
}
}
void CreateChemicalGlow()
{
GameObject obj = new GameObject("SaturnChemicalGlow");
obj.transform.parent = null;
obj.transform.position = transform.position;
chemicalGlowSystem = obj.AddComponent<ParticleSystem>();
var main = chemicalGlowSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 2000;
main.startLifetime = new ParticleSystem.MinMaxCurve(5f, 10f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(1f, 3f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.9f, 0.85f, 0.5f, 0.2f),
new Color(0.8f, 0.75f, 0.4f, 0.1f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = chemicalGlowSystem.emission;
emission.rateOverTime = 100f;
var shape = chemicalGlowSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.08f;
shape.radiusThickness = 0.03f;
var vel = chemicalGlowSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(1f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = chemicalGlowSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.9f, 0.85f, 0.5f), 0f),
new GradientColorKey(new Color(0.85f, 0.78f, 0.45f), 0.5f),
new GradientColorKey(new Color(0.75f, 0.68f, 0.35f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.2f, 0.15f),
new GradientAlphaKey(0.1f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = chemicalGlowSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 1f;
if (fogMaterial != null)
renderer.material = fogMaterial;
chemicalGlowSystem.Play();
}
IEnumerator SpawnLightning()
{
while (enabled)
{
if (stratosphereLevel < 1f)
{
float interval = Mathf.Lerp(0.2f, 2f, stratosphereLevel);
yield return new WaitForSeconds(interval);
Vector3 dir = Random.onUnitSphere;
Vector3 pos = transform.position + dir * planetRadius * 1.05f;
GameObject lightObj = new GameObject("SaturnLightning");
lightObj.transform.position = pos;
Light light = lightObj.AddComponent<Light>();
light.type = LightType.Point;
light.color = new Color(0.9f, 0.85f, 0.6f);
light.intensity = Mathf.Lerp(30f, 150f, 1f - stratosphereLevel);
light.range = planetRadius * 3f;
lightningObjects.Add(lightObj);
yield return new WaitForSeconds(0.1f);
if (lightObj != null) Destroy(lightObj);
lightningObjects.Remove(lightObj);
}
else
{
yield return new WaitForSeconds(0.5f);
}
}
}
void UpdateFog()
{
if (fogSystem == null) return;
var emission = fogSystem.emission;
if (stratosphereLevel >= 1f)
emission.rateOverTime = 200f;
else if (stratosphereLevel >= 0.7f)
emission.rateOverTime = Mathf.Lerp(200f, 120f, Mathf.InverseLerp(1f, 0.7f, stratosphereLevel));
else if (stratosphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(120f, 50f, Mathf.InverseLerp(0.7f, 0.5f, stratosphereLevel));
else if (stratosphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(50f, 10f, Mathf.InverseLerp(0.5f, 0.3f, stratosphereLevel));
else
emission.rateOverTime = 0f;
}
void UpdateClouds()
{
foreach (var ps in cloudClusters)
{
if (ps == null) continue;
var emission = ps.emission;
if (stratosphereLevel >= 1f)
emission.rateOverTime = 60f;
else if (stratosphereLevel >= 0.7f)
emission.rateOverTime = Mathf.Lerp(60f, 35f, Mathf.InverseLerp(1f, 0.7f, stratosphereLevel));
else if (stratosphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(35f, 15f, Mathf.InverseLerp(0.7f, 0.5f, stratosphereLevel));
else if (stratosphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(15f, 5f, Mathf.InverseLerp(0.5f, 0.3f, stratosphereLevel));
else
emission.rateOverTime = 0f;
}
}
void UpdateChemicalGlow()
{
if (chemicalGlowSystem == null) return;
var emission = chemicalGlowSystem.emission;
float t = Mathf.InverseLerp(1f, 0f, stratosphereLevel);
emission.rateOverTime = Mathf.Lerp(100f, 0f, t);
}
void Update()
{
if (!Application.isPlaying) return;
if (stratosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = stratosphereLevel;
UpdateFog();
UpdateClouds();
UpdateChemicalGlow();
}
public void CleanUp()
{
if (fogSystem != null) Destroy(fogSystem.gameObject);
foreach (var ps in cloudClusters)
if (ps != null) Destroy(ps.gameObject);
cloudClusters.Clear();
if (chemicalGlowSystem != null) Destroy(chemicalGlowSystem.gameObject);
foreach (var obj in lightningObjects)
if (obj != null) Destroy(obj);
lightningObjects.Clear();
if (lightningCoroutine != null) StopCoroutine(lightningCoroutine);
fogSystem = null;
chemicalGlowSystem = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4e96423e5c826b47a98e6f3641a4277
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,248 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaturnThermosphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material ringRainMaterial;
public Material solarWindMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
public float previousLevel = 1f;
private ParticleSystem _ionizationSystem;
private ParticleSystem _ringRainSystem;
void Awake()
{
enabled = false;
}
float WorldRadius()
{
return planetRadius * transform.lossyScale.x;
}
public void InitState()
{
if (_ionizationSystem != null) Destroy(_ionizationSystem.gameObject);
if (_ringRainSystem != null) Destroy(_ringRainSystem.gameObject);
_ionizationSystem = null;
_ringRainSystem = null;
thermosphereLevel = 1f;
previousLevel = 1f;
CreateIonization();
CreateRingRain();
}
void CreateIonization()
{
float r = WorldRadius();
GameObject obj = new GameObject("SaturnIonization");
obj.transform.parent = null;
obj.transform.position = transform.position;
_ionizationSystem = obj.AddComponent<ParticleSystem>();
var main = _ionizationSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 30000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 9f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.02f, r * 0.06f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.5f, 0.8f, 1f, 1f),
new Color(0.8f, 0.5f, 1f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = _ionizationSystem.emission;
emission.rateOverTime = 1500f;
var shape = _ionizationSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = r * 1.18f;
shape.radiusThickness = 0.04f;
var vel = _ionizationSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(2.5f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = _ionizationSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.5f, 0.8f, 1f), 0f),
new GradientColorKey(new Color(0.7f, 0.5f, 1f), 0.5f),
new GradientColorKey(new Color(1f, 0.3f, 0.8f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(1f, 0.1f),
new GradientAlphaKey(0.8f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = _ionizationSystem.noise;
noise.enabled = true;
noise.strength = 2f;
noise.frequency = 0.15f;
noise.scrollSpeed = 0.3f;
var renderer = _ionizationSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (solarWindMaterial != null)
renderer.material = solarWindMaterial;
_ionizationSystem.Play();
}
void CreateRingRain()
{
float r = WorldRadius();
GameObject obj = new GameObject("SaturnRingRain");
obj.transform.parent = null;
obj.transform.position = transform.position;
obj.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
_ringRainSystem = obj.AddComponent<ParticleSystem>();
var main = _ringRainSystem.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 30000;
main.startLifetime = new ParticleSystem.MinMaxCurve(4f, 8f);
main.startSpeed = new ParticleSystem.MinMaxCurve(r * 0.01f, r * 0.02f);
main.startSize = new ParticleSystem.MinMaxCurve(r * 0.004f, r * 0.012f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.6f, 0.9f, 1f, 1f),
new Color(0.4f, 0.7f, 1f, 0.8f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = _ringRainSystem.emission;
emission.rateOverTime = 2000f;
var shape = _ringRainSystem.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Donut;
shape.radius = r * 2f;
shape.donutRadius = r * 0.5f;
shape.radiusThickness = 1f;
shape.arc = 360f;
var vel = _ringRainSystem.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(-(r * 0.015f));
vel.z = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = _ringRainSystem.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.8f, 0.95f, 1f), 0f),
new GradientColorKey(new Color(0.5f, 0.8f, 1f), 0.4f),
new GradientColorKey(new Color(0.3f, 0.6f, 0.9f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.8f, 0.5f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = _ringRainSystem.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Stretch;
renderer.velocityScale = 0.15f;
renderer.lengthScale = 4f;
renderer.sortingFudge = 4f;
if (ringRainMaterial != null)
renderer.material = ringRainMaterial;
else if (solarWindMaterial != null)
renderer.material = solarWindMaterial;
_ringRainSystem.Play();
}
void UpdateIonization()
{
if (_ionizationSystem == null) return;
var e = _ionizationSystem.emission;
if (thermosphereLevel <= 0f)
{
e.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
e.rateOverTime = Mathf.Lerp(1500f, 4000f, t);
}
void UpdateRingRain()
{
if (_ringRainSystem == null) return;
var e = _ringRainSystem.emission;
if (thermosphereLevel <= 0f)
{
e.rateOverTime = 0f;
return;
}
float t = Mathf.InverseLerp(1f, 0f, thermosphereLevel);
e.rateOverTime = Mathf.Lerp(2000f, 0f, t);
}
void Update()
{
if (!Application.isPlaying) return;
if (thermosphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = thermosphereLevel;
UpdateIonization();
UpdateRingRain();
}
public void CleanUp()
{
if (_ionizationSystem != null) Destroy(_ionizationSystem.gameObject);
if (_ringRainSystem != null) Destroy(_ringRainSystem.gameObject);
_ionizationSystem = null;
_ringRainSystem = null;
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3971532dfe13b4b42871fc7107b0f409
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,286 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaturnTroposphereEffects : MonoBehaviour
{
[Header("Íàëàøòóâàííÿ")]
public Material stormMaterial;
public Material windMaterial;
public float planetRadius = 58f;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float previousLevel = 1f;
private List<ParticleSystem> _bandClusters = new List<ParticleSystem>();
private List<ParticleSystem> _windClusters = new List<ParticleSystem>();
void Awake()
{
enabled = false;
}
public void InitState()
{
foreach (var ps in _bandClusters)
if (ps != null) Destroy(ps.gameObject);
_bandClusters.Clear();
foreach (var ps in _windClusters)
if (ps != null) Destroy(ps.gameObject);
_windClusters.Clear();
troposphereLevel = 1f;
previousLevel = 1f;
CreateBands();
CreateWindStreams();
}
void CreateBands()
{
float[] latitudes = { -50f, -25f, -8f, 8f, 25f, 50f };
float[] speeds = { 2f, -1.5f, 2.5f, -2.5f, 1.5f, -2f };
Color[] colors =
{
new Color(0.8f, 0.72f, 0.5f),
new Color(0.88f, 0.8f, 0.58f),
new Color(0.85f, 0.76f, 0.52f),
new Color(0.82f, 0.74f, 0.5f),
new Color(0.78f, 0.7f, 0.48f),
new Color(0.75f, 0.67f, 0.45f)
};
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("SaturnBand_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 15000;
main.startLifetime = new ParticleSystem.MinMaxCurve(6f, 12f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(0.375f, 3f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(colors[i].r, colors[i].g, colors[i].b, 0.6f),
new Color(colors[i].r * 0.85f, colors[i].g * 0.85f, colors[i].b * 0.85f, 0.4f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 0f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius;
shape.radiusThickness = 0.02f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(speeds[i]);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(colors[i], 0f),
new GradientColorKey(colors[i] * 0.85f, 0.5f),
new GradientColorKey(colors[i] * 0.65f, 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.6f, 0.15f),
new GradientAlphaKey(0.4f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var noise = ps.noise;
noise.enabled = true;
noise.strength = 0.3f;
noise.frequency = 0.15f;
noise.scrollSpeed = 0.08f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 4f;
if (stormMaterial != null)
renderer.material = stormMaterial;
ps.Play();
_bandClusters.Add(ps);
}
}
void CreateWindStreams()
{
float[] latitudes = { -15f, 0f, 15f };
float[] speeds = { 15f, -18f, 15f };
for (int i = 0; i < latitudes.Length; i++)
{
GameObject obj = new GameObject("SaturnWind_" + i);
obj.transform.parent = null;
obj.transform.position = transform.position;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 20000;
main.startLifetime = new ParticleSystem.MinMaxCurve(2f, 4f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0f, 0f);
main.startSize = new ParticleSystem.MinMaxCurve(1.25f, 3.75f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.95f, 0.9f, 0.75f, 0.6f),
new Color(0.85f, 0.8f, 0.65f, 0.4f)
);
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.gravityModifier = 0f;
var emission = ps.emission;
emission.rateOverTime = 0f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = planetRadius * 1.01f;
shape.radiusThickness = 0.01f;
shape.arc = 360f;
shape.rotation = new Vector3(latitudes[i], 0f, 0f);
var vel = ps.velocityOverLifetime;
vel.enabled = true;
vel.space = ParticleSystemSimulationSpace.World;
vel.orbitalX = new ParticleSystem.MinMaxCurve(0f);
vel.orbitalY = new ParticleSystem.MinMaxCurve(speeds[i]);
vel.orbitalZ = new ParticleSystem.MinMaxCurve(0f);
vel.x = new ParticleSystem.MinMaxCurve(0f);
vel.y = new ParticleSystem.MinMaxCurve(0f);
vel.z = new ParticleSystem.MinMaxCurve(0f);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.95f, 0.9f, 0.75f), 0f),
new GradientColorKey(new Color(0.85f, 0.8f, 0.65f), 0.5f),
new GradientColorKey(new Color(0.75f, 0.7f, 0.55f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.6f, 0.1f),
new GradientAlphaKey(0.4f, 0.8f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = 3f;
if (windMaterial != null)
renderer.material = windMaterial;
else if (stormMaterial != null)
renderer.material = stormMaterial;
ps.Play();
_windClusters.Add(ps);
}
}
void UpdateBands()
{
foreach (var ps in _bandClusters)
{
if (ps == null) continue;
var emission = ps.emission;
if (troposphereLevel <= 0f)
{
emission.rateOverTime = 0f;
continue;
}
if (troposphereLevel >= 0.7f)
emission.rateOverTime = 0f;
else if (troposphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(0f, 400f, Mathf.InverseLerp(0.7f, 0.5f, troposphereLevel));
else if (troposphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(400f, 1200f, Mathf.InverseLerp(0.5f, 0.3f, troposphereLevel));
else
emission.rateOverTime = Mathf.Lerp(1200f, 2500f, Mathf.InverseLerp(0.3f, 0f, troposphereLevel));
}
}
void UpdateWindStreams()
{
foreach (var ps in _windClusters)
{
if (ps == null) continue;
var emission = ps.emission;
if (troposphereLevel <= 0f)
{
emission.rateOverTime = 0f;
continue;
}
if (troposphereLevel >= 1f)
emission.rateOverTime = 800f;
else if (troposphereLevel >= 0.7f)
emission.rateOverTime = Mathf.Lerp(800f, 1200f, Mathf.InverseLerp(1f, 0.7f, troposphereLevel));
else if (troposphereLevel >= 0.5f)
emission.rateOverTime = Mathf.Lerp(1200f, 2000f, Mathf.InverseLerp(0.7f, 0.5f, troposphereLevel));
else if (troposphereLevel >= 0.3f)
emission.rateOverTime = Mathf.Lerp(2000f, 3000f, Mathf.InverseLerp(0.5f, 0.3f, troposphereLevel));
else
emission.rateOverTime = Mathf.Lerp(3000f, 5000f, Mathf.InverseLerp(0.3f, 0f, troposphereLevel));
}
}
void Update()
{
if (!Application.isPlaying) return;
if (troposphereLevel >= 1f && previousLevel < 1f)
InitState();
previousLevel = troposphereLevel;
UpdateBands();
UpdateWindStreams();
}
public void CleanUp()
{
foreach (var ps in _bandClusters)
if (ps != null) Destroy(ps.gameObject);
_bandClusters.Clear();
foreach (var ps in _windClusters)
if (ps != null) Destroy(ps.gameObject);
_windClusters.Clear();
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73849beaec6b1a84ebaa3b27b3fd59ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,686 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class SimulationController : MonoBehaviour
{
public static SimulationController Instance;
[Header("UI åëåìåíòè")]
public TextMeshProUGUI layerNameText;
public TextMeshProUGUI layerInfoText;
public TextMeshProUGUI percentageText;
public Slider progressSlider;
[Header("Êíîïêè")]
public Button nextButton;
public Button prevButton;
private PlanetDatabase.PlanetInfo currentPlanetInfo;
private int currentLayerIndex;
private bool layerInitialized = false;
void Awake()
{
Instance = this;
}
public void StartLayer(int layerIndex, PlanetDatabase.PlanetInfo planetInfo)
{
currentPlanetInfo = planetInfo;
currentLayerIndex = layerIndex;
layerInitialized = false;
if (progressSlider != null)
{
progressSlider.minValue = 0f;
progressSlider.maxValue = 4f;
progressSlider.wholeNumbers = true;
progressSlider.value = 4f;
progressSlider.onValueChanged.RemoveAllListeners();
progressSlider.onValueChanged.AddListener(OnSliderChanged);
}
if (prevButton != null)
prevButton.interactable = currentLayerIndex > 0;
if (nextButton != null)
nextButton.interactable = currentLayerIndex < currentPlanetInfo.layers.Length - 1;
UpdateUI();
InitCurrentLayer();
UpdateLayerSimulation(1f);
}
void InitCurrentLayer()
{
if (layerInitialized) return;
layerInitialized = true;
var atmo = GameManager.Instance.GetCurrentPlanet().atmosphereSystem;
if (atmo == null) return;
switch (currentLayerIndex)
{
case 0:
var tropo = atmo.GetComponentInChildren<TroposphereEffects>(true);
if (tropo != null && !tropo.enabled) tropo.enabled = true;
var mercury = atmo.GetComponentInChildren<MercuryEffects>(true);
if (mercury != null && !mercury.enabled)
{
mercury.enabled = true;
mercury.InitState();
}
var marsEff = atmo.GetComponentInChildren<MarsEffects>(true);
if (marsEff != null && !marsEff.enabled)
{
marsEff.enabled = true;
marsEff.InitState();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Mars")
{
var marsAtmo = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo != null)
{
marsAtmo.SetLayerActive("Layer_Mesosphere", false);
marsAtmo.SetLayerActive("Layer_Thermosphere", false);
marsAtmo.SetLayerActive("Layer_Exosphere", false);
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Jupiter")
{
var jupiterAtmo = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo != null)
{
jupiterAtmo.SetLayerActive("Layer_Stratosphere", false);
jupiterAtmo.SetLayerActive("Layer_Thermosphere", false);
jupiterAtmo.SetLayerActive("Layer_Exosphere", false);
}
var jupiterTropo = atmo.GetComponentInChildren<JupiterTroposphereEffects>(true);
if (jupiterTropo != null && !jupiterTropo.enabled)
{
jupiterTropo.enabled = true;
jupiterTropo.InitState();
}
var jupiterStratoGlow0 = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStratoGlow0 != null && jupiterStratoGlow0.jupiterGlow != null)
jupiterStratoGlow0.jupiterGlow.Stop();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Saturn")
{
var saturnAtmo = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo != null)
{
saturnAtmo.SetLayerActive("Layer_Stratosphere", false);
saturnAtmo.SetLayerActive("Layer_Thermosphere", false);
saturnAtmo.SetLayerActive("Layer_Exosphere", false);
}
var saturnTropo = atmo.GetComponentInChildren<SaturnTroposphereEffects>(true);
if (saturnTropo != null && !saturnTropo.enabled)
{
saturnTropo.enabled = true;
saturnTropo.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Uranus")
{
var uranusAtmo = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo != null)
{
uranusAtmo.SetLayerActive("Layer_Stratosphere", false);
uranusAtmo.SetLayerActive("Layer_Thermosphere", false);
}
var uranusTropo = atmo.GetComponentInChildren<UranusTroposphereEffects>(true);
if (uranusTropo != null && !uranusTropo.enabled)
{
uranusTropo.enabled = true;
uranusTropo.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Neptune")
{
var neptuneAtmo = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo != null)
{
neptuneAtmo.SetLayerActive("Layer_Stratosphere", false);
neptuneAtmo.SetLayerActive("Layer_Thermosphere", false);
}
var neptuneTropo = atmo.GetComponentInChildren<NeptuneTroposphereEffects>(true);
if (neptuneTropo != null && !neptuneTropo.enabled)
{
neptuneTropo.enabled = true;
neptuneTropo.InitState();
}
}
break;
case 1:
var strato = atmo.GetComponentInChildren<StratosphereEffects>(true);
if (strato != null && !strato.enabled) strato.enabled = true;
var stratoDeath = atmo.GetComponentInChildren<StratosphereDeath>(true);
if (stratoDeath != null && !stratoDeath.enabled)
{
stratoDeath.enabled = true;
stratoDeath.InitState();
}
var venusEff = atmo.GetComponentInChildren<VenusEffects>(true);
if (venusEff != null && !venusEff.enabled)
{
venusEff.enabled = true;
venusEff.InitState();
}
var marsMeso = atmo.GetComponentInChildren<MarsMesosphereEffects>(true);
if (marsMeso != null && !marsMeso.enabled)
{
marsMeso.enabled = true;
marsMeso.InitState();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Mars")
{
var marsAtmo = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo != null)
{
marsAtmo.SetLayerActive("Layer_Troposphere", false);
marsAtmo.SetLayerActive("Layer_Thermosphere", false);
marsAtmo.SetLayerActive("Layer_Exosphere", false);
marsAtmo.SetLayerActive("Layer_Mesosphere", true);
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Jupiter")
{
var jupiterAtmo = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo != null)
{
jupiterAtmo.SetLayerActive("Layer_Troposphere", false);
jupiterAtmo.SetLayerActive("Layer_Thermosphere", false);
jupiterAtmo.SetLayerActive("Layer_Exosphere", false);
jupiterAtmo.SetLayerActive("Layer_Stratosphere", true);
}
var jupiterStrato = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStrato != null && !jupiterStrato.enabled)
{
jupiterStrato.enabled = true;
jupiterStrato.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Saturn")
{
var saturnAtmo = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo != null)
{
saturnAtmo.SetLayerActive("Layer_Troposphere", false);
saturnAtmo.SetLayerActive("Layer_Thermosphere", false);
saturnAtmo.SetLayerActive("Layer_Exosphere", false);
saturnAtmo.SetLayerActive("Layer_Stratosphere", true);
}
var saturnStrato = atmo.GetComponentInChildren<SaturnStratosphereEffects>(true);
if (saturnStrato != null && !saturnStrato.enabled)
{
saturnStrato.enabled = true;
saturnStrato.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Uranus")
{
var uranusAtmo = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo != null)
{
uranusAtmo.SetLayerActive("Layer_Troposphere", false);
uranusAtmo.SetLayerActive("Layer_Thermosphere", false);
uranusAtmo.SetLayerActive("Layer_Stratosphere", true);
}
var uranusStrato = atmo.GetComponentInChildren<UranusStratosphereEffects>(true);
if (uranusStrato != null && !uranusStrato.enabled)
{
uranusStrato.enabled = true;
uranusStrato.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Neptune")
{
var neptuneAtmo = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo != null)
{
neptuneAtmo.SetLayerActive("Layer_Troposphere", false);
neptuneAtmo.SetLayerActive("Layer_Thermosphere", false);
neptuneAtmo.SetLayerActive("Layer_Stratosphere", true);
}
var neptuneStrato = atmo.GetComponentInChildren<NeptuneStratosphereEffects>(true);
if (neptuneStrato != null && !neptuneStrato.enabled)
{
neptuneStrato.enabled = true;
neptuneStrato.InitState();
}
}
break;
case 2:
var meso = atmo.GetComponentInChildren<MesosphereEffects>(true);
if (meso != null && !meso.enabled) meso.enabled = true;
var venusThermo = atmo.GetComponentInChildren<VenusThermosphereEffects>(true);
if (venusThermo != null && !venusThermo.enabled)
{
venusThermo.enabled = true;
venusThermo.InitState();
}
var marsThermo = atmo.GetComponentInChildren<MarsThermosphereEffects>(true);
if (marsThermo != null && !marsThermo.enabled)
{
marsThermo.enabled = true;
marsThermo.InitState();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Mars")
{
var marsAtmo2 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo2 != null)
{
marsAtmo2.SetLayerActive("Layer_Troposphere", false);
marsAtmo2.SetLayerActive("Layer_Mesosphere", false);
marsAtmo2.SetLayerActive("Layer_Exosphere", false);
marsAtmo2.SetLayerActive("Layer_Thermosphere", true);
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Jupiter")
{
var jupiterAtmo = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo != null)
{
jupiterAtmo.SetLayerActive("Layer_Troposphere", false);
jupiterAtmo.SetLayerActive("Layer_Stratosphere", false);
jupiterAtmo.SetLayerActive("Layer_Exosphere", false);
jupiterAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var jupiterThermo = atmo.GetComponentInChildren<JupiterThermosphereEffects>(true);
if (jupiterThermo != null && !jupiterThermo.enabled)
{
jupiterThermo.enabled = true;
jupiterThermo.InitState();
}
var jupiterStratoGlow2 = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStratoGlow2 != null && jupiterStratoGlow2.jupiterGlow != null)
jupiterStratoGlow2.jupiterGlow.Stop();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Saturn")
{
var saturnAtmo = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo != null)
{
saturnAtmo.SetLayerActive("Layer_Troposphere", false);
saturnAtmo.SetLayerActive("Layer_Stratosphere", false);
saturnAtmo.SetLayerActive("Layer_Exosphere", false);
saturnAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var saturnThermo = atmo.GetComponentInChildren<SaturnThermosphereEffects>(true);
if (saturnThermo != null && !saturnThermo.enabled)
{
saturnThermo.enabled = true;
saturnThermo.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Uranus")
{
var uranusAtmo = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo != null)
{
uranusAtmo.SetLayerActive("Layer_Troposphere", false);
uranusAtmo.SetLayerActive("Layer_Stratosphere", false);
uranusAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var uranusThermo = atmo.GetComponentInChildren<UranusThermosphereEffects>(true);
if (uranusThermo != null && !uranusThermo.enabled)
{
uranusThermo.enabled = true;
uranusThermo.InitState();
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Neptune")
{
var neptuneAtmo = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo != null)
{
neptuneAtmo.SetLayerActive("Layer_Troposphere", false);
neptuneAtmo.SetLayerActive("Layer_Stratosphere", false);
neptuneAtmo.SetLayerActive("Layer_Thermosphere", true);
}
var neptuneThermo = atmo.GetComponentInChildren<NeptuneThermosphereEffects>(true);
if (neptuneThermo != null && !neptuneThermo.enabled)
{
neptuneThermo.enabled = true;
neptuneThermo.InitState();
}
}
break;
case 3:
var thermo = atmo.GetComponentInChildren<ThermosphereEffects>(true);
if (thermo != null)
{
if (!thermo.enabled)
{
thermo.enabled = true;
thermo.InitStateAndSpawn();
}
thermo.thermosphereLevel = 1f;
}
var venusExo = atmo.GetComponentInChildren<VenusExosphereEffects>(true);
if (venusExo != null && !venusExo.enabled)
{
venusExo.enabled = true;
venusExo.InitState();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Mars")
{
var marsAtmo3 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo3 != null)
{
marsAtmo3.SetLayerActive("Layer_Troposphere", false);
marsAtmo3.SetLayerActive("Layer_Mesosphere", false);
marsAtmo3.SetLayerActive("Layer_Thermosphere", false);
marsAtmo3.SetLayerActive("Layer_Exosphere", true);
}
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Jupiter")
{
var jupiterAtmo = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo != null)
{
jupiterAtmo.SetLayerActive("Layer_Troposphere", false);
jupiterAtmo.SetLayerActive("Layer_Stratosphere", false);
jupiterAtmo.SetLayerActive("Layer_Thermosphere", false);
jupiterAtmo.SetLayerActive("Layer_Exosphere", true);
}
var jupiterExo = atmo.GetComponentInChildren<JupiterExosphereEffects>(true);
if (jupiterExo != null && !jupiterExo.enabled)
{
jupiterExo.enabled = true;
jupiterExo.InitState();
}
var jupiterStratoGlow3 = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStratoGlow3 != null && jupiterStratoGlow3.jupiterGlow != null)
jupiterStratoGlow3.jupiterGlow.Stop();
}
if (GameManager.Instance.GetCurrentPlanet().planetKey == "Saturn")
{
var saturnAtmo = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo != null)
{
saturnAtmo.SetLayerActive("Layer_Troposphere", false);
saturnAtmo.SetLayerActive("Layer_Stratosphere", false);
saturnAtmo.SetLayerActive("Layer_Thermosphere", false);
saturnAtmo.SetLayerActive("Layer_Exosphere", true);
}
var saturnExo = atmo.GetComponentInChildren<SaturnExosphereEffects>(true);
if (saturnExo != null && !saturnExo.enabled)
{
saturnExo.enabled = true;
saturnExo.InitState();
}
}
break;
case 4:
var exo = atmo.GetComponentInChildren<ExosphereEffects>(true);
if (exo != null && !exo.enabled) exo.enabled = true;
break;
}
}
void OnSliderChanged(float value)
{
float level = SliderToLevel(value);
int percent = Mathf.RoundToInt(level * 100f);
if (percentageText != null)
percentageText.text = "³äñîòêè: " + percent + "%";
UpdateLayerText(level);
UpdateLayerSimulation(level);
}
float SliderToLevel(float sliderValue)
{
switch (Mathf.RoundToInt(sliderValue))
{
case 4: return 1f;
case 3: return 0.7f;
case 2: return 0.5f;
case 1: return 0.3f;
case 0: return 0f;
default: return 1f;
}
}
void UpdateLayerText(float level)
{
if (currentPlanetInfo?.layers == null) return;
if (currentLayerIndex >= currentPlanetInfo.layers.Length) return;
var layer = currentPlanetInfo.layers[currentLayerIndex];
if (layerInfoText == null) return;
if (level >= 1f)
layerInfoText.text = layer.description;
else if (level >= 0.7f)
layerInfoText.text = layer.importance;
else if (level >= 0.5f)
layerInfoText.text = layer.threat;
else if (level >= 0.3f)
layerInfoText.text = layer.howToProtect;
else
layerInfoText.text = "Øàð ïîâí³ñòþ çðóéíîâàíî. Íàñë³äêè äëÿ ïëàíåòè º íåçâîðîòíèìè.";
}
void UpdateLayerSimulation(float value)
{
PlanetDeath pd = GameObject.FindObjectOfType<PlanetDeath>();
if (pd == null) return;
var atmo = GameManager.Instance.GetCurrentPlanet().atmosphereSystem;
if (atmo == null) return;
switch (currentLayerIndex)
{
case 0:
pd.troposphereLevel = value;
var mercuryEff = atmo.GetComponentInChildren<MercuryEffects>(true);
if (mercuryEff != null) mercuryEff.exosphereLevel = value;
var mercuryAtmo = atmo.GetComponentInChildren<MercuryAtmosphereSystem>(true);
if (mercuryAtmo != null) mercuryAtmo.SetIntensity(value);
var venusDeath = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath != null) venusDeath.troposphereLevel = value;
var venusAtmo = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo != null) venusAtmo.SetIntensity(value);
var marsEff = atmo.GetComponentInChildren<MarsEffects>(true);
if (marsEff != null) marsEff.troposphereLevel = value;
var marsDeath0 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath0 != null) marsDeath0.troposphereLevel = value;
var marsAtmo = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo != null) marsAtmo.SetLayerIntensity("Layer_Troposphere", value);
var jupiterDeath0 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath0 != null) jupiterDeath0.troposphereLevel = value;
var jupiterAtmo0 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo0 != null) jupiterAtmo0.SetLayerIntensity("Layer_Troposphere", value);
var jupiterTropo0 = atmo.GetComponentInChildren<JupiterTroposphereEffects>(true);
if (jupiterTropo0 != null) jupiterTropo0.troposphereLevel = value;
var saturnDeath0 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath0 != null) saturnDeath0.troposphereLevel = value;
var saturnAtmo0 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo0 != null) saturnAtmo0.SetLayerIntensity("Layer_Troposphere", value);
var saturnTropo0 = atmo.GetComponentInChildren<SaturnTroposphereEffects>(true);
if (saturnTropo0 != null) saturnTropo0.troposphereLevel = value;
var uranusDeath0 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath0 != null) uranusDeath0.troposphereLevel = value;
var uranusAtmo0 = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo0 != null) uranusAtmo0.SetLayerIntensity("Layer_Troposphere", value);
var uranusTropo0 = atmo.GetComponentInChildren<UranusTroposphereEffects>(true);
if (uranusTropo0 != null) uranusTropo0.troposphereLevel = value;
var neptuneDeath0 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath0 != null) neptuneDeath0.troposphereLevel = value;
var neptuneAtmo0 = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo0 != null) neptuneAtmo0.SetLayerIntensity("Layer_Troposphere", value);
var neptuneTropo0 = atmo.GetComponentInChildren<NeptuneTroposphereEffects>(true);
if (neptuneTropo0 != null) neptuneTropo0.troposphereLevel = value;
break;
case 1:
pd.stratosphereLevel = value;
var venusEff = atmo.GetComponentInChildren<VenusEffects>(true);
if (venusEff != null) venusEff.mesosphereLevel = value;
var venusAtmo2 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo2 != null) venusAtmo2.SetLayerIntensity("Layer_Mesosphere", value);
var venusDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath2 != null) venusDeath2.mesosphereLevel = value;
var marsAtmo2 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo2 != null) marsAtmo2.SetLayerIntensity("Layer_Mesosphere", value);
var marsMeso = atmo.GetComponentInChildren<MarsMesosphereEffects>(true);
if (marsMeso != null) marsMeso.mesosphereLevel = value;
var marsDeath1 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath1 != null) marsDeath1.mesosphereLevel = value;
var jupiterAtmo1 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo1 != null) jupiterAtmo1.SetLayerIntensity("Layer_Stratosphere", value);
var jupiterStrato1 = atmo.GetComponentInChildren<JupiterStratosphereEffects>(true);
if (jupiterStrato1 != null) jupiterStrato1.stratosphereLevel = value;
var jupiterDeath1 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath1 != null) jupiterDeath1.stratosphereLevel = value;
var saturnAtmo1 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo1 != null) saturnAtmo1.SetLayerIntensity("Layer_Stratosphere", value);
var saturnStrato1 = atmo.GetComponentInChildren<SaturnStratosphereEffects>(true);
if (saturnStrato1 != null) saturnStrato1.stratosphereLevel = value;
var saturnDeath1 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath1 != null) saturnDeath1.stratosphereLevel = value;
var uranusAtmo1 = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo1 != null) uranusAtmo1.SetLayerIntensity("Layer_Stratosphere", value);
var uranusStrato1 = atmo.GetComponentInChildren<UranusStratosphereEffects>(true);
if (uranusStrato1 != null) uranusStrato1.stratosphereLevel = value;
var uranusDeath1 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath1 != null) uranusDeath1.stratosphereLevel = value;
var neptuneAtmo1 = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo1 != null) neptuneAtmo1.SetLayerIntensity("Layer_Stratosphere", value);
var neptuneStrato1 = atmo.GetComponentInChildren<NeptuneStratosphereEffects>(true);
if (neptuneStrato1 != null) neptuneStrato1.stratosphereLevel = value;
var neptuneDeath1 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath1 != null) neptuneDeath1.stratosphereLevel = value;
break;
case 2:
pd.mesosphereLevel = value;
var venusDeath3 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<VenusDeath>();
if (venusDeath3 != null) venusDeath3.thermosphereLevel = (1f - value) * 15f;
var venusAtmo3 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo3 != null) venusAtmo3.SetLayerIntensity("Layer_Thermosphere", value);
var venusThermo = atmo.GetComponentInChildren<VenusThermosphereEffects>(true);
if (venusThermo != null) venusThermo.thermosphereLevel = (1f - value) * 15f;
var marsAtmo3 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo3 != null) marsAtmo3.SetLayerIntensity("Layer_Thermosphere", value);
var marsThermo = atmo.GetComponentInChildren<MarsThermosphereEffects>(true);
if (marsThermo != null) marsThermo.thermosphereLevel = value;
var marsDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<MarsDeath>();
if (marsDeath2 != null) marsDeath2.thermosphereLevel = value;
var jupiterAtmo2 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo2 != null) jupiterAtmo2.SetLayerIntensity("Layer_Thermosphere", value);
var jupiterThermo2 = atmo.GetComponentInChildren<JupiterThermosphereEffects>(true);
if (jupiterThermo2 != null) jupiterThermo2.thermosphereLevel = value;
var jupiterDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath2 != null) jupiterDeath2.thermosphereLevel = value;
var saturnAtmo2 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo2 != null) saturnAtmo2.SetLayerIntensity("Layer_Thermosphere", value);
var saturnThermo2 = atmo.GetComponentInChildren<SaturnThermosphereEffects>(true);
if (saturnThermo2 != null) saturnThermo2.thermosphereLevel = value;
var saturnDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath2 != null) saturnDeath2.thermosphereLevel = value;
var uranusAtmo2 = atmo.GetComponentInChildren<UranusAtmosphereSystem>(true);
if (uranusAtmo2 != null) uranusAtmo2.SetLayerIntensity("Layer_Thermosphere", value);
var uranusThermo2 = atmo.GetComponentInChildren<UranusThermosphereEffects>(true);
if (uranusThermo2 != null) uranusThermo2.thermosphereLevel = value;
var uranusDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<UranusDeath>();
if (uranusDeath2 != null) uranusDeath2.thermosphereLevel = value;
var neptuneAtmo2 = atmo.GetComponentInChildren<NeptuneAtmosphereSystem>(true);
if (neptuneAtmo2 != null) neptuneAtmo2.SetLayerIntensity("Layer_Thermosphere", value);
var neptuneThermo2 = atmo.GetComponentInChildren<NeptuneThermosphereEffects>(true);
if (neptuneThermo2 != null) neptuneThermo2.thermosphereLevel = value;
var neptuneDeath2 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<NeptuneDeath>();
if (neptuneDeath2 != null) neptuneDeath2.thermosphereLevel = value;
break;
case 3:
pd.thermosphereLevel = value;
var thermo = atmo.GetComponentInChildren<ThermosphereEffects>(true);
if (thermo != null) thermo.thermosphereLevel = value;
var venusExo = atmo.GetComponentInChildren<VenusExosphereEffects>(true);
if (venusExo != null) venusExo.exosphereLevel = value;
var venusAtmo4 = atmo.GetComponentInChildren<VenusAtmosphereSystem>(true);
if (venusAtmo4 != null) venusAtmo4.SetLayerIntensity("Layer_Exosphere", value);
var marsAtmo4 = atmo.GetComponentInChildren<MarsAtmosphereSystem>(true);
if (marsAtmo4 != null) marsAtmo4.SetLayerIntensity("Layer_Exosphere", value);
var marsExo = atmo.GetComponentInChildren<MarsExosphereEffects>(true);
if (marsExo != null)
{
if (!marsExo.enabled)
{
marsExo.enabled = true;
marsExo.InitState();
}
marsExo.exosphereLevel = value;
}
var marsDeathExo = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<MarsDeath>();
if (marsDeathExo != null)
{
if (value <= 0f) marsDeathExo.mesosphereLevel = 0f;
else marsDeathExo.ResetTexture();
}
var jupiterAtmo3 = atmo.GetComponentInChildren<JupiterAtmosphereSystem>(true);
if (jupiterAtmo3 != null) jupiterAtmo3.SetLayerIntensity("Layer_Exosphere", value);
var jupiterExo3 = atmo.GetComponentInChildren<JupiterExosphereEffects>(true);
if (jupiterExo3 != null) jupiterExo3.exosphereLevel = value;
var jupiterDeath3 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<JupiterDeath>();
if (jupiterDeath3 != null) jupiterDeath3.exosphereLevel = value;
var saturnAtmo3 = atmo.GetComponentInChildren<SaturnAtmosphereSystem>(true);
if (saturnAtmo3 != null) saturnAtmo3.SetLayerIntensity("Layer_Exosphere", value);
var saturnExo3 = atmo.GetComponentInChildren<SaturnExosphereEffects>(true);
if (saturnExo3 != null) saturnExo3.exosphereLevel = value;
var saturnDeath3 = GameManager.Instance.GetCurrentPlanet()
.planetTransform?.GetComponent<SaturnDeath>();
if (saturnDeath3 != null) saturnDeath3.exosphereLevel = value;
break;
case 4:
pd.exosphereLevel = value;
break;
}
}
void UpdateUI()
{
if (currentPlanetInfo?.layers == null) return;
if (currentLayerIndex >= currentPlanetInfo.layers.Length) return;
var layer = currentPlanetInfo.layers[currentLayerIndex];
if (layerNameText != null)
layerNameText.text = layer.name;
if (layerInfoText != null)
layerInfoText.text = layer.description;
if (percentageText != null)
percentageText.text = "³äñîòêè: 100%";
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee5cf1b4a7a00a24d8c82ce3a0be0734
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,303 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StratosphereDeath : MonoBehaviour
{
[Header("Çâ'ÿçêè")]
public StratosphereEffects stratosphereEffects;
public PlanetDeath planetDeath;
[Header("Ïîæåæ³")]
public GameObject firePrefab;
public int maxFires = 50;
public float fireRadius = 6.4f;
[Header("Ñòàí")]
[Range(0f, 1f)]
public float stratosphereLevel = 1f;
private List<GameObject> activeFires = new List<GameObject>();
private List<GameObject> godRays = new List<GameObject>();
public bool planesStartedFalling = false;
public bool pearlCloudsGone = false;
private float previousLevel = 1f;
void Start()
{
StartCoroutine(CollectGodRaysDelayed());
}
IEnumerator CollectGodRaysDelayed()
{
yield return new WaitForSeconds(2f);
CollectGodRays();
}
void CollectGodRays()
{
godRays.Clear();
if (stratosphereEffects == null) return;
foreach (Transform child in stratosphereEffects.transform)
{
if (child.name.StartsWith("GodRay_"))
godRays.Add(child.gameObject);
}
}
void Update()
{
if (!Application.isPlaying) return;
if (godRays.Count == 0)
CollectGodRays();
UpdatePearlClouds();
UpdateGodRays();
UpdatePlanes();
UpdateFires();
UpdatePlanetTexture();
previousLevel = stratosphereLevel;
}
void UpdatePearlClouds()
{
if (stratosphereEffects == null) return;
if (stratosphereLevel < 0.7f && !pearlCloudsGone)
{
pearlCloudsGone = true;
foreach (Transform child in stratosphereEffects.transform)
{
if (child.name.StartsWith("PearlCloud_"))
StartCoroutine(FadeOutAndDestroy(child.gameObject, 3f));
}
}
if (stratosphereLevel >= 0.7f && pearlCloudsGone)
{
pearlCloudsGone = false;
stratosphereEffects.SpawnPearlClouds();
}
}
void UpdateGodRays()
{
foreach (GameObject ray in godRays)
{
if (ray == null) continue;
ParticleSystem ps = ray.GetComponent<ParticleSystem>();
if (ps == null) continue;
var main = ps.main;
if (stratosphereLevel >= 0.7f)
{
main.startColor = new Color(1f, 0.95f, 0.6f, 0.2f);
ray.transform.localScale = new Vector3(0.2f, 0.2f, 0.8f);
}
else if (stratosphereLevel >= 0.5f)
{
float t = Mathf.InverseLerp(0.7f, 0.5f, stratosphereLevel);
main.startColor = new Color(1f, 0.95f, 0.6f, Mathf.Lerp(0.2f, 0.6f, t));
ray.transform.localScale = new Vector3(
Mathf.Lerp(0.2f, 0.4f, t),
Mathf.Lerp(0.2f, 0.4f, t),
Mathf.Lerp(0.8f, 2f, t)
);
}
else
{
float t = Mathf.InverseLerp(0.5f, 0f, stratosphereLevel);
main.startColor = new Color(1f, 0.85f, 0.4f, Mathf.Lerp(0.6f, 1f, t));
ray.transform.localScale = new Vector3(
Mathf.Lerp(0.4f, 0.7f, t),
Mathf.Lerp(0.4f, 0.7f, t),
Mathf.Lerp(2f, 4f, t)
);
}
}
}
void UpdatePlanes()
{
if (stratosphereEffects == null) return;
if (stratosphereLevel >= 1f && planesStartedFalling)
{
ResetState();
return;
}
if (stratosphereLevel <= 0.3f && !planesStartedFalling)
{
planesStartedFalling = true;
StartCoroutine(DropPlanesSequentially());
}
}
IEnumerator DropPlanesSequentially()
{
List<Transform> planes = new List<Transform>();
foreach (Transform child in stratosphereEffects.transform)
{
if (child.name.StartsWith("Plane_"))
planes.Add(child);
}
foreach (Transform plane in planes)
{
if (plane == null) continue;
yield return new WaitForSeconds(Random.Range(0.2f, 0.8f));
StartCoroutine(DropPlane(plane));
}
}
IEnumerator DropPlane(Transform plane)
{
float elapsed = 0f;
Vector3 fallDir = (Vector3.zero - plane.position).normalized;
float fallSpeed = Random.Range(3f, 6f);
while (elapsed < 3f && plane != null)
{
plane.position += fallDir * fallSpeed * Time.deltaTime;
plane.Rotate(Random.insideUnitSphere * 50f * Time.deltaTime);
elapsed += Time.deltaTime;
yield return null;
}
if (plane != null)
{
SpawnFire(plane.position);
Destroy(plane.gameObject);
}
}
void UpdateFires()
{
activeFires.RemoveAll(f => f == null);
if (stratosphereLevel < 0.7f && stratosphereLevel > 0.1f)
{
int targetFires = Mathf.RoundToInt(Mathf.Lerp(0, maxFires, Mathf.InverseLerp(0.7f, 0.3f, stratosphereLevel)));
if (activeFires.Count < targetFires && Random.value < 0.15f)
SpawnFire(transform.position + Random.onUnitSphere * fireRadius);
}
else if (stratosphereLevel <= 0.1f)
{
foreach (GameObject fire in activeFires)
{
if (fire != null) StartCoroutine(FadeOutAndDestroy(fire, 2f));
}
activeFires.Clear();
}
}
void SpawnFire(Vector3 position)
{
if (firePrefab == null) return;
Vector3 dirFromCenter = (position - transform.position).normalized;
Vector3 surfacePos = transform.position + dirFromCenter * fireRadius;
Quaternion fireRot = Quaternion.FromToRotation(Vector3.up, dirFromCenter);
GameObject fire = Instantiate(firePrefab, surfacePos, fireRot);
fire.transform.localScale = Vector3.one * Random.Range(0.1f, 0.3f);
activeFires.Add(fire);
StartCoroutine(AutoDestroyFire(fire, Random.Range(8f, 15f)));
}
public void TriggerPlanesDown()
{
if (!planesStartedFalling)
{
planesStartedFalling = true;
StartCoroutine(DropPlanesSequentially());
}
}
public void InitState()
{
ResetState();
StartCoroutine(RespawnAfterInit());
}
IEnumerator RespawnAfterInit()
{
yield return null;
if (stratosphereEffects != null)
{
stratosphereEffects.SpawnPlanes();
stratosphereEffects.SpawnPearlClouds();
}
yield return new WaitForSeconds(0.5f);
CollectGodRays();
}
public void ResetState()
{
StopAllCoroutines();
planesStartedFalling = false;
pearlCloudsGone = false;
foreach (GameObject fire in activeFires)
if (fire != null) Destroy(fire);
activeFires.Clear();
if (stratosphereEffects != null)
{
foreach (Transform child in stratosphereEffects.transform)
{
if (child.name.StartsWith("Plane_"))
Destroy(child.gameObject);
if (child.name.StartsWith("PearlCloud_"))
Destroy(child.gameObject);
}
}
godRays.Clear();
stratosphereLevel = 1f;
}
IEnumerator RespawnAfterReset()
{
yield return null;
stratosphereEffects.SpawnPlanes();
stratosphereEffects.SpawnPearlClouds();
yield return new WaitForSeconds(0.5f);
CollectGodRays();
}
IEnumerator AutoDestroyFire(GameObject fire, float delay)
{
yield return new WaitForSeconds(delay);
if (fire != null)
{
activeFires.Remove(fire);
StartCoroutine(FadeOutAndDestroy(fire, 2f));
}
}
IEnumerator FadeOutAndDestroy(GameObject obj, float duration)
{
float elapsed = 0f;
while (elapsed < duration && obj != null)
{
elapsed += Time.deltaTime;
yield return null;
}
if (obj != null) Destroy(obj);
}
void UpdatePlanetTexture()
{
if (planetDeath == null) return;
planetDeath.stratosphereLevel = stratosphereLevel;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ed956d9e9bd5ac84c9d307a43b0910d5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,179 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StratosphereEffects : MonoBehaviour
{
[Header("˳òàêè")]
public GameObject planePrefab;
public int planeCount = 15;
public float planeOrbitRadius = 8.0f;
public float planeMinSpeed = 15f;
public float planeMaxSpeed = 25f;
public float planeScale = 0.003f;
[Header("Ïåðëàìóòðîâ³ õìàðè")]
public Material pearlCloudMaterial;
public int pearlCloudGroupCount = 10;
public float pearlCloudRadius = 8.3f;
[Header("UV ïðîìåí³")]
public GameObject godRayPrefab;
public int rayCount = 5;
public float rayDistance = 12f;
public Transform sunTransform;
private List<PlaneData> planes = new List<PlaneData>();
private List<ParticleSystem> pearlClouds = new List<ParticleSystem>();
private class PlaneData
{
public Transform transform;
public Vector3 orbitAxis;
public float orbitSpeed;
public float orbitAngle;
}
void Start()
{
SpawnPlanes();
SpawnPearlClouds();
SpawnGodRays();
}
public void SpawnPlanes()
{
if (planePrefab == null) return;
for (int i = 0; i < planeCount; i++)
{
GameObject plane = Instantiate(planePrefab, this.transform);
plane.name = "Plane_" + i;
plane.transform.localScale = Vector3.one * planeScale;
Vector3 axis = Random.onUnitSphere;
float angle = Random.Range(0f, 360f);
Vector3 startPos = GetOrbitPosition(axis, angle);
plane.transform.position = startPos;
planes.Add(new PlaneData
{
transform = plane.transform,
orbitAxis = axis,
orbitSpeed = Random.Range(planeMinSpeed, planeMaxSpeed),
orbitAngle = angle
});
}
}
public void SpawnPearlClouds()
{
for (int i = 0; i < pearlCloudGroupCount; i++)
{
Vector3 groupCenter = this.transform.position + Random.onUnitSphere * pearlCloudRadius;
GameObject obj = new GameObject("PearlCloud_" + i);
obj.transform.parent = this.transform;
obj.transform.position = groupCenter;
ParticleSystem ps = obj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = false;
main.playOnAwake = true;
main.maxParticles = 12;
main.startLifetime = 999f;
main.startSpeed = 0f;
main.startSize = new ParticleSystem.MinMaxCurve(0.4f, 0.9f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(1f, 0.6f, 0.85f, 0.6f),
new Color(0.85f, 0.5f, 0.9f, 0.45f)
);
main.simulationSpace = ParticleSystemSimulationSpace.Local;
var emission = ps.emission;
emission.rateOverTime = 0f;
emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0f, 12) });
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = 0.5f;
shape.radiusThickness = 1f;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = -8f;
if (pearlCloudMaterial != null)
renderer.material = pearlCloudMaterial;
ps.Play();
pearlClouds.Add(ps);
}
}
void SpawnGodRays()
{
if (godRayPrefab == null) return;
for (int i = 0; i < rayCount; i++)
{
float spreadX = Random.Range(-2f, 2f);
float spreadY = Random.Range(-2f, 2f);
Vector3 spawnPos = this.transform.position
+ new Vector3(0.19f, -0.21f, -0.51f) * rayDistance
+ Vector3.up * spreadY
+ Vector3.right * spreadX;
GameObject ray = Instantiate(godRayPrefab, this.transform);
ray.name = "GodRay_" + i;
ray.transform.position = spawnPos;
ray.transform.rotation = Quaternion.Euler(90f, 0f, 189f);
ray.transform.localScale = new Vector3(0.3f, 0.3f, 1f);
}
}
Vector3 GetOrbitPosition(Vector3 axis, float angle)
{
Vector3 perpendicular = Vector3.Cross(axis, Vector3.up).normalized;
if (perpendicular.magnitude < 0.01f)
perpendicular = Vector3.Cross(axis, Vector3.right).normalized;
Quaternion rot = Quaternion.AngleAxis(angle, axis);
return this.transform.position + rot * perpendicular * planeOrbitRadius;
}
void Awake()
{
enabled = false;
}
void Update()
{
if (!Application.isPlaying) return;
foreach (PlaneData p in planes)
{
if (p.transform == null) continue;
p.orbitAngle += p.orbitSpeed * Time.deltaTime;
Vector3 newPos = GetOrbitPosition(p.orbitAxis, p.orbitAngle);
Vector3 direction = (newPos - p.transform.position).normalized;
p.transform.position = newPos;
if (direction != Vector3.zero)
p.transform.rotation = Quaternion.LookRotation(direction, p.transform.position - this.transform.position);
}
Quaternion pearlRotation = Quaternion.AngleAxis(2f * Time.deltaTime, Vector3.up);
foreach (ParticleSystem ps in pearlClouds)
{
if (ps == null) continue;
ps.transform.position = this.transform.position + pearlRotation * (ps.transform.position - this.transform.position);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 455ce78e11ffac343b45b08891f5c614
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,241 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThermosphereEffects : MonoBehaviour
{
[Header("ÌÊÑ")]
public GameObject issPrefab;
public float issOrbitRadius = 32f;
public float issOrbitSpeed = 20f;
public int issCount = 6;
public StratosphereDeath stratosphereDeath;
[Header("Ïîëÿðíå ñÿéâî")]
public GameObject auroraPrefab;
public float auroraRadius = 9.2f;
[Header("Âèáóõ ïðè ïàä³íí³")]
public GameObject explosionPrefab;
[Range(0f, 1f)]
public float thermosphereLevel = 1f;
private float previousLevel = 1f;
private class SatelliteData
{
public Transform transform;
public Vector3 orbitAxis;
public float orbitAngle;
public float orbitSpeed;
public bool isFalling;
}
private List<SatelliteData> satellites = new List<SatelliteData>();
private GameObject auroraNorth;
private GameObject auroraSouth;
void Awake()
{
enabled = false;
}
void SpawnISS()
{
if (issPrefab == null) return;
for (int i = 0; i < issCount; i++)
{
Vector3 axis = Random.onUnitSphere;
float angle = Random.Range(0f, 360f);
GameObject sat = Instantiate(issPrefab, this.transform);
sat.name = "Satellite_" + i;
sat.transform.localScale = Vector3.one * 0.002f;
Vector3 perpendicular = Vector3.Cross(axis, Vector3.up).normalized;
if (perpendicular.magnitude < 0.01f)
perpendicular = Vector3.Cross(axis, Vector3.right).normalized;
Quaternion rot = Quaternion.AngleAxis(angle, axis);
sat.transform.position = this.transform.position + rot * perpendicular * issOrbitRadius;
satellites.Add(new SatelliteData
{
transform = sat.transform,
orbitAxis = axis,
orbitAngle = angle,
orbitSpeed = Random.Range(15f, 25f),
isFalling = false
});
StartCoroutine(RotateSolarPanels(sat));
}
}
IEnumerator RotateSolarPanels(GameObject sat)
{
while (sat != null)
{
Transform panel1 = sat.transform.Find("solar_plane");
Transform panel2 = sat.transform.Find("solar_plane1");
if (panel1 != null) panel1.Rotate(Vector3.right * 10f * Time.deltaTime);
if (panel2 != null) panel2.Rotate(Vector3.right * 10f * Time.deltaTime);
yield return null;
}
}
void SpawnAurora()
{
if (auroraPrefab == null) return;
Vector3 center = this.transform.position;
auroraNorth = Instantiate(auroraPrefab, this.transform);
auroraNorth.name = "AuroraNorth";
auroraNorth.transform.position = center + Vector3.up * auroraRadius * 0.8f;
auroraNorth.transform.rotation = Quaternion.identity;
auroraNorth.transform.localScale = Vector3.one * 0.5f;
auroraSouth = Instantiate(auroraPrefab, this.transform);
auroraSouth.name = "AuroraSouth";
auroraSouth.transform.position = center + Vector3.down * auroraRadius * 0.8f;
auroraSouth.transform.rotation = Quaternion.Euler(180f, 0f, 0f);
auroraSouth.transform.localScale = Vector3.one * 0.5f;
}
public void InitState()
{
foreach (SatelliteData sat in satellites)
if (sat.transform != null) Destroy(sat.transform.gameObject);
satellites.Clear();
if (auroraNorth != null) Destroy(auroraNorth);
if (auroraSouth != null) Destroy(auroraSouth);
auroraNorth = null;
auroraSouth = null;
thermosphereLevel = 1f;
previousLevel = 1f;
}
public void InitStateAndSpawn()
{
InitState();
if (gameObject.activeInHierarchy)
StartCoroutine(SpawnDelayed());
}
IEnumerator SpawnDelayed()
{
yield return null;
SpawnISS();
SpawnAurora();
}
public void DropAllSatellites()
{
foreach (SatelliteData sat in satellites)
{
if (sat.transform != null && !sat.isFalling)
{
sat.isFalling = true;
StartCoroutine(SatelliteFall(sat));
}
}
}
void Update()
{
if (!Application.isPlaying) return;
if (thermosphereLevel >= 1f && previousLevel < 1f)
InitStateAndSpawn();
previousLevel = thermosphereLevel;
UpdateSatellites();
UpdateAurora();
}
void UpdateSatellites()
{
bool shouldFall = thermosphereLevel <= 0.3f;
bool shouldDrift = thermosphereLevel <= 0.5f && thermosphereLevel > 0.3f;
if (shouldFall && stratosphereDeath != null)
stratosphereDeath.TriggerPlanesDown();
foreach (SatelliteData sat in satellites)
{
if (sat.transform == null || sat.isFalling) continue;
sat.orbitAngle += sat.orbitSpeed * Time.deltaTime;
if (shouldDrift)
sat.orbitAngle += Random.Range(-2f, 2f) * Time.deltaTime;
Vector3 perpendicular = Vector3.Cross(sat.orbitAxis, Vector3.up).normalized;
if (perpendicular.magnitude < 0.01f)
perpendicular = Vector3.Cross(sat.orbitAxis, Vector3.right).normalized;
Quaternion rot = Quaternion.AngleAxis(sat.orbitAngle, sat.orbitAxis);
Vector3 newPos = this.transform.position + rot * perpendicular * issOrbitRadius;
Vector3 direction = (newPos - sat.transform.position).normalized;
sat.transform.position = newPos;
if (direction != Vector3.zero)
sat.transform.rotation = Quaternion.LookRotation(direction, sat.transform.position - this.transform.position);
if (shouldFall)
{
sat.isFalling = true;
StartCoroutine(SatelliteFall(sat));
}
}
}
IEnumerator SatelliteFall(SatelliteData sat)
{
float elapsed = 0f;
float fallSpeed = 3f;
while (elapsed < 5f && sat.transform != null)
{
Vector3 fallDir = (this.transform.position - sat.transform.position).normalized;
sat.transform.position += fallDir * fallSpeed * Time.deltaTime;
sat.transform.Rotate(Random.insideUnitSphere * 40f * Time.deltaTime);
fallSpeed += 2f * Time.deltaTime;
elapsed += Time.deltaTime;
yield return null;
}
if (sat.transform != null)
{
if (explosionPrefab != null)
{
GameObject exp = Instantiate(explosionPrefab, sat.transform.position, Quaternion.identity);
exp.transform.localScale = Vector3.one * 0.4f;
Destroy(exp, 4f);
}
Destroy(sat.transform.gameObject);
}
}
void UpdateAurora()
{
bool auroraActive = thermosphereLevel > 0.3f;
if (auroraNorth != null) auroraNorth.SetActive(auroraActive);
if (auroraSouth != null) auroraSouth.SetActive(auroraActive);
}
public void SetThermosphereLevel(float level)
{
thermosphereLevel = level;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ed76d6d42738954a9b628e04b318a86
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,357 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TroposphereEffects : MonoBehaviour
{
[Header("Ìàòåð³àëè õìàð")]
public Material[] cloudMaterials;
[Header("Äîù")]
public GameObject rainPrefab;
[Header("Õìàðè")]
public int cloudGroupCount = 20;
public int particlesPerCloud = 4;
public float cloudGroupSpread = 0.4f;
public float cloudMinSize = 0.8f;
public float cloudMaxSize = 1.8f;
public float cloudOrbitSpeed = 0.5f;
[Header("Äîùîâ³ õìàðè")]
public int rainCloudGroupCount = 5;
public float rainDuration = 15f;
public float rainPause = 10f;
private float cloudRadius;
private Vector3 planetCenter;
[Header("Òóìàí")]
public Material fogMaterial;
private class RainCloud
{
public List<CloudPuff> puffs = new List<CloudPuff>();
public GameObject rainInstance;
public GameObject fogInstance;
public float timer;
public bool isRaining;
public bool isFogging;
public Vector3 position;
}
private class CloudPuff
{
public Transform transform;
public float orbitSpeed;
public Vector3 orbitAxis;
}
private List<CloudPuff> cloudPuffs = new List<CloudPuff>();
private List<RainCloud> rainClouds = new List<RainCloud>();
private Transform cloudRoot;
void Start()
{
planetCenter = this.transform.position;
cloudRadius = this.transform.lossyScale.x * 0.5f * 0.95f;
SpawnCloudGroups();
SpawnRainClouds();
}
void SpawnCloudGroups()
{
cloudRoot = new GameObject("CloudParticles").transform;
cloudRoot.parent = this.transform;
cloudRoot.localPosition = Vector3.zero;
for (int i = 0; i < cloudGroupCount; i++)
{
Vector3 groupCenter = planetCenter + Random.onUnitSphere * cloudRadius;
Vector3 toCenter = (planetCenter - groupCenter).normalized;
Vector3 axis = Quaternion.AngleAxis(Random.Range(-20f, 20f), Random.onUnitSphere) * Vector3.up;
float speed = cloudOrbitSpeed * Random.Range(0.7f, 1.3f);
for (int j = 0; j < particlesPerCloud; j++)
{
Vector3 pos = groupCenter + (Vector3)Random.insideUnitSphere * cloudGroupSpread;
CloudPuff puff = CreateCloudPuff(cloudRoot, pos, toCenter, axis, speed, false, i);
cloudPuffs.Add(puff);
}
}
}
GameObject CreateFog(Vector3 position)
{
GameObject fogObj = new GameObject("Fog");
fogObj.transform.parent = cloudRoot;
fogObj.transform.position = position;
ParticleSystem ps = fogObj.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.playOnAwake = true;
main.maxParticles = 80;
main.startLifetime = new ParticleSystem.MinMaxCurve(10f, 16f);
main.startSpeed = new ParticleSystem.MinMaxCurve(0.03f, 0.08f);
main.startSize = new ParticleSystem.MinMaxCurve(0.2f, 0.6f);
main.startColor = new ParticleSystem.MinMaxGradient(
new Color(0.88f, 0.92f, 0.95f, 0.18f),
new Color(0.95f, 0.97f, 1f, 0.09f)
);
main.startRotation = new ParticleSystem.MinMaxCurve(0f, 360f * Mathf.Deg2Rad);
main.simulationSpace = ParticleSystemSimulationSpace.World;
var emission = ps.emission;
emission.rateOverTime = 8f;
var shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = cloudGroupSpread * 2.5f;
shape.radiusThickness = 1f;
var velocityOverLifetime = ps.velocityOverLifetime;
velocityOverLifetime.enabled = true;
velocityOverLifetime.space = ParticleSystemSimulationSpace.World;
Vector3 tangent = Vector3.Cross((planetCenter - position).normalized, Vector3.up).normalized;
velocityOverLifetime.x = new ParticleSystem.MinMaxCurve(tangent.x * 0.08f - 0.04f, tangent.x * 0.08f + 0.04f);
velocityOverLifetime.y = new ParticleSystem.MinMaxCurve(-0.01f, 0.01f);
velocityOverLifetime.z = new ParticleSystem.MinMaxCurve(tangent.z * 0.08f - 0.04f, tangent.z * 0.08f + 0.04f);
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
AnimationCurve curve = new AnimationCurve();
curve.AddKey(0f, 0f);
curve.AddKey(0.15f, 1f);
curve.AddKey(0.75f, 0.85f);
curve.AddKey(1f, 0f);
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, curve);
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient gradient = new Gradient();
gradient.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(0.88f, 0.92f, 0.95f), 0f),
new GradientColorKey(new Color(0.95f, 0.97f, 1f), 0.5f),
new GradientColorKey(new Color(0.88f, 0.92f, 0.95f), 1f)
},
new GradientAlphaKey[] {
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(0.18f, 0.2f),
new GradientAlphaKey(0.12f, 0.7f),
new GradientAlphaKey(0f, 1f)
}
);
colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient);
var rotationOverLifetime = ps.rotationOverLifetime;
rotationOverLifetime.enabled = true;
rotationOverLifetime.z = new ParticleSystem.MinMaxCurve(-0.2f, 0.2f);
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = -3f;
if (fogMaterial != null)
renderer.material = fogMaterial;
ps.Play();
return fogObj;
}
void SpawnRainClouds()
{
for (int i = 0; i < rainCloudGroupCount; i++)
{
RainCloud rc = CreateRainCloud();
rainClouds.Add(rc);
}
}
RainCloud CreateRainCloud()
{
RainCloud rc = new RainCloud();
rc.position = planetCenter + Random.onUnitSphere * cloudRadius;
rc.timer = Random.Range(0f, rainDuration);
rc.isRaining = true;
Vector3 toCenter = (planetCenter - rc.position).normalized;
Vector3 axis = Quaternion.AngleAxis(Random.Range(-20f, 20f), Random.onUnitSphere) * Vector3.up;
float speed = cloudOrbitSpeed * Random.Range(0.6f, 1.0f);
for (int j = 0; j < particlesPerCloud; j++)
{
Vector3 pos = rc.position + (Vector3)Random.insideUnitSphere * cloudGroupSpread;
CloudPuff puff = CreateCloudPuff(cloudRoot, pos, toCenter, axis, speed, true, j);
rc.puffs.Add(puff);
cloudPuffs.Add(puff);
}
if (rainPrefab != null)
{
Vector3 dirToCenter = (planetCenter - rc.position).normalized;
Vector3 rainPos = rc.position + dirToCenter * (cloudGroupSpread + 0.9f);
rc.rainInstance = Instantiate(rainPrefab, rainPos, Quaternion.identity);
rc.rainInstance.transform.parent = cloudRoot;
rc.rainInstance.transform.localScale = Vector3.one * 0.5f;
RainDirector director = rc.rainInstance.AddComponent<RainDirector>();
director.planetCenter = planetCenter;
}
return rc;
}
CloudPuff CreateCloudPuff(Transform parent, Vector3 pos, Vector3 toCenter, Vector3 axis, float speed, bool dark, int texIndex)
{
ParticleSystem ps = new GameObject("CloudPuff").AddComponent<ParticleSystem>();
ps.transform.parent = parent;
ps.transform.position = pos;
var main = ps.main;
main.loop = false;
main.playOnAwake = true;
main.maxParticles = 1;
main.startLifetime = 999f;
main.startSpeed = 0f;
main.startSize = Random.Range(cloudMinSize, cloudMaxSize);
main.startColor = dark
? new Color(Random.Range(0.1f, 0.3f), Random.Range(0.1f, 0.3f), Random.Range(0.1f, 0.3f), Random.Range(0.7f, 0.9f))
: new Color(Random.Range(0.88f, 1f), Random.Range(0.88f, 1f), 1f, Random.Range(0.55f, 0.8f));
main.simulationSpace = ParticleSystemSimulationSpace.Local;
var emission = ps.emission;
emission.rateOverTime = 0f;
emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0f, 1) });
var shape = ps.shape;
shape.enabled = false;
var renderer = ps.GetComponent<ParticleSystemRenderer>();
renderer.renderMode = ParticleSystemRenderMode.Billboard;
renderer.sortingFudge = -10f;
if (cloudMaterials != null && cloudMaterials.Length > 0)
{
renderer.material = cloudMaterials[texIndex % cloudMaterials.Length];
}
else
{
Material mat = new Material(Shader.Find("Universal Render Pipeline/Particles/Unlit"));
mat.SetFloat("_Surface", 1f);
mat.SetFloat("_Blend", 0f);
mat.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
mat.renderQueue = 3001;
mat.SetColor("_BaseColor", main.startColor.color);
renderer.material = mat;
}
ps.Play();
return new CloudPuff
{
transform = ps.transform,
orbitSpeed = speed,
orbitAxis = axis
};
}
void Update()
{
if (!Application.isPlaying) return;
Quaternion globalRotation = Quaternion.AngleAxis(cloudOrbitSpeed * Time.deltaTime, Vector3.up);
foreach (CloudPuff puff in cloudPuffs)
{
if (puff.transform == null) continue;
puff.transform.position = planetCenter + globalRotation * (puff.transform.position - planetCenter);
}
for (int i = 0; i < rainClouds.Count; i++)
{
RainCloud rc = rainClouds[i];
rc.timer -= Time.deltaTime;
if (rc.isRaining && rc.timer <= 0f)
{
if (rc.rainInstance != null)
Destroy(rc.rainInstance);
rc.isRaining = false;
rc.isFogging = true;
rc.timer = 20f;
Vector3 fogPos = rc.position + (planetCenter - rc.position).normalized * cloudGroupSpread * 1.5f;
rc.fogInstance = CreateFog(fogPos);
}
else if (rc.isFogging && rc.timer <= 0f)
{
if (rc.fogInstance != null)
Destroy(rc.fogInstance);
rc.isFogging = false;
rc.timer = rainPause;
foreach (CloudPuff puff in rc.puffs)
{
if (puff.transform != null)
Destroy(puff.transform.gameObject);
cloudPuffs.Remove(puff);
}
}
else if (!rc.isRaining && !rc.isFogging && rc.timer <= 0f)
{
foreach (CloudPuff puff in rc.puffs)
cloudPuffs.Remove(puff);
rainClouds[i] = CreateRainCloud();
}
if (rc.rainInstance != null)
rc.rainInstance.transform.position = planetCenter +
globalRotation * (rc.rainInstance.transform.position - planetCenter);
if (rc.fogInstance != null)
rc.fogInstance.transform.position = planetCenter +
globalRotation * (rc.fogInstance.transform.position - planetCenter);
}
}
void DestroyRainCloud(RainCloud rc)
{
if (rc.rainInstance != null)
Destroy(rc.rainInstance);
foreach (CloudPuff puff in rc.puffs)
{
if (puff.transform != null)
Destroy(puff.transform.gameObject);
}
}
public void SetRainEnabled(bool enabled)
{
foreach (RainCloud rc in rainClouds)
{
if (rc.rainInstance != null)
rc.rainInstance.SetActive(enabled);
}
}
public void SetCloudsEnabled(bool enabled)
{
if (cloudRoot != null)
cloudRoot.gameObject.SetActive(enabled);
}
void Awake()
{
enabled = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d85fb363a3031bd47aa4d1e0361cc728
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,143 @@
using UnityEngine;
[ExecuteAlways]
public class UranusAtmosphereSystem : MonoBehaviour
{
public float uranusRadiusUnits = 7.1492f;
public float heightMultiplier = 8f;
[Header("Òåêñòóðè")]
public Texture2D uranusTexture1;
public Texture2D uranusTexture2;
void OnEnable()
{
if (!Application.isPlaying && transform.childCount == 0)
BuildLayers();
}
[ContextMenu("Ïåðåáóäóâàòè øàðè")]
public void BuildLayers()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Transform child = transform.GetChild(i);
if (child.name.StartsWith("Layer_"))
{
if (Application.isPlaying) Destroy(child.gameObject);
else DestroyImmediate(child.gameObject);
}
}
CreateTextureLayer("Layer_Troposphere", 300f,
new Color(0.3f, 0.85f, 0.9f),
new Color(0.1f, 0.55f, 0.65f),
2.5f, 0.7f, 0.008f, -0.005f);
CreateSimpleLayer("Layer_Stratosphere", 600f,
new Color(0.85f, 0.75f, 0.3f),
new Color(0.6f, 0.5f, 0.15f),
1.2f, 0.35f);
CreateSimpleLayer("Layer_Thermosphere", 900f,
new Color(0.5f, 0.3f, 1f),
new Color(0.25f, 0.1f, 0.7f),
0.9f, 0.2f);
}
void CreateTextureLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity,
float scrollSpeed1, float scrollSpeed2)
{
float radiusUnits = uranusRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/JupiterAtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_ScrollSpeed1", scrollSpeed1);
mat.SetFloat("_ScrollSpeed2", scrollSpeed2);
mat.SetFloat("_PulseSpeed", 0.2f);
mat.SetFloat("_PulseStrength", 0.08f);
mat.SetFloat("_TextureBlend", 0.4f);
mat.SetFloat("_TextureInfluence", 0.4f);
if (uranusTexture1 != null) mat.SetTexture("_MainTex", uranusTexture1);
if (uranusTexture2 != null) mat.SetTexture("_SecondTex", uranusTexture2);
obj.GetComponent<Renderer>().material = mat;
}
void CreateSimpleLayer(string layerName, float heightKm,
Color rimColor, Color coreColor,
float rimIntensity, float coreIntensity)
{
float radiusUnits = uranusRadiusUnits + (heightKm / 1000f) * heightMultiplier;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
obj.name = layerName;
obj.transform.parent = this.transform;
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one * radiusUnits * 2f;
if (Application.isPlaying) Destroy(obj.GetComponent<Collider>());
else DestroyImmediate(obj.GetComponent<Collider>());
Material mat = new Material(Shader.Find("Custom/AtmosphereLayer"));
mat.SetColor("_RimColor", rimColor);
mat.SetColor("_CoreColor", coreColor);
mat.SetFloat("_RimPower", 2.0f);
mat.SetFloat("_RimIntensity", rimIntensity);
mat.SetFloat("_CoreIntensity", coreIntensity);
mat.SetFloat("_PulseSpeed", 0.2f);
mat.SetFloat("_PulseStrength", 0.08f);
obj.GetComponent<Renderer>().material = mat;
}
public void SetLayerIntensity(string layerName, float level)
{
Transform layer = transform.Find(layerName);
if (layer == null) return;
Renderer r = layer.GetComponent<Renderer>();
if (r == null) return;
float rimBase = 0f;
float coreBase = 0f;
switch (layerName)
{
case "Layer_Troposphere": rimBase = 2.5f; coreBase = 0.7f; break;
case "Layer_Stratosphere": rimBase = 1.2f; coreBase = 0.35f; break;
case "Layer_Thermosphere": rimBase = 0.9f; coreBase = 0.2f; break;
}
r.material.SetFloat("_RimIntensity", Mathf.Lerp(0f, rimBase, level));
r.material.SetFloat("_CoreIntensity", Mathf.Lerp(0f, coreBase, level));
}
public void SetLayerActive(string layerName, bool active)
{
Transform layer = transform.Find(layerName);
if (layer != null) layer.gameObject.SetActive(active);
}
public void SetIntensity(float level)
{
SetLayerIntensity("Layer_Troposphere", level);
SetLayerIntensity("Layer_Stratosphere", level);
SetLayerIntensity("Layer_Thermosphere", level);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0747fd26d8f56d14e9315bf5b5d073cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UranusDeath : MonoBehaviour
{
[Header("Òåêñòóðè òðîïîñôåðè")]
public Texture2D tropo100;
public Texture2D tropo70;
public Texture2D tropo50;
public Texture2D tropo30;
public Texture2D tropo0;
public Texture2D deadTexture;
[Range(0f, 1f)]
public float troposphereLevel = 1f;
public float stratosphereLevel = 1f;
public float thermosphereLevel = 1f;
private Renderer _planetRenderer;
private Material _planetMat;
private Texture2D _originalTexture;
void Start()
{
_planetRenderer = GetComponent<Renderer>();
if (_planetRenderer == null)
_planetRenderer = GetComponentInChildren<Renderer>();
if (_planetRenderer != null)
{
_planetMat = _planetRenderer.material;
_originalTexture = (Texture2D)_planetMat.GetTexture("_BaseMap");
}
}
public void ResetTexture()
{
troposphereLevel = 1f;
stratosphereLevel = 1f;
thermosphereLevel = 1f;
if (_planetMat != null && _originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
}
void Update()
{
if (_planetMat == null) return;
UpdatePlanetTexture();
}
void UpdatePlanetTexture()
{
float worst = Mathf.Min(troposphereLevel, stratosphereLevel, thermosphereLevel);
if (worst >= 1f)
{
if (_originalTexture != null)
_planetMat.SetTexture("_BaseMap", _originalTexture);
return;
}
Texture2D tex = worst <= 0f ? deadTexture : GetPlanetTexture(worst);
if (tex != null)
_planetMat.SetTexture("_BaseMap", tex);
}
Texture2D GetPlanetTexture(float level)
{
if (level >= 0.7f) return tropo100;
else if (level >= 0.5f) return tropo70;
else if (level >= 0.3f) return tropo50;
else if (level > 0f) return tropo30;
else return tropo0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bcd59981ea01c1c48910eef91d739637
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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