/// <summary> /// The run method of the thread on which the <see cref="SevenZipExtractor"/> is created. /// </summary> /// <remarks> /// This method creates a <see cref="SevenZipExtractor"/> and then watches for events to execute. /// Other methods signal the thread that an action needs to be taken, and this thread executes said /// actions. /// </remarks> protected void RunThread() { m_szeExtractor = String.IsNullOrEmpty(m_strPath) ? new SevenZipExtractor(m_stmArchive) : new SevenZipExtractor(m_strPath); try { ActionPackage apkStartEvent = m_queEvents.Dequeue(); apkStartEvent.DoneEvent.Set(); while (true) { m_mreEvent.WaitOne(); ActionPackage apkEvent = m_queEvents.Dequeue(); if (apkEvent.Action == null) { break; } try { apkEvent.Action(); } catch (Exception e) { apkEvent.Exception = e; } m_mreEvent.Reset(); apkEvent.DoneEvent.Set(); } } finally { m_szeExtractor.Dispose(); } }
private void treeViewAction_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Level == 0) { comboBoxGesture.Visible = false; buttonSpy.Visible = true; CurrentActionPackage = Settings.ActionPackages[treeViewAction.SelectedNode.Index]; CurrentAction = null; textBoxName.Text = CurrentActionPackage.Name; textBoxCode.Text = CurrentActionPackage.Code; if (e.Node.Nodes.Count == 0) { CurrentActionPackage.Actions.Add(new Action("", "", "")); e.Node.Nodes.Add(""); e.Node.Expand(); } } else { comboBoxGesture.Visible = true; buttonSpy.Visible = false; CurrentActionPackage = Settings.ActionPackages[treeViewAction.SelectedNode.Parent.Index]; CurrentAction = CurrentActionPackage.Actions[treeViewAction.SelectedNode.Index]; textBoxName.Text = CurrentAction.Name; comboBoxGesture.SelectedValue = CurrentAction.Gesture; textBoxCode.Text = CurrentAction.Code; } }
/// <summary> /// 执行这条指令 /// </summary> public void Dash() { // 构造参数字典 var ArgDict = this.ArgumentList.ToDictionary(kvp => kvp.Key, kvp => new ArgumentPackage() { aType = kvp.Value.Key, valueExp = kvp.Value.Value }); // 构造新的动作包装 ActionPackage ap = new ActionPackage() { indent = this.indent, argsDict = ArgDict, nodeName = String.Format("{0}@{1}", this.commandLine, this.apType), nodeType = this.apType }; // 缓存编辑前的动作 this.LastAP = this.parent.GetAction(this.commandLine); // 更新后台 this.parent.ReplaceAction(ap, this.commandLine); // 更新前端 HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine); HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent, String.Format("◆{0}{1}{2}", ap.GetActionName(), ap.GetSpace(), ap.GetParaDescription())); }
/// <summary> /// Executes the given action. /// </summary> /// <remarks> /// This method: /// 1) Enqueues the action in the work queue. /// 2) Notifies the extraction thread that there is work to do. /// 3) Waits to be notified that the action has completed. /// 4) Throws any exception that was raised while executing the action. /// </remarks> /// <param name="p_actAction">The action to get the extractor to execute.</param> protected void ExecuteAction(Action p_actAction) { ActionPackage apkAction = new ActionPackage(p_actAction); m_queEvents.Enqueue(apkAction); m_mreEvent.Set(); apkAction.DoneEvent.WaitOne(); if (apkAction.Exception != null) { throw apkAction.Exception; } }
private void SyncPlayerAction() { ActionPackage package = PackageFactory.GetPackage(PackageType.Action) as ActionPackage; GameObject mainPlayer = HasActionObjectManager.Instance.playerManager.getMyPlayer(); GOPlayerController controller = mainPlayer.GetComponent <GOPlayerController>(); package.aoId = controller.playerAttribute.aoId; package.direction = controller.playerInputState.moveDirection; package.isJump = controller.playerInputState.jump; package.actionId = controller.goActionController.curAction.actionData.id; package.yRotate = mainPlayer.transform.localRotation.eulerAngles.y; SendPackage(package); }
/// <summary> /// Initializes the thread safe extractor. /// </summary> protected void Init() { m_queEvents = new Queue <ActionPackage>(); m_mreEvent = new ManualResetEvent(false); m_thdExtractor = new TrackedThread(RunThread); m_thdExtractor.Thread.IsBackground = false; m_thdExtractor.Thread.Name = "Seven Zip Extractor"; ActionPackage apkStart = new ActionPackage(null); m_queEvents.Enqueue(apkStart); m_thdExtractor.Start(); apkStart.DoneEvent.WaitOne(); }
/// <summary> /// 执行这条指令 /// </summary> public void Dash() { var ArgDict = this.ArgumentList.ToDictionary(kvp => kvp.Key, kvp => new ArgumentPackage() { aType = kvp.Value.Key, valueExp = kvp.Value.Value }); ActionPackage ap = new ActionPackage() { indent = this.indent, argsDict = ArgDict, nodeName = String.Format("{0}@{1}", this.commandLine, this.apType), nodeType = this.apType }; this.parent.AddAction(ap, this.commandLine); HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent, String.Format("◆{0}{1}{2}", ap.GetActionName(), ap.GetSpace(), ap.GetParaDescription())); }
/// <summary> /// 重载执行命令 /// </summary> public void Dash() { // IF节点 Dictionary <string, ArgumentPackage> ifArgDict = new Dictionary <string, ArgumentPackage>(); ifArgDict.Add("op1", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operand1 }); ifArgDict.Add("op2", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operand2 }); ifArgDict.Add("opr", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operateMode }); ifArgDict.Add("expr", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.condExpr }); ifArgDict.Add("?elseflag", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.isContainElse.ToString() }); ActionPackage ap1 = new ActionPackage() { indent = this.indent, argsDict = ifArgDict, nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_if.ToString()), nodeType = ActionPackageType.act_if }; // 缓存编辑前的动作 this.LastAP = this.parent.GetAction(this.commandLine); // 更新后台 this.parent.ReplaceAction(ap1, this.commandLine); // 更新前端 HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine); HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap1.indent, String.Format("◆{0}{1}{2}", ap1.GetActionName(), ap1.GetSpace(), ap1.GetParaDescription())); }
/// <summary> /// 建立一个新工程 /// </summary> /// <param name="path">要建立工程的目录</param> /// <param name="projName">工程名称</param> public void NewProject(string path, string projName) { FileManager.CreateInitFolder(string.Format("{0}\\{1}", path, projName)); Halation.project = new ProjectPackage(projName); Halation.project.AddScene("main"); ActionPackage initap = new ActionPackage() { nodeType = ActionPackageType.act_dialog }; initap.argsDict.Add("context", new ArgumentPackage() { aType = ArgType.unknown, valueExp = "欢迎来到Yuri世界!" }); Halation.project.GetScene("main").AddAction(initap, 0); Halation.project.GetScene("main").AddFunction("rclick", new List <string>()); Halation.projectName = projName; Halation.mainView.Text = String.Format("Yuri Halation - [{0}]", Halation.projectName); FileManager.Serialization(Halation.project, string.Format("{0}\\{1}\\game.yrproj", path, projName)); Halation.projectFolder = string.Format("{0}\\{1}", path, projName); }
/// <summary> /// 重载执行命令 /// </summary> public void Dash() { // FOR节点 ActionPackage ap = new ActionPackage() { indent = this.indent, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_for.ToString()), nodeType = ActionPackageType.act_for }; this.parent.AddAction(ap, this.commandLine); HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent, "◆循环"); // PAD节点 ActionPackage ap2 = new ActionPackage() { indent = this.indent + 2, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = "pad", nodeType = ActionPackageType.NOP }; this.parent.AddAction(ap2, this.commandLine + 1); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 1, ap2.indent, "◆"); // ENDFOR节点 ActionPackage ap3 = new ActionPackage() { indent = this.indent, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endfor.ToString()), nodeType = ActionPackageType.act_endfor }; this.parent.AddAction(ap3, this.commandLine + 2); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap3.indent, ":以上反复"); }
/// <summary> /// 重载执行命令 /// </summary> public void Dash() { // IF节点 Dictionary <string, ArgumentPackage> ifArgDict = new Dictionary <string, ArgumentPackage>(); ifArgDict.Add("op1", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operand1 }); ifArgDict.Add("op2", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operand2 }); ifArgDict.Add("opr", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.operateMode }); ifArgDict.Add("expr", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.condExpr }); ifArgDict.Add("?elseflag", new ArgumentPackage() { aType = ArgType.unknown, valueExp = this.isContainElse.ToString() }); ActionPackage ap1 = new ActionPackage() { indent = this.indent, argsDict = ifArgDict, nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_if.ToString()), nodeType = ActionPackageType.act_if }; this.parent.AddAction(ap1, this.commandLine); HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap1.indent, String.Format("◆{0}{1}{2}", ap1.GetActionName(), ap1.GetSpace(), ap1.GetParaDescription())); // PAD节点 ActionPackage ap2 = new ActionPackage() { indent = this.indent + 2, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = "pad", nodeType = ActionPackageType.NOP }; this.parent.AddAction(ap2, this.commandLine + 1); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 1, ap2.indent, "◆"); // 考虑ELSE子句 if (this.isContainElse) { // ELSE节点 ActionPackage ap3 = new ActionPackage() { indent = this.indent, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_else.ToString()), nodeType = ActionPackageType.act_else }; this.parent.AddAction(ap3, this.commandLine + 2); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap3.indent, ":除此以外的情况"); // PAD节点 ActionPackage ap4 = new ActionPackage() { indent = this.indent + 2, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = "pad", nodeType = ActionPackageType.NOP }; this.parent.AddAction(ap4, this.commandLine + 3); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 3, ap4.indent, "◆"); // ENDIF节点 ActionPackage ap5 = new ActionPackage() { indent = this.indent, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endif.ToString()), nodeType = ActionPackageType.act_endif }; this.parent.AddAction(ap5, this.commandLine + 4); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 4, ap5.indent, ":分支结束"); } else { // ENDIF节点(这里不能与上面的endif合并,因为commandline有变化) ActionPackage ap6 = new ActionPackage() { indent = this.indent, argsDict = new Dictionary <string, ArgumentPackage>(), nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endif.ToString()), nodeType = ActionPackageType.act_endif }; this.parent.AddAction(ap6, this.commandLine + 2); HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap6.indent, ":分支结束"); } }
/// <summary> /// Executes the given action. /// </summary> /// <remarks> /// This method: /// 1) Enqueues the action in the work queue. /// 2) Notifies the extraction thread that there is work to do. /// 3) Waits to be notified that the action has completed. /// 4) Throws any exception that was raised while executing the action. /// </remarks> /// <param name="p_actAction">The action to get the extractor to execute.</param> protected void ExecuteAction(Action p_actAction) { ActionPackage apkAction = new ActionPackage(p_actAction); m_queEvents.Enqueue(apkAction); m_mreEvent.Set(); apkAction.DoneEvent.WaitOne(); if (apkAction.Exception != null) throw apkAction.Exception; }
/// <summary> /// Initializes the thread safe extractor. /// </summary> protected void Init() { m_queEvents = new Queue<ActionPackage>(); m_mreEvent = new ManualResetEvent(false); m_thdExtractor = new TrackedThread(RunThread); m_thdExtractor.Thread.IsBackground = false; m_thdExtractor.Thread.Name = "Seven Zip Extractor"; ActionPackage apkStart = new ActionPackage(null); m_queEvents.Enqueue(apkStart); m_thdExtractor.Start(); apkStart.DoneEvent.WaitOne(); }