-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameEndScript.cs
More file actions
34 lines (27 loc) · 986 Bytes
/
gameEndScript.cs
File metadata and controls
34 lines (27 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using UnityEngine;
using UnityEngine.SceneManagement;
public class gameEndScript : MonoBehaviour
{
[SerializeField] private stageControl stageControlScript;
private bool hasTriggeredCompletion = false;
void Update()
{
if (stageControlScript != null && !hasTriggeredCompletion)
{
if (stageControlScript.stageComplete)
{
hasTriggeredCompletion = true;
// Store completion data
string username = SQLManager.CurrentUsername;
PlayerPrefs.SetString("CompletionUsername", username);
if (LevelTimer.Instance != null)
{
float completionTime = LevelTimer.Instance.GetCurrentTime();
PlayerPrefs.SetFloat("CompletionTime", completionTime);
}
stageControlScript.stageComplete = false;
SceneManager.LoadScene("End Menu");
}
}
}
}