-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller
51 lines (47 loc) · 1.14 KB
/
controller
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class controller : MonoBehaviour {
public static controller instance;
private Text ScoreText;
private int score;
public GameObject scorePanel;
public Text endScore;
public Animator endPanelAnim;
// Use this for initialization
void Awake () {
MakeInstance();
}
void Start()
{
ScoreText = GameObject.Find("ScoreText").GetComponent<Text>();
StartCoroutine(CountScore());
}
void MakeInstance()
{
if (instance == null)
{
instance = this;
}
}
IEnumerator CountScore()
{
yield return new WaitForSeconds(0.1f);
score++;
ScoreText.text = score.ToString();
StartCoroutine(CountScore());
}
public void GameOver()
{
scorePanel.SetActive(false);
endScore.text = "height" + score;
endPanelAnim.Play("endpanel");
}
public void Again()
{
Time.timeScale = 1f;
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}