-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoreScript
58 lines (46 loc) · 929 Bytes
/
scoreScript
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
/*COPYRIGHT NAUMAN MUNIR 2015 */
using UnityEngine;
using System.Collections;
public class scoreScript : MonoBehaviour {
private int score = 0;
private int highScore = 0;
private bool newBest;
public playerController player;
public int Score {
get{ return score;}
set{ score = Score;}
}
public int HighScore
{
get{ return highScore;}
set{ highScore = HighScore;}
}
public bool NewBest
{
get{ return newBest;}
set{ newBest = NewBest;}
}
// Use this for initialization
void Start () {
//PlayerPrefs.DeleteAll ();
newBest = false;
highScore = PlayerPrefs.GetInt ("highScore", 0);
}
// Update is called once per frame
void Update () {
AddScore ();
}
public void AddScore()
{
score = player.PenguinEaten;
if (score > highScore) {
highScore = score;
newBest = true;
}
//Debug.Log (score);
}
void OnDestroy()
{
PlayerPrefs.SetInt ("highScore", highScore);
}
}