134 lines
3.6 KiB
C#
134 lines
3.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class PlanetSelector : MonoBehaviour
|
|
{
|
|
public AgingController agingController;
|
|
public TimeManager timeManager;
|
|
|
|
public Button previousButton;
|
|
public Button nextButton;
|
|
public TextMeshProUGUI ageText;
|
|
public TextMeshProUGUI planetText;
|
|
|
|
public Material skyboxMaterial;
|
|
|
|
private int currentPlanetIndex = 2;
|
|
|
|
private string[] planetNames = {
|
|
"Ìåðêóð³¿", "Âåíåð³", "Çåìë³", "̳ñÿö³",
|
|
"Ìàðñ³", "Þï³òåð³", "Ñàòóðí³", "Óðàí³", "Íåïòóí³", "Ïëóòîí³"
|
|
};
|
|
|
|
private float[] dayLengthHours = {
|
|
1407.6f, 5832.5f, 24f, 708.7f,
|
|
24.6f, 9.9f, 10.7f, 17.2f, 16.1f, 153.3f
|
|
};
|
|
|
|
private float[] daysInYear = {
|
|
88f, 225f, 365f, 365f,
|
|
687f, 4333f, 10759f, 30687f, 60190f, 90560f
|
|
};
|
|
|
|
private float[] agingDurations = {
|
|
5f, 10f, 20f, 20f, 28f, 40f, 40f, 40f, 40f, 40f
|
|
};
|
|
|
|
private float[] orbitalYears = {
|
|
0.24f, 0.62f, 1f, 1f, 1.88f, 11.86f, 29.46f, 84.01f, 164.8f, 248f
|
|
};
|
|
|
|
private Color[] skyboxColors =
|
|
{
|
|
new Color(0.75f,0.78f,0.85f),
|
|
new Color(1.25f,0.85f,0.55f),
|
|
new Color(1f,1f,1f),
|
|
new Color(0.75f,0.85f,1.2f),
|
|
new Color(1.35f,0.55f,0.45f),
|
|
new Color(0.7f,1.15f,1.25f),
|
|
new Color(0.95f,0.65f,1.35f),
|
|
new Color(0.55f,1.25f,1.1f),
|
|
new Color(0.45f,0.65f,1.35f),
|
|
new Color(0.7f,0.7f,1.35f)
|
|
};
|
|
|
|
private float[] skyboxExposure =
|
|
{
|
|
0.7f,
|
|
0.8f,
|
|
0.9f,
|
|
0.95f,
|
|
1.15f,
|
|
0.9f,
|
|
0.8f,
|
|
0.7f,
|
|
0.6f,
|
|
0.9f
|
|
};
|
|
|
|
private float[] skyboxRotation =
|
|
{
|
|
10f, 25f, 0f, 5f, 15f,
|
|
40f, 60f, 90f, 120f, 160f
|
|
};
|
|
|
|
void Start()
|
|
{
|
|
ApplyPlanet();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (timeManager.showAge)
|
|
{
|
|
int earthAge = Mathf.RoundToInt(agingController.currentAge);
|
|
ageText.text = "³ê: " + earthAge + " ³ç 70 ðîê³â";
|
|
|
|
float planetAge = timeManager.fromBeginning
|
|
? agingController.currentAge / orbitalYears[currentPlanetIndex]
|
|
: (agingController.currentAge - 25f) / orbitalYears[currentPlanetIndex];
|
|
|
|
planetText.text = "Íà " + planetNames[currentPlanetIndex] + " ïðîéøëî: " + planetAge.ToString("F1") + " ðîê³â";
|
|
}
|
|
else
|
|
{
|
|
ageText.text = "Òðèâàë³ñòü äîáè íà " + planetNames[currentPlanetIndex] + ": " + dayLengthHours[currentPlanetIndex].ToString("F1") + " ãîäèí";
|
|
planetText.text = "Ó ðîö³ íà " + planetNames[currentPlanetIndex] + ": " + daysInYear[currentPlanetIndex].ToString("F0") + " ä³á";
|
|
}
|
|
}
|
|
|
|
public void OnNextButton()
|
|
{
|
|
if (currentPlanetIndex < planetNames.Length - 1)
|
|
{
|
|
currentPlanetIndex++;
|
|
ApplyPlanet();
|
|
}
|
|
}
|
|
|
|
public void OnPreviousButton()
|
|
{
|
|
if (currentPlanetIndex > 0)
|
|
{
|
|
currentPlanetIndex--;
|
|
ApplyPlanet();
|
|
}
|
|
}
|
|
|
|
void ApplyPlanet()
|
|
{
|
|
agingController.agingDuration = agingDurations[currentPlanetIndex];
|
|
agingController.RestartAging();
|
|
agingController.ApplyHairColor(currentPlanetIndex);
|
|
skyboxMaterial.SetColor("_Tint", skyboxColors[currentPlanetIndex]);
|
|
skyboxMaterial.SetFloat("_Exposure", skyboxExposure[currentPlanetIndex]);
|
|
skyboxMaterial.SetFloat("_Rotation", skyboxRotation[currentPlanetIndex]);
|
|
DynamicGI.UpdateEnvironment();
|
|
previousButton.interactable = currentPlanetIndex > 0;
|
|
nextButton.interactable = currentPlanetIndex < planetNames.Length - 1;
|
|
}
|
|
}
|