ScoreManager.cs
2.03 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour {
int MaxMissionCubeCnt = 6;
public static int MissionCubeCnt;
private static ScoreManager instance;
AudioSource GameClearSound;
public static ScoreManager Instance
{
get
{
if(instance == null)
{
instance = GameObject.FindObjectOfType<ScoreManager>();
}
return instance;
}
}
// Use this for initialization
void Start () {
//DontDestroyOnLoad(gameObject);
MissionCubeCnt = 0;
GameClearSound = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update () {
GameClear();
Debug.Log("Mission Cube Count: " + MissionCubeCnt);
}
public void GameClear()
{
if(MissionCubeCnt >= 3)
{
StartCoroutine("PlayGameClearSound");
Debug.Log("게임 클리어");
//게임 기록 저장
MissionCubeCntToZero();
UIController.Instance.MissionCubeUI(0);
}
}
IEnumerator PlayGameClearSound()
{
Time.timeScale = 0;
AudioManager.Instance.BackgroundSoundOff();
GameClearSound.Play();
UIController.Instance.GameClearUI();
yield return new WaitWhile(() => GameClearSound.isPlaying);
Time.timeScale = 1;
UIController.Instance.GameClearUIOff();
ScaleUpGameManager.Instance.GameOver();
}
public void IncrementMissionCubeCnt()
{
MissionCubeCnt++;
}
public void MissionCubeCntToZero()
{
MissionCubeCnt = 0;
}
public int getMissionCubeCnt()
{
return MissionCubeCnt;
}
public void SaveScore(float time)
{
PlayerPrefs.DeleteAll();
PlayerPrefs.SetFloat("Timer", time);
}
public float GetHighScore()
{
return PlayerPrefs.GetFloat("Timer");
}
}