Ejemplo n.º 1
0
        private static void processBreaked(string msg)
        {
            string msg_real = msg.Substring(9);

            if (msg_real.StartsWith("[applog]"))
            {
                FrameStatePool.RespondToCPPBreak(AgentDataPool.TotalFrames, msg_real);
            }
            else
            {
                //[breaked]Ship::Ship_1 ships\basic.xml->BehaviorTree[0]:enter [all/success/failure] [1]
                string[] tokens = msg_real.Split(' ');

                if (tokens.Length == 4)
                {
                    string agentFullname = tokens[0];
                    //if (string.IsNullOrEmpty(Plugin.DebugAgentInstance))
                    {
                        Plugin.DebugAgentInstance = agentFullname;
                    }

                    string[] nodes = tokens[1].Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                    if (nodes.Length == 2)
                    {
                        string[] actions = nodes[1].Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);

                        if (actions.Length == 3)
                        {
                            Debug.Check(actions[2].StartsWith(":"));
                            string   actionName    = actions[2].Substring(1);
                            string[] actionResults = tokens[2].Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);

                            //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action
                            //it can only be success or failure
                            Debug.Check(actionResults.Length == 1 && (actionResults[0] == "success" || actionResults[0] == "failure") || actionResults[0] == "all");

                            string[] hitCounts = tokens[3].Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                            int      hitCount  = int.Parse(hitCounts[0]);

                            if (actionName == "plan")
                            {
                                NodeTreeList.ShowPlanning(agentFullname, AgentDataPool.TotalFrames, hitCount);
                            }

                            FrameStatePool.RespondToAPPBreak(agentFullname, AgentDataPool.TotalFrames, nodes[0], actions[1], actionName, actionResults[0], hitCount);
                        }
                    }
                }
            }

            Plugin.UpdateMode = UpdateModes.Break;
        }
Ejemplo n.º 2
0
        private void RegisterBehaviorTreeList(BehaviorTreeListDock dock)
        {
            behaviorTreeListDock = dock;
            behaviorTreeList = dock.behaviorTreeList;
            nodeTreeList = dock.nodeTreeList;

            RegisterDelegateHandlers();
        }
Ejemplo n.º 3
0
        private void loadLayout(EditModes editMode, string layoutFile, bool bLoadWks)
        {
            preLoadLayout(editMode);

            __layoutFile = layoutFile;

            // Remove all controls and create a new dockPanel.
            this.Controls.Clear();

            InitializeComponent();

            this.RecentWorkspacesMenu = new RecentMenu(this.recentWorkspacesMenuItem, new RecentMenu.ClickedHandler(OnMenuRecentWorkspaces), "SOFTWARE\\Tencent\\Tag\\Behaviac\\MRU");

            this.FormClosed -= this.MainWindow_FormClosed;
            this.FormClosed += this.MainWindow_FormClosed;
            this.KeyDown -= this.MainWindow_KeyDown;
            this.KeyDown += this.MainWindow_KeyDown;

            // Display the file version
            this.Text = "BehaviacDesigner " + this.ProductVersion;

            // Set the stored settings for the window
            this.WindowState = Settings.Default.MainWindowState;
            if (this.WindowState == FormWindowState.Normal)
            {
                this.Size = Settings.Default.MainWindowSize;
                this.Location = Settings.Default.MainWindowLocation;
                this.PerformLayout();
            }

            // If we have no stored layout, generate a default one
            if (behaviorTreeListDock != null)
            {
                nodeTreeList.Dispose();
                nodeTreeList = null;

                behaviorTreeList.Dispose();
                behaviorTreeList = null;

                behaviorTreeListDock.Close();
                behaviorTreeListDock = null;
            }

            bool layoutFileExisting = System.IO.File.Exists(layoutFile);
            if (layoutFileExisting)
            {
                // Add child controls for the dockPanel from the layout file.
                dockPanel.LoadFromXml(layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString));

                if (this.behaviorTreeList == null)
                {
                    //the corrupt layout file was deleted
                    layoutFileExisting = false;
                }
            }

            if (!layoutFileExisting)
            {
                BehaviorTreeListDock btlDock = new BehaviorTreeListDock();
                RegisterBehaviorTreeList(btlDock);
                btlDock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockLeft);

                PropertiesDock dock = new PropertiesDock();
                dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockRight);
            }

            if (this.WindowState == FormWindowState.Maximized)
            {
                this.Hide();
                this.WindowState = FormWindowState.Minimized;
                this.WindowState = FormWindowState.Maximized;
                this.Show();

                if (!layoutFileExisting)
                {
                    this.dockPanel.Size = new Size(this.Size.Width - 20, this.Size.Height - 68);
                }
            }

            postLoadLayout(editMode, bLoadWks);

            // Make sure the window is focused
            Focus();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads all plugins form a directory.
        /// </summary>
        /// <param name="path">The directory which is the root for the given list of plugins.</param>
        internal void LoadPlugins(NodeTreeList nodeTreeList, bool bAddNodes)
        {
            Plugin.InitNodeGroups();

            Plugin.LoadPlugins(RegisterPlugin, nodeTreeList, bAddNodes);

            if (bAddNodes)
            {
                // create the tree nodes for all behaviac nodes.
                TreeView root = (nodeTreeList != null) ? nodeTreeList.TreeView : treeView;
                foreach (NodeGroup group in Plugin.NodeGroups)
                {
                    group.Register(root.Nodes);
                }

                if (root.GetNodeCount(false) > 0)
                {
                    UIUtilities.SortTreeview(root.Nodes);
                    root.SelectedNode = root.Nodes[0];
                }
            }

            // update labels
            newBehaviorButton.Text = Plugin.GetResourceString("NewBehavior") + " (Ctrl+N)";
            _behaviorGroupName = Plugin.GetResourceString("BehaviorGroupName");
            _prefabGroupName = Plugin.GetResourceString("PrefabGroupName");
        }
Ejemplo n.º 5
0
        internal void UnLoadPlugins(NodeTreeList nodeTreeList)
        {
            Plugin.UnLoadPlugins();

            _fileManagers.Clear();

            treeView.Nodes.Clear();
            if (nodeTreeList != null)
                nodeTreeList.Clear();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads all plugins form a directory.
        /// </summary>
        /// <param name="path">The directory which is the root for the given list of plugins.</param>
        internal void LoadPlugins(NodeTreeList nodeTreeList, bool bAddNodes)
        {
            Plugin.LoadPlugins(RegisterPlugin, nodeTreeList.ImageList, bAddNodes);

            if (bAddNodes)
            {
                // create the tree nodes for all behavior nodes.
                TreeView root = (nodeTreeList != null) ? nodeTreeList.TreeView : treeView;

                nodeTreeList.ToggleShowSelectedNodes(Plugin.OnlyShowFrequentlyUsedNodes, root);
            }

            // update labels
            newBehaviorButton.Text = Plugin.GetResourceString("NewBehavior") + " (Ctrl+N)";
            //_behaviorGroupName = Plugin.GetResourceString("BehaviorGroupName");
            //_prefabGroupName = Plugin.GetResourceString("PrefabGroupName");
        }