/// <summary> /// This checks for every single token per line and see if it matches the /// begining line of the respective token. /// If it does, it applies the respective effect of the token to the text. /// NOTE: This uses the current line in the raw text rather than the text you see /// </summary> /// <param name="currentline"></param> public token.TOKENTYPE ParseTxt(int currentline, int text_index) { token.TOKENTYPE currenttok = token.TOKENTYPE.ANIMATION; foreach (token tok in listoftokens) { if (currentline == tok.b_line && tok.dialogue_num == text_index) { print("Commands " + tok.tokentype); currenttok = tok.tokentype; if (tok.tokentype == token.TOKENTYPE.END) { commands.Pop(); } else { commands.Push(tok); } } } TypeLine(currentline); // if (commands.Peek().tokentype == token.TOKENTYPE.WAIT) // return(currenttok); }
public IEnumerator DisplayDialogue(string textasset) { done_event = false; txbx.SetActive(true); textTarg = textasset; CompileText(); bool istyping = true; current_text = 0; while (current_text != disptxt.Length) { if (istyping) { for (int i = 0; i < disptxt[current_text].Length; i++) { token.TOKENTYPE toktype = ParseTxt(i, current_text); yield return(new WaitForSeconds(speed)); if (commands.Count > 0) { switch (commands.Peek().tokentype) { case token.TOKENTYPE.WAIT: speed = default_speed; commands.Pop(); break; case token.TOKENTYPE.SELECT_CHARACTER: case token.TOKENTYPE.MOVEPOS: case token.TOKENTYPE.ANIMATION: case token.TOKENTYPE.TXTSPD: case token.TOKENTYPE.FADE: commands.Pop(); break; } } } istyping = false; } yield return(new WaitForSeconds(Time.deltaTime)); if (Input.GetKeyDown(KeyCode.Space)) { textthing.text = ""; istyping = true; current_text++; } } RemoveIcon(); txbx.SetActive(false); done_event = true; }
public void CreateToken(token.TOKENTYPE enu, string tok, int beginlin, int ind, Vector2 vect) { foreach (tokendef tokens in tokendictionary) { if (tokens.tokentype == (int)enu) { token newtok = new token(); newtok.b_line = beginlin; //- tok.Length; newtok.dialogue_num = ind; newtok.tokentype = (token.TOKENTYPE)tokens.tokentype; newtok.capturedat = tok; newtok.position = vect; newtok.number = 0; listoftokens.Add(newtok); } } }
public void CreateToken(token.TOKENTYPE enu, string tok, int beginlin, int ind, Color colour, float time) { foreach (tokendef tokens in tokendictionary) { if (tokens.tokentype == (int)enu) { token newtok = new token(); newtok.b_line = beginlin; //- tok.Length; newtok.dialogue_num = ind; newtok.tokentype = (token.TOKENTYPE)tokens.tokentype; newtok.capturedat = tok; newtok.colour = colour; newtok.time = time; newtok.number = 0; listoftokens.Add(newtok); } } }
/// <summary> /// Processed during compile-time, this creates the list of tokens that are put in effect into the /// run time thing. /// </summary> /// <param name="tok">The token that was found.</param> /// <param name="beginlin">The line that the effect of this token begins</param> /// <param name="ind">Which part of the dialgoue the token applies to</param> public void CreateToken(token.TOKENTYPE enu, string tok, int beginlin, int ind) { //TODO: //DO A FOREACH LOOP OF THE TOKENS OF WHICH INSTRUCTIONS TO INCLUDE foreach (tokendef tokens in tokendictionary) { if (tokens.tokentype == (int)enu) { token newtok = new token(); newtok.b_line = beginlin; //- tok.Length; newtok.dialogue_num = ind; newtok.tokentype = (token.TOKENTYPE)tokens.tokentype; newtok.capturedat = tok; newtok.time = 0; newtok.number = 0; listoftokens.Add(newtok); } } }
void TypeLine(int currentline) { Stack <token> temp_stk = new Stack <token>(); foreach (token stack in commands) { temp_stk.Push(stack); } //This is for the line by line check while (temp_stk.Count > 0) { token.TOKENTYPE currenttok = temp_stk.Peek().tokentype; switch (currenttok) { case token.TOKENTYPE.SELECT_CHARACTER: Set(temp_stk.Peek().capturedat, 0); temp_stk.Pop(); break; case token.TOKENTYPE.WAIT: speed = (float)temp_stk.Peek().time; temp_stk.Pop(); break; case token.TOKENTYPE.COLOUR: textthing.text += "<color=" + temp_stk.Peek().capturedat + ">"; temp_stk.Pop(); break; case token.TOKENTYPE.ITALICS: textthing.text += "<i>"; temp_stk.Pop(); break; case token.TOKENTYPE.TXTSPD: default_speed = (float)temp_stk.Peek().time; speed = default_speed; temp_stk.Pop(); break; case token.TOKENTYPE.MOVEPOS: if (anim != null) { anim.transform.position = temp_stk.Peek().position; } temp_stk.Pop(); break; case token.TOKENTYPE.ANIMATION: //anim.GetComponent<o_actor>().anim_enum = (int)temp_stk.Peek().time; print((int)temp_stk.Peek().time); temp_stk.Pop(); break; case token.TOKENTYPE.FADE: Color fadecol = fad.GetComponent <Image>().color; fadecol.a = fad.GetComponent <Image>().color.a; StartCoroutine(Fade(fadecol, temp_stk.Peek().colour, (float)temp_stk.Peek().time)); temp_stk.Pop(); break; } } textthing.text += disptxt[current_text][currentline]; foreach (token tok in commands) { switch (tok.tokentype) { case token.TOKENTYPE.COLOUR: textthing.text += "</color>"; break; case token.TOKENTYPE.ITALICS: textthing.text += "</i>"; break; } } }