/
Score.cs
37 lines (29 loc) · 853 Bytes
/
Score.cs
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
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
public int score = 0; // The player's score.
private PlayerControl playerControl; // Reference to the player control script.
private int previousScore = 0; // The score in the previous frame.
private Mine mine;
void Awake ()
{
// Setting up the reference.
playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
mine = GameObject.Find ("mine").GetComponent<Mine> ();
}
void Update ()
{
// Set the score text.
guiText.text = "Score: " + score;
// If the score has changed...
if (previousScore != score)
{
// ... play a taunt.
playerControl.StartCoroutine (playerControl.Taunt ());
mine.playMov=true;
}
// Set the previous score to this frame's score.
previousScore = score;
}
}