mirror of
https://github.com/Kizuren/ShantiManti.git
synced 2025-12-21 21:16:04 +01:00
Refactored ClearData.cs and removed unused script
This commit is contained in:
parent
c85bcdd0ba
commit
293850d27e
3 changed files with 4 additions and 117 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 12fb2d68a00f1a94a94e473a0a76a3c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue