From 293850d27ea2ef10f601e546a38bd81d8eb7391b Mon Sep 17 00:00:00 2001 From: MarcUs7 <96580944+MarcUs7i@users.noreply.github.com> Date: Sat, 28 Dec 2024 19:40:53 +0100 Subject: [PATCH] Refactored ClearData.cs and removed unused script --- Assets/game/Scripts/UI/CheckDeleted.cs | 102 -------------------- Assets/game/Scripts/UI/CheckDeleted.cs.meta | 11 --- Assets/game/Scripts/UI/ClearData.cs | 8 +- 3 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 Assets/game/Scripts/UI/CheckDeleted.cs delete mode 100644 Assets/game/Scripts/UI/CheckDeleted.cs.meta diff --git a/Assets/game/Scripts/UI/CheckDeleted.cs b/Assets/game/Scripts/UI/CheckDeleted.cs deleted file mode 100644 index 1cb4a0d..0000000 --- a/Assets/game/Scripts/UI/CheckDeleted.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; - -public class CheckDeleted : MonoBehaviour -{ - public GameObject Error; - public GameObject Deleted; - public GameObject ThisDeleting; - int count = 0; - bool waitDelete = false; - public float WaitTime = 2.0f; - public float waitTimeExit = 3.0f; - bool waitExit = false; - int Delete = 0; - int Exit = 0; - - void Start() - { - count = 0; - waitDelete = false; - Delete = 0; - Exit = 0; - } - - void Update() - { - //Debug.Log("Delete Stage: " + count); - if (count == 0) - { - if (Exit == 0) - { - StartCoroutine(WaitForExit()); - } - if (waitExit) - { - return; - } - count++; - Exit = 0; - if (PlayerSaving.Level == 0 && PlayerSaving.Coins == 0 && !PlayerSaving.HasCompletedTutorial && PlayerSaving.MovingClouds) - { - - Deleted.SetActive(true); - Debug.Log("Done Stage: " + count); - count = 0; - ThisDeleting.SetActive(false); - } - } - if (count == 1 || count == 2) - { - PlayerSaving.DeletePlayer(); - if (Delete == 0) - { - StartCoroutine(WaitForDelete()); - } - if (waitDelete) - { - return; - } - PlayerSaving.LoadPlayer(); - count++; - Delete = 0; - if (PlayerSaving.Level == 0 && PlayerSaving.Coins == 0 && !PlayerSaving.HasCompletedTutorial && PlayerSaving.MovingClouds) - { - Deleted.SetActive(true); - Debug.Log("Done Stage: " + count); - count = 0; - ThisDeleting.SetActive(false); - } - } - if (count >= 3) - { - Error.SetActive(true); - Debug.Log("Failed Stage: " + count); - count = 0; - ThisDeleting.SetActive(false); - } - } - - IEnumerator WaitForDelete() - { - Delete++; - waitDelete = true; - yield return new WaitForSeconds(WaitTime); - waitDelete = false; - - } - - IEnumerator WaitForExit() - { - if (Exit == 0) - { - Exit++; - waitExit = true; - yield return new WaitForSeconds(waitTimeExit); - waitExit = false; - } - - } -} diff --git a/Assets/game/Scripts/UI/CheckDeleted.cs.meta b/Assets/game/Scripts/UI/CheckDeleted.cs.meta deleted file mode 100644 index 9d7fe3b..0000000 --- a/Assets/game/Scripts/UI/CheckDeleted.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 12fb2d68a00f1a94a94e473a0a76a3c0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/game/Scripts/UI/ClearData.cs b/Assets/game/Scripts/UI/ClearData.cs index d4ae463..7228403 100644 --- a/Assets/game/Scripts/UI/ClearData.cs +++ b/Assets/game/Scripts/UI/ClearData.cs @@ -12,7 +12,7 @@ public class ClearData : MonoBehaviour [Header("")] public float waitForDeletion = 0.1f; - void Start() + private void Start() { ConfirmationDialog.SetActive(true); DarkBackground.SetActive(false); @@ -28,7 +28,7 @@ public class ClearData : MonoBehaviour StartCoroutine(CheckDelete()); } - IEnumerator CheckDelete() + private IEnumerator CheckDelete() { PlayerSaving.DeletePlayer(); yield return new WaitForSeconds(waitForDeletion); @@ -38,7 +38,7 @@ public class ClearData : MonoBehaviour int[] checkInts = { PlayerSaving.Level, PlayerSaving.Coins }; bool[] checkBools = { PlayerSaving.HasCompletedTutorial, PlayerSaving.MovingClouds }; - for (int i = 0; i < defaultInts.Length; i++) + for (var i = 0; i < defaultInts.Length; i++) { if (checkInts[i] != defaultInts[i] || checkBools[i] != defaultBools[i]) { @@ -48,7 +48,7 @@ public class ClearData : MonoBehaviour } } - MainMenu mainMenu = FindObjectOfType().GetComponent(); + var mainMenu = FindFirstObjectByType().GetComponent(); mainMenu.LoadScene(0); } }