/
AchievementView.cs
59 lines (47 loc) · 1.67 KB
/
AchievementView.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
using Bos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Achievement))]
public class AchievementView : GameBehaviour
{
private Achievement _achi;
public GameObject CompletionBorder;
public Image Icon;
public Text Name;
public Text Requirement;
public Text AchiPoints;
public Color NameUncompletedColor;
public Color NameCompletedColor;
public Color RequirementUncompletedColor;
public Color RequirementCompletedColor;
public override void Start()
{
_achi = GetComponent<Achievement>();
Icon.sprite = _achi.Icon;
Name.text = _achi.Name;
AchiPoints.text = _achi.Points.ToString();
}
public override void Update() {
base.Update();
CompletionBorder.SetActive(_achi.IsCompleted);
if (_achi.IsCompleted) {
Name.color = NameCompletedColor;
AchiPoints.color = NameCompletedColor;
Requirement.color = RequirementCompletedColor;
Requirement.text = string.Format("{0}/{0}", _achi.TargetCount);
} else {
Name.color = NameUncompletedColor;
AchiPoints.color = NameUncompletedColor;
Requirement.color = RequirementUncompletedColor;
if (Services.TransportService.HasUnits(_achi.TargetGeneratorId)) {
Requirement.text = string.Format("{0}/{1}", Services.TransportService.GetUnitTotalCount(_achi.TargetGeneratorId), _achi.TargetCount);
} else {
Requirement.text = string.Format("{0}/{1}", 0, _achi.TargetCount);
}
}
}
}