public void Visit(Sequence seq) { int cmd_max = seq.data.Count - 1; var nowcmdid = cmd_max; var nowlog = nowCommandLogPosition; while (nowlog != null && nowlog.index < margine) { var verifyvistor = new CommandVerify(nowlog, margine); seq.data[nowcmdid].Accept(verifyvistor); if (verifyvistor.commandAcceptFlag) { nowlog = verifyvistor.nowCommandLogPosition; if (nowcmdid == 0) { commandAcceptFlag = true; nowCommandLogPosition = nowlog; return; } nowcmdid--; } else { if (nowcmdid == cmd_max) { commandAcceptFlag = false; return; } nowlog = nowlog.Next; } } commandAcceptFlag = false; }
public void Visit(SameTime same) { var oldestacceptlog = (LinkedListNode_Indexed)nowCommandLogPosition.Clone(); int?newestaccepttime = null; foreach (var e in same.data) { bool matched = false; var i = (LinkedListNode_Indexed)nowCommandLogPosition.Clone(); i.index = 0; for (; i != null && i.index < sametime_margine; i = i.Next) { var verifyvisitor = new CommandVerify(i, 1, i.index); e.Accept(verifyvisitor); if (verifyvisitor.commandAcceptFlag) { matched = true; if (oldestacceptlog.index < verifyvisitor.nowCommandLogPosition.index) { oldestacceptlog.index = verifyvisitor.nowCommandLogPosition.index; } if (newestaccepttime == null || verifyvisitor.nowCommandLogPosition.index < newestaccepttime.Value) { newestaccepttime = i.index; } break; } } if (!matched) { commandAcceptFlag = false; return; } } if (newestaccepttime == 0) { commandAcceptFlag = true; nowCommandLogPosition = oldestacceptlog; } else { commandAcceptFlag = false; nowCommandLogPosition = oldestacceptlog; } }
private void DrawLog() { var log = imgr.GetInputLog(); var text = buttonlist; text.text = ""; foreach (var e in log) { text.text += e.Key.ToString() + ":" + e.Value + "\n"; } var cmdtext = cmdlist; foreach (var cmd in cmds) { var verify = new CommandVerify(imgr.GetPressedTimeLog().First, 30); cmd.Value.Accept(verify); if (verify.commandAcceptFlag) { cmdtext.text = (cmd.Key + "\n") + cmdtext.text; break; } } var newinput = ""; foreach (var button in loglist) { var verify = new CommandVerify(imgr.GetPressedTimeLog().First, 1); button.cmd.Accept(verify); if (verify.commandAcceptFlag) { newinput += button.drawtext; } } if (newinput != "") { inputlog.text = newinput + "\n" + inputlog.text; } }
public void Accept(CommandVerify v) { v.Visit(this); }