The main part are RPG Core.cs
, StoryReader.cs
,OptionButton.cs
.
This tool is still in testing.
Example
Check out this demo project.(unity version 2020.1.1f1) or watch the demo video. All the story condition checks are done by this tool (example), other scripts only deal with player movement.
I use .xml as file extension only because it is easier to edit on vscode.
You can check out regexs at
RPG Core.cs
.
-Start by <story>
and end with </story>
tag.
-Add \
before <
and >
if it is in the content.
EXAMPLE
<l > \<color=red\> Red content text! \</color\> </l>
l
refers to line. It wraps dialog contents.
Example
<if(temp_a ==1)||(temp_a ==1)></if>
<if (temp_a<=1) && (temp_b==2) && (temp_b>=2) && (temp_a!=1)></if>
<if(temp_a ==1)></if>
Giving selections. Comes with <opt> </opt>
tags. Can not use other tags in it.
Example
<select>
<opt set("opt"=1) > dialog content </opt>
<opt set("opt"=2) > dialog content2 </opt>
</select>
EXAMPLE
animation(gameobjectName,clipName)
Will find gameobject with gameobjectName
in scene and play clipName
if aniamtor is attached.
EXAMPLE
audio(gameobjectName, stop)
audio(gameobjectName, play)
audio(gameobjectName, pause)
Will find gameobject with gameobjectName
in scene and set its audioSource's state.
EXAMPLE
title ="Jack"
Set the title.
EXAMPLE
by ="gameobjectname"
If you are using the style that dialog will show above the gameobject in scene, use it to find gameobject with the name gameobjectname
.
EXAMPLE
img(left,"img1")
img(middle,'img2')
img(right,/imgfolder/img1)
If you are using the style that similar to Japaneses game, use it to load the picture under Resources
folider and define which position to place. left,middle and right are just image variables in StoryReader.cs
. previous demo
EXAMPLE
<l init("para"=0)> </l>
Init or reset a variable.
EXAMPLE
set(" temp_a"=1)
set("temp_a"= "temp_b")
set("temp_a"="temp_b" + "temp_a")
Set a variables, or create one if it is not defined.
If variable's name start withtemp_
, then it will be clear out after the dialog end. Otherwise it will last the whole game. Keep in mind that you should write a script to save and load StoryRecord
in RPGCore.cs
before you close or open the game.
Read a variable's value.
EXAMPLE
$[key]
It is the same if you type it in the argument:
EXAMPLE
<select>
<opt set("temp_a"="temp_b") > set temp_a= b</opt>
<opt set("temp_a"=$[temp_c]) > set temp_a= c </opt>
</select>
But you can type it in the dialog content.
EXAMPLE
<l> temp_a = $[temp_a]</l>
WON'T WORK
<l> temp_a = "temp_a"</l>
Enable or disable gameobjects.
Any argument that doesn't match regex above also can be catched. Add your own argument function by following the rule:
functionName( arg1, arg2 ,arg3,arg4.......);
At ReadArgs
funtuion in StoryReader.cs
, there is a place marked YOUR OWN SCRIPT FUNCTION
. for example, myFunc(v1,v2,v3,v4....)
,then myFunc
is the functionName
and parameters are splited by,
.
Argments are not limited to one in one line!
EXAMPLE
<l title="Dog"
by="Dog"
img(right,"Img/Portrait/p1")
effect(shake)
animation(obj1,clip_hi)
animation(obj2,clip_ya)
animation(obj3,Idle)
> woof woof
</l>
Contains regexs , in charge of spliting nesting tags and other basic funtions.
- lang
Add your own language mark at
public enum Lang
. It is used to separate different language textfile folders.
- StoryRecord and temp_StoryRecord
Used to record custum variables. If variable start with
temp_
, then it is record intotemp_StoryRecord
and will be clear out while dialog end. Otherwise it is saved intoStoryRecord
and last the whole game. Keep in mind that you should write a script to save and load this parameter before you close or open the game.
- ESC_CHAR
I am not a regex pro, this is just a workaround to allow me typing
<
or>
in the dialog.
Controling UI. It reads tags, args texts and applying them to the UI.
To start a conversation, simply call StartConversation
function. see StoryTrigger.cs for example.
Asign your defult lanuage dialog text file to TextAsset text
. While converstation start, it will find the file with same name as text
under other lang
folder.
see others at Lontoone