Загрузка данных


Temperature.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Temperature : MonoBehaviour
{
	public Health health;
	public int playerDamage = 2;
	public float temperatureCurrent = 36.6f;
	public float temperatureNormal = 36.6f;
	public float temperatureCritical = 34f;
	public float freezeSpeed = 0.05f;
	float freezeDamageTimer = 1;
	public float freezeDamageDelay = 2;
 
	void Update()
	{
		// Температура постоянно убывает с указанной скоростью
		temperatureCurrent -= freezeSpeed * Time.deltaTime;
 
		// Если температура тела упала ниже критической
		if (temperatureCurrent <= temperatureCritical)
		{
			if (freezeDamageTimer <= 0)
			{
				health.TakeDamage(playerDamage);
				freezeDamageTimer += freezeDamageDelay;
			}
			else
			{
				freezeDamageTimer -= Time.deltaTime;
			}
		}
	}
}
 
Bonfire.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Bonfire : MonoBehaviour
{
	//Время жизни огня
	public float lifeTime = 15;
	//Теплоотдача
	public float heatPower = 0.1f;
 
	//Каждый кадр костёр постепенно угасает, затем исчезает со сцены
	void Update()
	{
		lifeTime -= Time.deltaTime;
		if (lifeTime <= 0)
		{
			gameObject.SetActive(false);
		}
	}
 
	void OnTriggerStay(Collider other)
	{
		if (other.GetComponent<Temperature>() != null)
		{
			Temperature temperature = other.GetComponent<Temperature>();
			// Если температура тела игрока меньше нормальной, то согреваем его
			if (temperature.temperatureCurrent < temperature.temperatureNormal)
			{
				temperature.temperatureCurrent += heatPower * Time.deltaTime;
			}
		}
	}
}
TemperatureUI.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
 
public class TemperatureUI : MonoBehaviour
{
	public Temperature temperature;
	public TextMeshProUGUI temperatureText;
 
	void Update()
	{
		float roundTemperature = Mathf.Round(temperature.temperatureCurrent * 10.0f) * 0.1f;
		temperatureText.text = roundTemperature.ToString();
	}
}
 
StartButton.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
 
public class StartButton : MonoBehaviour
{
	public void StartGame()
	{
		SceneManager.LoadScene(1);
	}
 
}