-
Notifications
You must be signed in to change notification settings - Fork 0
/
OneUILine.cs
75 lines (67 loc) · 1.92 KB
/
OneUILine.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Scripting;
//展示一个进度条
public class OneUILine : StepBase
{
public bool IsOpen = true;
//是否正在增加进度条,用来控制是否展示进度条
public bool EnegyHasCome = false;
//是否还有其它进度条
public bool IsInGroup = false;
//用来判断一个进度条是否加载满,在存在多个进度条时使用
public bool ForGroupHaveDone;
public List<OneUILine> NextLines = new List<OneUILine>();
[System.Serializable]
public class Event_ : UnityEngine.Events.UnityEvent { }
public Event_ Event_1;
public float ThisLenth = 1;
[HideInInspector]
public UnityEngine.UI.Image thisimg;
private void Start()
{
thisimg = GetComponent<UnityEngine.UI.Image>();
thisimg.fillAmount = 0;
if (IsInGroup)
{
Event_OnWaitTimeOver.RemoveAllListeners();
}
}
public override void Act()
{
base.Act();
EnegyHasCome = true;
}
private void Update()
{
//慢慢加载进度条
if (IsOpen && EnegyHasCome)
{
thisimg.fillAmount += Time.deltaTime / ThisLenth / 2;
}
//进度条加载满
if (thisimg.fillAmount >= 1 && EnegyHasCome)
{
Event_1?.Invoke();
foreach (var item in NextLines)
{
if(item)
item.EnegyHasCome = true;
}
if (!IsInGroup)
{
thisimg.fillAmount = 0;
}
EnegyHasCome = false;
ForGroupHaveDone = true;
StartCoroutine(Alwa());
}
}
IEnumerator Alwa() {
Event_OnStepOver?.Invoke();
yield return new WaitForSeconds(WaitTime);
ForGroupHaveDone = false;
Event_OnWaitTimeOver?.Invoke();
}
}