using System.Collections; using JetBrains.Annotations; using UnityEngine.UI; using UnityEngine; namespace InterfaceOff.WorldScene { public class LifeThingTrackerThing : MonoBehaviour { [SerializeField] private GameObject HurtOverlay; [SerializeField] private Slider SliderThing; [SerializeField] private WindowSpawner Spawner; [SerializeField] private GameObject HittyThingThatSkyDidntWantMeToNameItLikeThisAndInsteadNameItPropely; [SerializeField] private GameObject DisplayMoronText; [field: SerializeField] public int HitsTaken { get; private set; } private Rigidbody body; private void Awake() { body = GetComponent(); Vector3 pos = transform.localPosition; pos.y = 100f; transform.localPosition = pos; } private void Update() { float kjjjjgkjdfh = HitsTaken * 5f; kjjjjgkjdfh = Mathf.Clamp(kjjjjgkjdfh, 0f, 100); if (!Spawner.AutoSpawn) { return; } HittyThingThatSkyDidntWantMeToNameItLikeThisAndInsteadNameItPropely.transform.localScale = new Vector3(90, kjjjjgkjdfh, 90); } void LateUpdate() { if (Spawner.AutoSpawn) { Vector3 pos = transform.localPosition; pos.y = Mathf.Clamp(pos.y, 0, 10); if (Mathf.Approximately(pos.y, 0.0f)) { StartCoroutine(routine: DisplayHurtOverlay()); HitsTaken++; body.velocity = Vector3.zero; pos.y = 10.0f; } if (Mathf.Approximately(pos.y, 10.0f)) { body.velocity = Vector3.zero; } transform.localPosition = pos; SliderThing.value = pos.y; } } [UsedImplicitly] public void AddForceUp() { Vector3 vel = body.velocity; body.AddForce(Vector3.up * 500f, ForceMode.Force); } private IEnumerator DisplayHurtOverlay() { HurtOverlay.SetActive(true); DisplayMoronText.SetActive(true); yield return new WaitForSecondsRealtime(time: 0.4f); HurtOverlay.SetActive(false); yield return new WaitForSecondsRealtime(time: 0.6f); DisplayMoronText.SetActive(false); } } }