public void nextAction() { frameIdx += 1; if (model.frames [frameIdx].DialogType == eDialogFrameType.CHANGE_TEXT) { DialogFrameText realFrame = model.frames [frameIdx] as DialogFrameText; cursorF = 0.0f; cursorI = 0; view.dialogContent.text = ""; isReading = true; view.nameText.text = realFrame.Name; } else if (model.frames [frameIdx].DialogType == eDialogFrameType.CHANGE_LIHUI) { isMovingLihui = false; } else if (model.frames [frameIdx].DialogType == eDialogFrameType.CHANGE_BG) { DialogFrameBG realFrame = model.frames [frameIdx] as DialogFrameBG; Debug.Log("change"); //view.bg.sprite = null; } else if (model.frames [frameIdx].DialogType == eDialogFrameType.END) { } else if (model.frames [frameIdx].DialogType == eDialogFrameType.SHOW_BRANCH) { DialogFrameBranch realFrame = model.frames [frameIdx] as DialogFrameBranch; ShowBranch(realFrame.Choices); } else if (model.frames [frameIdx].DialogType == eDialogFrameType.EFFECT) { isEffecting = false; } }
public DialogBlock ReadFromTxt(List <string> input) { List <DialogFrameBase> dialogs = new List <DialogFrameBase> (); int InstId = 0; foreach (string line in input) { if (string.IsNullOrEmpty(line)) { continue; } DialogFrameBase dialogFrame; if (line.StartsWith("[")) { dialogFrame = new DialogFrameText(); dialogFrame.DialogType = eDialogFrameType.CHANGE_TEXT; int i = 1; int j = i; while (j < line.Length && line [j] != ']') { j++; } string speaker = line.Substring(i, j - i); if (speaker.Contains(",")) { ((DialogFrameText)dialogFrame).Name = speaker.Substring(0, line.IndexOf(",")); ((DialogFrameText)dialogFrame).LihuiIdx = int.Parse(speaker.Substring(line.IndexOf(",") + 1)); } else { ((DialogFrameText)dialogFrame).Name = speaker; } i = line.IndexOf(":") + 1; string words = line.Substring(i); ((DialogFrameText)dialogFrame).TextLines = preHandleWords(words); } else if (line.StartsWith("Lihui")) { dialogFrame = new DialogFrameLihui(); dialogFrame.DialogType = eDialogFrameType.CHANGE_LIHUI; string str = line.Substring(6); string[] cmds = str.Split(','); foreach (string cmd in cmds) { string[] args = cmd.Trim().Split(' '); string Opt = args [0]; string Lid = args [1]; int SlotIdx = int.Parse(args [2]); ((DialogFrameLihui)dialogFrame).Opts.Add(Opt); ((DialogFrameLihui)dialogFrame).Lids.Add(Lid); ((DialogFrameLihui)dialogFrame).SlotIdxs.Add(SlotIdx); } } else if (line.StartsWith("BG")) { dialogFrame = new DialogFrameBG(); dialogFrame.DialogType = eDialogFrameType.CHANGE_BG; string str = line.Substring(3); string[] args = str.Trim().Split(' '); if (args.Length > 1) { ((DialogFrameBG)dialogFrame).BGM = args [1]; } ((DialogFrameBG)dialogFrame).BG = args [0]; } else if (line.StartsWith("Effect")) { dialogFrame = new DialogFrameEffect(); dialogFrame.DialogType = eDialogFrameType.EFFECT; string str = line.Substring(7); ((DialogFrameEffect)dialogFrame).EffectId = str; } else if (line.StartsWith("End")) { dialogFrame = new DialogFrameEnd(); dialogFrame.DialogType = eDialogFrameType.END; } else if (line.StartsWith("Branch")) { dialogFrame = new DialogFrameBranch(); dialogFrame.DialogType = eDialogFrameType.SHOW_BRANCH; string str = line.Substring(7); string[] branches = str.Split(','); foreach (string branch in branches) { string[] ops = branch.Split(' '); ((DialogFrameBranch)dialogFrame).Choices.Add(ops[0]); } } else { throw new UnityException("not defined dialog type"); } dialogFrame.Index = InstId++; dialogs.Add(dialogFrame); } DialogBlock ret = new DialogBlock(); ret.frames = dialogs; return(ret); }