Ejemplo n.º 1
0
        private void SetInfoList()
        {
            // 状态节点
            Node_Draw_Info stateDrawInfo = new Node_Draw_Info("CreateState");

            //stateDrawInfo.AddNodeType(NODE_TYPE.STATE);
            infoList.Add(stateDrawInfo);

            // 子状态机节点
            Node_Draw_Info subMachineDrawInfo = new Node_Draw_Info("Create-Sub State Machine");

            subMachineDrawInfo.AddNodeType(NODE_TYPE.SUB_STATE_MACHINE);
            infoList.Add(subMachineDrawInfo);

            List <CustomIdentification> nodeList = CustomNode.Instance.GetNodeList();

            for (int i = 0; i < nodeList.Count; ++i)
            {
                CustomIdentification customIdentification = nodeList[i];
                if (customIdentification.NodeType == NODE_TYPE.STATE)
                {
                    stateDrawInfo.AddNodeType(NODE_TYPE.STATE, customIdentification.Name, (int)customIdentification.Identification);
                }
                else if (customIdentification.NodeType == NODE_TYPE.SUB_STATE_MACHINE)
                {
                    subMachineDrawInfo.AddNodeType(NODE_TYPE.SUB_STATE_MACHINE, customIdentification.Name, (int)customIdentification.Identification);
                }
            }
        }
Ejemplo n.º 2
0
        private void ShowMenu(SkillHsmConfigNodeData currentNode, SkillHsmConfigNodeData nodeValue)
        {
            int menuType = (nodeValue != null) ? 1 : 0;

            GenericMenu menu = new GenericMenu();

            if (menuType == 0)
            {
                GenericMenu.MenuFunction2 CallBack = (object userData) => {
                    if (null != HSMManager.hSMAddState)
                    {
                        int subMachineId = -1;
                        if (HSMManager.Instance.CurrentOpenSubMachineId >= 0)
                        {
                            subMachineId = HSMManager.Instance.CurrentOpenSubMachineId;
                        }
                        HSMManager.hSMAddState((Node_Draw_Info_Item)userData, mousePosition, subMachineId);
                    }
                };

                List <Node_Draw_Info> nodeList = _drawController._HSMDrawModel.InfoList;
                for (int i = 0; i < nodeList.Count; ++i)
                {
                    Node_Draw_Info draw_Info = nodeList[i];
                    for (int j = 0; j < draw_Info._nodeArr.Count; ++j)
                    {
                        KeyValuePair <string, Node_Draw_Info_Item> kv = draw_Info._nodeArr[j];
                        string itemName = string.Format("{0}", kv.Key);
                        menu.AddItem(new GUIContent(itemName), false, CallBack, kv.Value);
                    }
                }
            }
            else
            {
                if (null != currentNode && nodeValue.Id == currentNode.Id && nodeValue.NodeType != (int)NODE_TYPE.EXIT)
                {
                    // 连线子节点
                    menu.AddItem(new GUIContent("Make Transition"), false, MakeTransition);
                    menu.AddSeparator("");
                }

                if (null != currentNode && (currentNode.NodeType != (int)NODE_TYPE.ENTRY && (currentNode.NodeType != (int)NODE_TYPE.EXIT)))
                {
                    // 删除节点
                    menu.AddItem(new GUIContent("Delete State"), false, DeleteNode);
                }

                if (nodeValue.NodeType != (int)NODE_TYPE.ENTRY && nodeValue.NodeType != (int)NODE_TYPE.EXIT)
                {
                    // 设置默认节点
                    menu.AddItem(new GUIContent("Set Default State"), false, SetDefaultState);
                }
            }

            menu.ShowAsContext();
            Event.current.Use();
        }