I’d like to show a little more detail on the various types of sequence events.
I’m going to share some xml to demonstrate what happens in a sequence.
Here is a part of a sequence in the game.
First: Tatenen walks to coordinates -3299 x -182
Second: Ammut walks to coordinates -3299 x -244
Third: FadeIn the camera and take 1.5 seconds to do it.
Fourth: Wait 2 seconds while the fade takes place.
Tatenen walks left Ammut Walks left Fade back in wait for fade What is the meaning of this?
To run this sequence I have a sequence controller script that will parse this information as coroutines so that we can “yield” to each line.
The NPCWalkToPoint runs code which looks like this (note* this is not the code directly. The real code is much more generic than this. But for demonstration I thought this would be more useful to a beginner to see it fully broken down.):
float x = float.Parse(node.Attributes["x"].Value); float z = float.Parse(node.Attributes["z"].Value); string NPCName = node.Attributes["object"].Value; //send the npc name and coordinates to a method that makes that npc walk to the coordinates. yield return StartCoroutine(Movement.NPCWalkToPointNoYield(new Vector2(x,z),NPCName));
The next event would be a FadeIn.
float time = float.Parse(node.Attributes["FadeIn"].Value; yield return StartCoroutine(ScreenFade.FadeIn(time));
The Wait event
float time = float.Parse(node.Attributes["wait"].Value); yield return StartCoroutine(Timer.Wait(time));
Make sure the NPC has stopped moving and has reached its destination
string NPCName = node.Attributes["object"].Value; yield return StartCoroutine(Movement.WaitForNPCToMove(NPCName));
Speak some dialogue!
string charName = node.Attributes["spkChar"].Value; string spkType = node.Attributes["spkType"].Value; string textToSpeak = node.InnerText; yield return StartCoroutine(Speach.speak(charName,spkType,textToSpeak);
I have probably about 100 or so event types setup in this manner and I constantly am adding more. The idea is to make any events be scripted through the XML and not in code. The sequence controller will parse the xml and run specified methods that do all the work. You could make a very simple visual editor based on this method for scripting events.
Hopefully this gives you some ideas!