aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2019-04-27 18:00:48 +0200
committermarcinzelent <zelent.marcin@gmail.com>2019-04-27 18:00:48 +0200
commit19d32b28f4888407a5c06ed84a751a2c35691d2b (patch)
tree43641a956be270b2974b553dade69752426925e1 /nGJ2019/Assets/Scripts/EventTimeline.cs
parent70c0792ee952d2690fac411ca3240fcb50f7a7b0 (diff)
Added messaging
Diffstat (limited to 'nGJ2019/Assets/Scripts/EventTimeline.cs')
-rw-r--r--nGJ2019/Assets/Scripts/EventTimeline.cs28
1 files changed, 27 insertions, 1 deletions
diff --git a/nGJ2019/Assets/Scripts/EventTimeline.cs b/nGJ2019/Assets/Scripts/EventTimeline.cs
index 21b0bdb..b864ae7 100644
--- a/nGJ2019/Assets/Scripts/EventTimeline.cs
+++ b/nGJ2019/Assets/Scripts/EventTimeline.cs
@@ -17,15 +17,30 @@ public class EventTimeline
this.type = type;
}
}
+
+ public class MessageEvent
+ {
+ public float time;
+ public String message;
+
+ public MessageEvent(float time, String message)
+ {
+ this.time = time;
+ this.message = message;
+ }
+ }
public event Action<SpawnEvent> OnSpawnEvent;
+ public event Action<MessageEvent> OnMessageEvent;
private List<SpawnEvent> futureEvents;
+ private List<MessageEvent> futureMessages;
private float currentTime;
public EventTimeline()
{
futureEvents = new List<SpawnEvent>();
+ futureMessages = new List<MessageEvent>();
currentTime = 0;
}
@@ -34,17 +49,28 @@ public class EventTimeline
futureEvents.Add(new SpawnEvent(time, height, type));
futureEvents.Sort((x,y) => x.time.CompareTo(y.time));
}
+
+ public void Add(float time, String message)
+ {
+ futureMessages.Add(new MessageEvent(time, message));
+ futureMessages.Sort((x,y) => x.time.CompareTo(y.time));
+ }
public void timeTick(float deltaTime)
{
currentTime += deltaTime;
- while(futureEvents.Count > 0 && currentTime > futureEvents[0].time)
+ while(futureEvents.Count > 0 && currentTime > futureEvents[0].time && futureMessages.Count > 0 && currentTime > futureMessages[0].time)
{
SpawnEvent e = futureEvents[0];
futureEvents.RemoveAt(0);
if(OnSpawnEvent != null)
OnSpawnEvent(e);
+
+ MessageEvent m = futureMessages[0];
+ futureMessages.RemoveAt(0);
+ if(OnMessageEvent != null)
+ OnMessageEvent(m);
}
}
}