Example #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);
                }
            }
        }
Example #2
0
        public List <CustomIdentification> GetNodeList()
        {
            if (nodeList.Count > 0)
            {
                return(nodeList);
            }

            #region Skill
            CustomIdentification skillPhaseState = SkillPhaseState._customIdentification;
            nodeList.Add(skillPhaseState);

            CustomIdentification skillHold = SkillHoldSkillState._customIdentification;
            nodeList.Add(skillHold);

            CustomIdentification fishHold = SkillHoldFishState._customIdentification;
            nodeList.Add(fishHold);

            CustomIdentification skillNotify = SkillNotifyState._customIdentification;
            nodeList.Add(skillNotify);

            CustomIdentification nextStage = SkillNextStage._customIdentification;
            nodeList.Add(nextStage);

            CustomIdentification exitSkill = SkillExitState._customIdentification;
            nodeList.Add(exitSkill);
            #endregion

            #region Sub-Machine
            CustomIdentification subMachineSkill = SubMachineSkill._customIdentification;
            nodeList.Add(subMachineSkill);
            #endregion

            #region Entry
            CustomIdentification entry = HSMStateEntry._customIdentification;
            nodeList.Add(entry);
            #endregion

            #region Exit
            CustomIdentification exit = HSMStateExit._customIdentification;
            nodeList.Add(exit);
            #endregion

            HashSet <IDENTIFICATION> hash = new HashSet <IDENTIFICATION>();
            for (int i = 0; i < nodeList.Count; ++i)
            {
                CustomIdentification identificationi = nodeList[i];
                if (hash.Contains(identificationi.Identification))
                {
                    Debug.LogError("重复的 Identification:" + identificationi.Identification);
                    break;
                }
                hash.Add(identificationi.Identification);
            }

            return(nodeList);
        }
Example #3
0
        public object GetState(IDENTIFICATION identification)
        {
            object obj = null;
            CustomIdentification info = GetIdentification(identification);

            if (info.Valid())
            {
                obj = info.Create();
            }
            return(obj);
        }
Example #4
0
        public CustomIdentification GetIdentification(IDENTIFICATION identification)
        {
            GetNodeList();

            for (int i = 0; i < nodeList.Count; ++i)
            {
                CustomIdentification info = nodeList[i];
                if (info.Identification == identification)
                {
                    return(info);
                }
            }

            return(new CustomIdentification());
        }
Example #5
0
        public void Draw(SkillHsmConfigNodeData nodeValue)
        {
            if (null == nodeValue)
            {
                EditorGUILayout.LabelField("未选择节点");
                return;
            }

            EditorGUILayout.BeginVertical("box");
            {
                //string nodeId = string.Format("节点  ID:{0}", nodeValue.Id);
                //EditorGUILayout.LabelField(nodeId);

                int    index = EnumNames.GetEnumIndex <NODE_TYPE>((NODE_TYPE)nodeValue.NodeType);
                string name  = EnumNames.GetEnumName <NODE_TYPE>(index);
                name = string.Format("节点类型:{0}", name);
                EditorGUILayout.LabelField(name);

                if (nodeValue.Identification > 0)
                {
                    CustomIdentification customIdentification = CustomNode.Instance.GetIdentification((IDENTIFICATION)nodeValue.Identification);
                    string typeName = string.Format("类     型:{0}", customIdentification.Name);
                    EditorGUILayout.LabelField(typeName);

                    string className = string.Format("类     名:{0}", customIdentification.Type.Name);
                    EditorGUILayout.LabelField(className);

                    //string identificationName = string.Format("类标识  :{0}", nodeValue.Identification);
                    //EditorGUILayout.LabelField(identificationName);
                }
                GUILayout.Space(5);

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("节点名:", GUILayout.Width(50));
                    nodeValue.NodeName = EditorGUILayout.TextField(nodeValue.NodeName, GUILayout.ExpandWidth(true));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.LabelField("节点描述:");
                nodeValue.Descript = EditorGUILayout.TextArea(nodeValue.Descript, GUILayout.Height(30));
                GUILayout.Space(5);
            }
            EditorGUILayout.EndVertical();

            DrawNode(nodeValue);
        }