-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiamondManager.cs
More file actions
36 lines (26 loc) · 802 Bytes
/
DiamondManager.cs
File metadata and controls
36 lines (26 loc) · 802 Bytes
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
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
public class DiamondManager : MonoBehaviour {
public Text diamondText;
public float diamondCount;
public float pointsPerDiamond;
public bool diamondIncreasing;
// Use this for initialization
void Start () {
if (PlayerPrefs.HasKey("Diamonds"))
{
diamondCount = PlayerPrefs.GetFloat("Diamonds");
}
}
// Update is called once per frame
void Update () {
diamondText.text = "Diamonds: " + Mathf.Round( diamondCount);
PlayerPrefs.SetFloat("Diamonds", diamondCount);
}
public void AddDiamond(int pointsToAddDiamonds)
{
diamondCount += pointsToAddDiamonds;
PlayerPrefs.SetFloat("Diamonds", diamondCount);
}
}