Exemplo n.º 1
0
        private void Config <T>(string name, int identification)
        {
            CustomIdentification customIdentification = new CustomIdentification(name, identification, typeof(T));

            if (null != ConfigEvent)
            {
                ConfigEvent(customIdentification);
            }
        }
Exemplo n.º 2
0
        private void Config <T>(string name) where T : NodeLeaf, new()
        {
            ICustomIdentification <NodeLeaf> customIdentification = new CustomIdentification <T>(name, typeof(T));

            if (null != ConfigEvent)
            {
                ConfigEvent(customIdentification);
            }
        }
Exemplo n.º 3
0
        public object GetNode(int identification)
        {
            object obj = null;
            CustomIdentification info = GetIdentification(identification);

            if (info.Valid())
            {
                obj = info.Create();
            }
            return(obj);
        }
Exemplo n.º 4
0
        private void AddIdentification(CustomIdentification customIdentification)
        {
            if (hash.Contains(customIdentification.Identification))
            {
                Debug.LogError("重复的 Identification:" + customIdentification.Identification);
                return;
            }
            hash.Add(customIdentification.Identification);

            nodeList.Add(customIdentification);
        }
Exemplo n.º 5
0
        public CustomIdentification GetIdentification(int identification)
        {
            for (int i = 0; i < nodeList.Count; ++i)
            {
                CustomIdentification info = nodeList[i];
                if (info.Identification == (int)identification)
                {
                    return(info);
                }
            }

            return(new CustomIdentification());
        }
Exemplo n.º 6
0
        public void Draw(NodeValue nodeValue)
        {
            if (null == nodeValue)
            {
                EditorGUILayout.LabelField("未选择节点");
                return;
            }

            EditorGUILayout.BeginVertical("box");
            {
                if (nodeValue.NodeType == (int)NODE_TYPE.CONDITION ||
                    nodeValue.NodeType == (int)NODE_TYPE.ACTION)
                {
                    int    index = EnumNames.GetEnumIndex <NODE_TYPE>((NODE_TYPE)nodeValue.NodeType);
                    string name  = EnumNames.GetEnumName <NODE_TYPE>(index);
                    EditorGUILayout.LabelField(name);
                    GUILayout.Space(5);
                }

                string nodeName = nodeValue.nodeName;
                EditorGUILayout.LabelField(nodeName);

                string nodeId = string.Format("节点_{0}", nodeValue.id);
                EditorGUILayout.LabelField(nodeId);

                GUI.enabled          = false;
                nodeValue.isRootNode = EditorGUILayout.Toggle(new GUIContent("根节点"), nodeValue.isRootNode, GUILayout.Width(50));
                GUI.enabled          = true;

                if (nodeValue.parentNodeID >= 0)
                {
                    string parentName = string.Format("父节点_{0}", nodeValue.parentNodeID);
                    EditorGUILayout.LabelField(parentName);
                }

                if (nodeValue.identification > 0)
                {
                    string identificationName = string.Format("类标识_{0}", nodeValue.identification);
                    EditorGUILayout.LabelField(identificationName);

                    CustomIdentification customIdentification = CustomNode.Instance.GetIdentification(nodeValue.identification);
                    string className = customIdentification.ClassType.Name;
                    EditorGUILayout.LabelField(className);
                }

                nodeValue.descript = EditorGUILayout.TextArea(nodeValue.descript, GUILayout.Height(50));
            }
            EditorGUILayout.EndVertical();

            DrawNode(nodeValue, "参数");
        }
Exemplo n.º 7
0
        public List <CustomIdentification> GetNodeList()
        {
            if (nodeList.Count > 0)
            {
                return(nodeList);
            }


            #region Skill
            // 条件节点
            {
                CustomIdentification input = NodeConditionInput.CustomIdentification();
                nodeList.Add(input);

                CustomIdentification skillState = NodeConditionSkillState.CustomIdentification();
                nodeList.Add(skillState);

                CustomIdentification general = NodeConditionGeneral.CustomIdentification();
                nodeList.Add(general);
            }

            // 行为节点
            {
                CustomIdentification requestSkillState = NodeActionRequestSkillState.CustomIdentification();
                nodeList.Add(requestSkillState);
            }
            #endregion

            #region Human
            // 条件节点
            {
                CustomIdentification custom = NodeConditionCustom.CustomIdentification();
                nodeList.Add(custom);
            }

            // 行为节点
            {
                CustomIdentification cooking = NodeActionCooking.CustomIdentification();
                nodeList.Add(cooking);

                CustomIdentification eat = NodeActionEat.CustomIdentification();
                nodeList.Add(eat);

                CustomIdentification move = NodeActionMove.CustomIdentification();
                nodeList.Add(move);

                CustomIdentification watchTv = NodeActionWatchTV.CustomIdentification();
                nodeList.Add(watchTv);
            }
            #endregion

            HashSet <int> hash = new HashSet <int>();
            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);
        }