Refactored ClearData.cs and removed unused script

This commit is contained in:
MarcUs7 2024-12-28 19:40:53 +01:00
parent c85bcdd0ba
commit 293850d27e
3 changed files with 4 additions and 117 deletions

View file

@ -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;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 12fb2d68a00f1a94a94e473a0a76a3c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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<MainMenu>().GetComponent<MainMenu>();
var mainMenu = FindFirstObjectByType<MainMenu>().GetComponent<MainMenu>();
mainMenu.LoadScene(0);
}
}