using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class PlanetInfoDisplay : MonoBehaviour { [SerializeField] private PlanetType planetType; [SerializeField] private PlanetSpin planetSpin; [SerializeField] private TextMeshProUGUI infoText; [SerializeField] private float startDistanceUnity; private Dictionary _realDistances = new Dictionary() { { PlanetType.Mercury, 57.9f }, { PlanetType.Venus, 108.2f }, { PlanetType.Earth, 149.6f }, { PlanetType.Mars, 227.9f }, { PlanetType.Jupiter, 778.5f }, { PlanetType.Saturn, 1432f }, { PlanetType.Uranus, 2867f }, { PlanetType.Neptune, 4515f }, { PlanetType.Pluto, 5906f } }; private Dictionary _realRotationSpeeds = new Dictionary() { { PlanetType.Mercury, 10.83f }, { PlanetType.Venus, 6.52f }, { PlanetType.Earth, 1674f }, { PlanetType.Mars, 868f }, { PlanetType.Jupiter, 45583f }, { PlanetType.Saturn, 36840f }, { PlanetType.Uranus, 14794f }, { PlanetType.Neptune, 9719f }, { PlanetType.Pluto, 813f } }; private Dictionary _baseRotationSpeeds = new Dictionary() { { PlanetType.Mercury, 0.26f }, { PlanetType.Venus, -0.025f }, { PlanetType.Earth, 15f }, { PlanetType.Mars, 14.6f }, { PlanetType.Jupiter, 36.4f }, { PlanetType.Saturn, 33.6f }, { PlanetType.Uranus, -20.9f }, { PlanetType.Neptune, 22.4f }, { PlanetType.Pluto, -2.35f } }; private Dictionary _orbitalSpeeds = new Dictionary() { { PlanetType.Mercury, 47.4f }, { PlanetType.Venus, 35.0f }, { PlanetType.Earth, 29.8f }, { PlanetType.Mars, 24.1f }, { PlanetType.Jupiter, 13.1f }, { PlanetType.Saturn, 9.7f }, { PlanetType.Uranus, 6.8f }, { PlanetType.Neptune, 5.4f }, { PlanetType.Pluto, 4.7f } }; private Dictionary _temperatures = new Dictionary() { { PlanetType.Mercury, new Vector2(-180f, 430f) }, { PlanetType.Venus, new Vector2(437f, 497f) }, { PlanetType.Earth, new Vector2(-88f, 58f) }, { PlanetType.Mars, new Vector2(-125f, 20f) }, { PlanetType.Jupiter, new Vector2(-145f, -108f) }, { PlanetType.Saturn, new Vector2(-178f, -130f) }, { PlanetType.Uranus, new Vector2(-224f, -197f) }, { PlanetType.Neptune, new Vector2(-218f, -200f) }, { PlanetType.Pluto, new Vector2(-240f, -218f) } }; private Dictionary _planetTypes = new Dictionary() { { PlanetType.Mercury, "Кам'яниста" }, { PlanetType.Venus, "Кам'яниста" }, { PlanetType.Earth, "Кам'яниста" }, { PlanetType.Mars, "Кам'яниста" }, { PlanetType.Jupiter, "Газовий гігант" }, { PlanetType.Saturn, "Газовий гігант" }, { PlanetType.Uranus, "Крижаний гігант" }, { PlanetType.Neptune, "Крижаний гігант" }, { PlanetType.Pluto, "Карликова" } }; void Update() { if (infoText == null) return; UpdateInfo(); } void UpdateInfo() { float currentX = Mathf.Abs(transform.position.x); float distanceKm = 0f; if (startDistanceUnity > 0.001f) { float ratio = currentX / startDistanceUnity; distanceKm = ratio * _realDistances[planetType]; } float currentRotationSpeed = 0f; if (planetSpin != null) { float baseSpeed = Mathf.Abs(_baseRotationSpeeds[planetType]); float currentSpeed = Mathf.Abs(planetSpin.RotationSpeed); if (baseSpeed > 0.0001f) { float speedRatio = currentSpeed / baseSpeed; currentRotationSpeed = _realRotationSpeeds[planetType] * speedRatio; } } float orbitalSpeed = _orbitalSpeeds[planetType]; Vector2 temp = _temperatures[planetType]; string type = _planetTypes[planetType]; infoText.text = "Тип планети: " + type + "\n" + "Відстань від Сонця: " + distanceKm.ToString("F1") + " млн км\n" + "Швидкість обертання навколо своєї осі: " + currentRotationSpeed.ToString("F0") + " км/год\n" + "Швидкість руху по орбіті навколо Сонця: " + orbitalSpeed.ToString("F1") + " км/с\n" + "Температура поверхні: від "+"\n" + temp.x.ToString("F0") + "°C до " + temp.y.ToString("F0") + "°C"; } }