using SHADE; using SHADE_Scripting.UI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class Results : Script { public GameObject score; public GameObject timeLeft; public GameObject maxCombo; public GameObject finalScore; public GameObject contiuneBtn; public GameObject levelTransition; public uint nextScene; public float scoreTweenDur = 2.0f; private TextRenderable scoreText; private TextRenderable timeLeftText; private TextRenderable maxComboText; private TextRenderable finalScoreText; private int scoreCount = 0; private bool once = true; [NonSerialized] private TweenThread scoreTween; private bool waitForTransition; protected override void awake() { scoreText = score.GetComponent(); if (!scoreText) Debug.LogError("MISSING SCORE TEXT"); timeLeftText = timeLeft.GetComponent(); if (!timeLeftText) Debug.LogError("MISSING TIME LEFT TEXT"); maxComboText = maxCombo.GetComponent(); if (!maxComboText) Debug.LogError("MISSING MAX COMBO TEXT"); finalScoreText = finalScore.GetComponent(); if (!finalScoreText) Debug.LogError("MISSING FINAL SCORE TEXT"); if (!contiuneBtn) Debug.LogError("MISSING CONTIUNE BTN"); else contiuneBtn.SetActive(false); waitForTransition = false; } protected override void start() { scoreCount = GameManager.Instance.Score + (GameManager.Instance.finalTime * 100); if(scoreText) scoreText.Text = $"{GameManager.Instance.Score}"; if (timeLeftText) timeLeftText.Text = $"{GameManager.Instance.finalTime}s"; if (maxComboText) maxComboText.Text = $"X{GameManager.Instance.MaxComboAccquired}"; if (finalScoreText) finalScoreText.Text = $"{scoreCount}"; UIElement contiune = contiuneBtn.GetComponent(); if (contiune != null) { contiune.OnRelease.RegisterAction(() => { levelTransition.GetScript().resetToLeft(); waitForTransition = true; GameManager.Instance.GamePause = false; Application.FixDeltaTime = Time.DefaultFixDeltaTime; AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale; }); } else { Debug.LogError("Failed to register contiune button."); } scoreTween = TweenManager.CreateTweenThread(scoreTweenDur, 0, scoreCount, EASING_METHOD.EASE_IN_SINE); } protected override void update() { if (levelTransition.GetScript().complete && waitForTransition) { Audio.StopAllSounds(); SceneManager.ChangeScene(nextScene); } if (finalScoreText && !scoreTween.IsCompleted()) finalScoreText.Text = $"{(int)scoreTween.GetValue()}"; else if(scoreTween.IsCompleted() && once) { contiuneBtn.SetActive(true); finalScoreText.Text = $"{scoreCount}"; once = false; } } }