private void Start() { manager = FindObjectOfType <GameManager>(); text = GetComponent <TextController>(); command = GetComponent <CommandController>(); visualizer = GetComponentInChildren <CharacterVisualizer>(); audio = GetComponent <AudioSource>(); group = GetComponent <CanvasGroup>(); background = transform.Find("Background").gameObject.GetComponent <Image>(); overLayer = transform.Find("Overlay").gameObject.GetComponent <Image>(); //var texts = scenarioText.ToString(); if (scenarioText != null) { AnalysisScenario(); } action = (_) => { if (IsEnabled) { int current = text.CurrentLine; while (current < Lines.Count && command.IsCommand(current)) { command.Execute(this, command[current]); current++; } text.CurrentLine = current; if (current < Lines.Count && !command.IsCommand(current)) { text.TextUpdate(Lines[current]); } if (current >= Lines.Count) { var tween = DOTween.To(() => group.alpha, (a) => group.alpha = a, 0.0f, 1.0f); if (!overlay) { tween.OnComplete(() => manager.ChangeScene(nextScene)); } else { tween.OnComplete(() => Disable()); } } } }; this.OnKeyDownAsObservable(KeyCode.Space).Subscribe(action).AddTo(this); this.OnKeyDownAsObservable(KeyCode.Return).Subscribe(action).AddTo(this); action.Invoke(new Unit()); }
public void AnalysisScenario(string rawText) { //Debug.Log(rawText); command.ResetCommand(); text.ResetText(); visualizer.InvisibleAll(); TextLines = rawText.Split('\n'); if (Lines == null) { Lines = new List <Line>(); } else { Lines.Clear(); } var regex = new Regex(@"\[.*]", RegexOptions.Compiled); //Debug.Log(regex); for (int i = 0; i < TextLines.Length; i++) { // 空行はスキップ if (string.IsNullOrEmpty(TextLines[i])) { continue; } var line = new Line { Type = LineType.NormalText, LineCount = i, Text = TextLines[i] }; if (regex.IsMatch(line.Text)) { line.Type = LineType.Command; var commands = CommandController.Analysis(line); if (commands.tag == "br") { line.Type = LineType.WaitText; line.Text = line.Text.Replace("[br]", "\n"); } else { command.Add(commands); } } Lines.Add(line); } //action.Invoke(new Unit()); }