-
Notifications
You must be signed in to change notification settings - Fork 0
/
organ_menu_entry.cs
103 lines (89 loc) · 2.26 KB
/
organ_menu_entry.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class organ_menu_entry : MonoBehaviour
{
public string sava;
public string myType;
public int cost;
public string savaName;
public Sprite face;
public int sumonTime;
public bool sava_lock;
public int HowMany;
public int releaseCost;
public float releaseTime;
public int maxHp;
Color imLocking = Color.red;
Color imLockingCant = new Color (0.7f, 0.5f, 0.5f, 1f);
Color imFree= Color.white;
Color imFreeCant= Color.gray;
Color ReleacingNow = Color.yellow;
bool Cando;
Text CostText;
Text SnameText;
Image Myface;
Mana_manager myMana;
public bool releasing;
// Use this for initialization
void Start ()
{
CostText = transform.FindChild ("Cost").GetComponent<Text> ();
if (releaseCost > 0) {
CostText.text = releaseCost.ToString ();
} else {
CostText.text = cost.ToString ();
}
SnameText = transform.FindChild ("Sname").GetComponent<Text> ();
Myface = transform.FindChild ("Face_image").GetComponent<Image> ();
myMana = GameObject.Find ("Mana").GetComponent<Mana_manager> ();
SnameText.text = savaName;
Myface.sprite = face;
Cando = true;
releasing = false;
}
// Update is called once per frame
void Update ()
{
if (sava_lock && myMana.GetMana () < releaseCost && !releasing) {
SetTextColor (imLockingCant);
} else if (sava_lock && myMana.GetMana () >= releaseCost && !releasing) {
SetTextColor (imLocking);
} else if (!sava_lock && myMana.GetMana () >= cost && !releasing) {
SetTextColor (imFree);
} else if (releasing) {
SetTextColor (ReleacingNow);
} else {
SetTextColor (imFreeCant);
}
if (!sava_lock)
releasing = false;
}
void SetTextColor (Color aaa)
{
CostText.color = aaa;
SnameText.color = aaa;
}
public void iRelease ()
{
releasing = true;
StartCoroutine ("ImReleasing");
}
public void StopRelease ()
{
StopCoroutine ("ImReleasing");
releasing = false;
CostText.text = releaseCost.ToString ();
}
private IEnumerator ImReleasing ()
{
float startTime = Time.time;
while ((Time.time - startTime) < releaseTime) {
CostText.text = ((int)(releaseTime - (Time.time - startTime)) + 1).ToString ();
yield return 0;
}
sava_lock = false;
releasing = false;
CostText.text = cost.ToString ();
}
}