public TelemetryInformationContainer(ITelemetryParser telemetryParser, IPictureFetcher pictureFetcher, PlotCreator plotCreator) { countOfRecordsToStore = 20; this.pictureFetcher = pictureFetcher; DataParser = telemetryParser; creator = plotCreator; Measures = new Dictionary <string, IDataItem>(); LastTimestamps = new List <DateTime>(); }
private void UpdatePlot() { if (this._scores == null) { this._lblSelection.Text = this._errorMessage; this._lblSelection.ForeColor = Color.Red; this._chart.Visible = false; return; } this._chart.Visible = true; this._lblSelection.Text = ""; this._lblSelection.ForeColor = ForeColor; MCharting.Plot plot = new MCharting.Plot(); plot.Title = $"{this._lblMethod.Text} of {this._core.FileNames.Title}"; plot.SubTitle = $"Source: {this._lblPcaSource.Text}, View: {this._lblPlotView.Text}, Legend: {this._lblLegend.Text}, Corrections: {this._lblCorrections.Text}, Observations: {this._lblObs.Text}, Peaks: {this._lblPeaks.Text}"; switch (this._method) { case EMethod.Pca: plot.XLabel = $"PC{this._component + 1}"; plot.YLabel = $"PC{this._component + 2}"; break; case EMethod.Plsr: plot.XLabel = $"Component {this._component + 1}"; plot.YLabel = $"Component {this._component + 2}"; plot.SubTitle += ", PLSR Response: " + this._lblPlsrSource.Text; break; } this._chart.Style.Margin = new Padding(48, 48, 48, 48); plot.Style.GridStyle = new Pen(Color.FromArgb(224, 224, 224)); // Get the "rows" IEnumerator enSources; Column column; this.GetSource(this._colourBy, out enSources, out column); // Get the "columns" double[,] plotPoints; if (this._plotSource == EPlotSource.Loadings) { plotPoints = this._loadings; } else { plotPoints = this._scores; } // Get the component if (this._component < 0) { this._component = 0; } if (this._component >= plotPoints.GetLength(1)) { this._component = plotPoints.GetLength(1) - 1; } this._btnPrevPc.Enabled = this._component != 0; this._btnNextPc.Enabled = this._component != plotPoints.GetLength(1) - 1; this._lblPlotView.Text = this._plotSource == EPlotSource.Loadings ? "Loadings" : "Scores"; this._btnScores.Checked = this._plotSource == EPlotSource.Scores; this._btnLoadings.Checked = this._plotSource == EPlotSource.Loadings; this._lblPcNumber.Text = "PC" + (this._component + 1).ToString() + " / " + plotPoints.GetLength(1); this._lblLegend.Text = column.DisplayName; bool isGroup = false; // Iterate scores for (int r = 0; r < plotPoints.GetLength(0); r++) { enSources.MoveNext(); MCharting.Series series = GetOrCreateSeriesForValue(plot, column, (Visualisable)enSources.Current, ref isGroup); var coord = new MCharting.DataPoint(plotPoints[r, this._component], plotPoints[r, this._component + 1]); coord.Tag = enSources.Current; series.Points.Add(coord); } // Assign colours if (!column.HasColourSupport && !isGroup) { foreach (var colour in PlotCreator.AutoColour(plot.Series)) { colour.Key.Style.DrawPoints = new SolidBrush(colour.Value); } } this._chart.Style.Animate = true; this._chart.Style.SelectionColour = Color.Yellow; this._chart.SetPlot(plot); }
public void carryTask() { if (currentLine >= code.Length) { Done(); return; } string[] t = code[currentLine].Split(':'); string cmd = t[0]; if (t.Length <= 1) { currentLine++; carryTask(); return; } string[] p = t[1].Split(','); bool handler = false; currentLine++; Debug.Log("Drama script: (Command) '" + cmd + "' (Param) " + t[1]); // 人物路径任务 // path:人物,task1,task2,... if (cmd == "path") { Chara chara = GameObject.Find(p[0]).GetComponent <Chara>(); for (int i = 1; i < p.Length; i++) { float xB = 0, yB = 0; if (p[i].StartsWith("left")) { xB = -float.Parse(p[i].Substring(4)); } if (p[i].StartsWith("right")) { xB = float.Parse(p[i].Substring(5)); } if (p[i].StartsWith("up")) { yB = float.Parse(p[i].Substring(2)); } if (p[i].StartsWith("down")) { yB = -float.Parse(p[i].Substring(4)); } Debug.Log("Drama script: walk task enqueue:" + xB + "," + yB); chara.walkTasks.Enqueue(Chara.walkTask.fromStep(xB, yB)); } chara.walkTaskCallback = carryTask; handler = true; } // 人物朝向改动 // face:人物,dir if (cmd == "face") { Chara chara = GameObject.Find(p[0]).GetComponent <Chara>(); if (p[1] == "left") { chara.dir = Chara.walkDir.Left; } if (p[1] == "right") { chara.dir = Chara.walkDir.Right; } if (p[1] == "up") { chara.dir = Chara.walkDir.Up; } if (p[1] == "down") { chara.dir = Chara.walkDir.Down; } chara.UploadWalk(); handler = true; carryTask(); } // meta if (cmd == "exit") { Application.Quit(); } // 标签 // label:标签 // goto:标签 if (cmd == "label") { handler = true; carryTask(); } if (cmd == "goto") { for (int i = 0; i < code.Length; i++) { if (code[i] == "label:" + p[0]) { currentLine = i + 1; break; } } handler = true; carryTask(); } // 显示和隐藏 // show:物体 if (cmd == "show") { GameObject.Find(p[0]).SetActive(true); handler = true; carryTask(); } // hide:物体 if (cmd == "hide") { GameObject.Find(p[0]).SetActive(false); handler = true; carryTask(); } // 调查任务 // spy:调查内容 if (cmd == "spy") { Dramas.LaunchCheck(p[0], carryTask); handler = true; } // 退出脚本(如果最后一项任务是需要等待的,则需要加入此行缓冲) if (cmd == "break") { currentLine = code.Length; handler = true; } // 设置开关 // set:开关名,global/personal,true/false if (cmd == "set") { string key = ""; if (p[1] == "global") { key = p[0]; } if (p[1] == "personal") { key = parent.gameObject.scene + "." + parent.gameObject.name + "." + p[0]; } PlayerPrefs.SetString(key, p[2]); handler = true; carryTask(); } // 选择 // choice:标题,选项0,选项1,... if (cmd == "choice") { string explain = p[0]; List <string> choice = new List <string>(); for (int i = 1; i < p.Length; i++) { choice.Add(p[i]); } handler = true; MakeChoice.Create(carryTask, explain, choice.ToArray()); } if (cmd == "distribute_choices") { int buff = 0; while (true) { if (code[currentLine].StartsWith("choice:")) { buff++; } if (code[currentLine] == "endchoice:" && buff == 0) { break; } if (code[currentLine] == "case:" + MakeChoice.choiceId.ToString() && buff == 0) { break; } if (code[currentLine] == "endchoice:") { buff--; } Debug.Log("require:" + "case:" + MakeChoice.choiceId.ToString() + ",buff:" + buff + "\n" + code[currentLine]); currentLine++; } currentLine++; handler = true; carryTask(); } // case:选项编号 if (cmd == "case") { int buff = 0; while (true) { if (code[currentLine].StartsWith("choice:")) { buff++; } if (code[currentLine] == "endchoice:" && buff == 0) { break; } if (code[currentLine] == "endchoice:") { buff--; } currentLine++; } currentLine++; handler = true; carryTask(); } if (cmd == "endchoice") { handler = true; carryTask(); } // 触发器 // if:开关名,global/personal,要求的true/false if (cmd == "if") { string key = ""; if (p[1] == "global") { key = p[0]; } if (p[1] == "personal") { key = parent.gameObject.scene + "." + parent.gameObject.name + "." + p[0]; } string data = PlayerPrefs.GetString(key); if (p[2] != data) { int buff = 0; while (true) { if (code[currentLine].StartsWith("if:")) { buff++; } if (code[currentLine] == "endif:" && buff == 0) { break; } if (code[currentLine] == "else:" && buff == 0) { break; } if (code[currentLine] == "endif:") { buff--; } currentLine++; } currentLine++; } handler = true; carryTask(); } if (cmd == "else") { int buff = 0; while (true) { if (code[currentLine].StartsWith("if:")) { buff++; } if (code[currentLine] == "endif:" && buff == 0) { break; } if (code[currentLine] == "endif:") { buff--; } currentLine++; } currentLine++; handler = true; carryTask(); } if (cmd == "endif") { handler = true; carryTask(); } // 更换背景音乐 // bgm:背景音乐名 if (cmd == "bgm") { MapCamera.bgm.clip = (AudioClip)Resources.Load("BGM\\" + p[0]); MapCamera.bgm.Play(); handler = true; carryTask(); } // 更换环境音效 // bgs:环境音效名 if (cmd == "bgs") { MapCamera.bgs.clip = (AudioClip)Resources.Load("BGM\\" + p[0]); MapCamera.bgs.Play(); handler = true; carryTask(); } // 停止BGM // stopbgm if (cmd == "stopbgm") { MapCamera.bgm.Stop(); carryTask(); handler = true; } // stopbgs if (cmd == "stopbgs") { MapCamera.bgs.Stop(); carryTask(); handler = true; } // 恢复BGM // rebgm if (cmd == "rebgm") { MapCamera.bgm.Play(); carryTask(); handler = true; } // rebgs if (cmd == "rebgs") { MapCamera.bgs.Play(); carryTask(); handler = true; } // 等待任务 // wait:等待时间 if (cmd == "wait") { GameObject fab = (GameObject)Resources.Load("Prefabs\\WaitTicker"); // 载入母体 GameObject ticker = GameObject.Instantiate(fab, new Vector3(0, 0, -1), Quaternion.identity); WaitTicker wait = ticker.GetComponent <WaitTicker>(); wait.waitTime = float.Parse(p[0]); wait.callback = carryTask; handler = true; } // 音效任务 // snd:音效名称,nowait/wait if (cmd == "snd") { GameObject fab = (GameObject)Resources.Load("Prefabs\\MusicPlayer"); // 载入母体 GameObject player = GameObject.Instantiate(fab, new Vector3(0, 0, -1), Quaternion.identity); AudioSource source = player.GetComponent <AudioSource>(); source.clip = (AudioClip)Resources.Load("Snd\\" + p[0]); player.SetActive(true); source.Play(); GameObject.Destroy(player, source.clip.length); handler = true; if (p[1] == "nowait") { carryTask(); } if (p[1] == "wait") { player.GetComponent <DestoryCallback>().callback = carryTask; } } // 传送任务 // tp:地图名称;传送点编号;朝向 if (cmd == "tp") { MapCamera.initTp = int.Parse(p[1]); if (p[2] == "left") { MapCamera.initDir = Chara.walkDir.Left; } if (p[2] == "right") { MapCamera.initDir = Chara.walkDir.Right; } if (p[2] == "up") { MapCamera.initDir = Chara.walkDir.Up; } if (p[2] == "down") { MapCamera.initDir = Chara.walkDir.Down; } MapCamera.HitCheck = null; DramaScript nds = DramaCrossScene.Start(this); Switcher.Carry(p[0], UnityEngine.SceneManagement.LoadSceneMode.Single, 0, nds.carryTask); handler = true; } // 切换场景任务 // sw:场景名称 if (cmd == "sw") { MapCamera.HitCheck = null; DramaScript nds = DramaCrossScene.Start(this); Switcher.Carry(p[0], UnityEngine.SceneManagement.LoadSceneMode.Single, 0, nds.carryTask); if (MapCamera.bgm != null) { GameObject.Destroy(MapCamera.bgm); MapCamera.bgm = null; } if (MapCamera.bgs != null) { GameObject.Destroy(MapCamera.bgs); MapCamera.bgs = null; } handler = true; } // 情节任务 // plot:情节预制体名称/clear if (cmd == "plot") { if (p[0] == "clear") { PlotCreator.Clear(carryTask); } else { Loading.Start(() => { PlotCreator.LoadPlot(p[0]); Loading.Finish(); }, carryTask); } handler = true; } // 对话任务 // say/immersion:人物,[是否禁止输入] // [(shake)/(rainbow)/...]对话内容 if (cmd == "say" || cmd == "immersion") { // 创建剧本框架 bool dinput = false; if (p.Length > 1) { if (p[1] == "true") { dinput = true; } Debug.Log("DramaScript: say's third param detected:" + dinput); } Dramas drama = Dramas.LaunchScript(cmd == "say" ? "DialogFrameSrc" : "Immersion", carryTask); drama.Drama.Clear(); string role = p[0]; // 读取直至对话结束 while (currentLine + 1 < code.Length) { sayTag: t = code[currentLine].TrimStart().Split(':'); Debug.Log("Drama script: (Dialog) " + code[currentLine]); // 初始化对话参数 string motion = "Enter"; WordEffect.Effect effect = WordEffect.Effect.None; float speed = 0.03f; // 如果是对话 if (t.Length == 1) { // 格式化对话并提取附加参数 p = code[currentLine].TrimStart().Replace("(", ")").Split(')'); // 处理附加参数 for (int i = 1; i < p.Length; i += 2) { if (i == p.Length - 1) { break; } if (p[i] == "shake") { effect = WordEffect.Effect.Shake; } else if (p[i] == "rainbow") { effect = WordEffect.Effect.Rainbow; } else if (p[i] == "Leap" || p[i] == "Focus") { motion = p[i]; } else { speed = float.Parse(p[i]); } } // 装入结构体 Dramas.DramaData data = new Dramas.DramaData { Character = role, motion = motion, Effect = effect, content = p[p.Length - 1], Speed = speed }; // 添加对话 drama.Drama.Add(data); } else { // 对话读取结束,跳出 if (t[0] == cmd) { role = t[1]; currentLine++; goto sayTag; } break; } currentLine++; } // 刷新剧本 drama.ReadDrama(); drama.DisableInput = dinput; drama.gameObject.SetActive(true); lastDrama = drama; handler = true; if (dinput) { carryTask(); } } // 继续对话 if (cmd == "resume") { lastDrama.Resume(); handler = true; } // 未处理的脚本 if (!handler) { Debug.LogWarning("'" + cmd + $"'(行 {currentLine - 1})未被处理。"); carryTask(); return; } if (currentLine >= code.Length) { Done(); } }