-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlatformStatus.cs
73 lines (69 loc) · 2.6 KB
/
PlatformStatus.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
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
using UnityEngine;
using UnityEngine.UI;
public class PlatformStatus : MonoBehaviour {
public bool landed = false;
public Color landedColor;
Text score;
Text best;
public Comet comet;
Animator platformAnim;
public Animator scoreAnim;
public DifficultyModifier difficulty;
public AudioClip sound;
AudioSource audioSource;
private void Start()
{
score = GameObject.Find("Score").GetComponent<Text>();
best = GameObject.Find("Best Score").GetComponentInChildren<Text>();
platformAnim = gameObject.GetComponent<Animator>();
audioSource = GameObject.Find("Audio").GetComponent<AudioSource>();
}
private void OnCollisionEnter2D(Collision2D collision)
{
int currentScoreVal = PlayerPrefs.GetInt("currentScore");
int bestScoreVal = PlayerPrefs.GetInt("bestScore");
if (landed == false)
{
landed = true;
PlayerPrefs.SetInt("currentScore", currentScoreVal + 1);
currentScoreVal = PlayerPrefs.GetInt("currentScore");
score.text = currentScoreVal.ToString();
if (currentScoreVal > bestScoreVal)
{
PlayerPrefs.SetInt("bestScore", currentScoreVal);
best.text = PlayerPrefs.GetInt("bestScore").ToString();
}
GetComponent<SpriteRenderer>().color = landedColor;
platformAnim.SetTrigger("Trigger");
scoreAnim.SetTrigger("Trigger");
audioSource.PlayOneShot(sound);
difficulty.ModDifficulty();
if (currentScoreVal % 20 == 0)
{
comet.ActivateComet();
}
//check for achievments
switch (PlayerPrefs.GetInt("currentScore"))
{
case 5:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAC");
break;
case 20:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAD");
break;
case 50:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAE");
break;
case 100:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAI");
break;
case 200:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAJ");
break;
case 500:
PlayGamesScript.UnlockAchievement("CggI5crG7DEQAhAK");
break;
}
}
}
}