-
Notifications
You must be signed in to change notification settings - Fork 0
/
AchievementDisplayer.cs
60 lines (54 loc) · 1.57 KB
/
AchievementDisplayer.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AchievementDisplayer : MonoBehaviour {
public static AchievementDisplayer instance;
public GameObject dialogueBox;
public Text text;
public float waitTime = 4;
float timer = 0;
public Queue<Achievement> q;
// Use this for initialization
void Start () {
instance = this;
q = new Queue<Achievement>();
}
AchievementCard temp;
// Update is called once per frame
void Update () {
if (q.Count > 0)
{
if (timer == 0)
{
dialogueBox.GetComponent<Animator>().SetBool("Show", true);
dialogueBox.GetComponent<AudioSource>().Play();
foreach (AchievementCard c in GameController.instance.achievements)
{
if (c.achievement == q.Peek())
{
temp = c;
}
}
text.text = temp.Name;
}
timer += Time.deltaTime;
if (timer > waitTime * 2 + 1.5f)
{
text.text = "";
timer = 0;
q.Dequeue();
} else if (timer > waitTime * 2)
{
dialogueBox.GetComponent<Animator>().SetBool("Show", false);
} else if (timer > waitTime)
{
text.text = temp.description;
}
}
}
public void displayAchievement(Achievement a)
{
q.Enqueue(a);
}
}