Ejemplo n.º 1
0
        public bool checkCanFinish()
        {
            if (checkAllValueValid() == false)
            {
                s_errorString = string.Format("node type {0} value invalid", m_eNodeType.ToString());
                return(false);
            }

            if (m_vChildNode.Count == 0 && m_eNodeType != eNodeType.eNode_BetTimes)
            {
                s_errorString = string.Format("node type {0} , value :{1} have no child", m_eNodeType.ToString(), currentValue);
                return(false);
            }

            foreach (NodeData tdata in m_vChildNode.Values)
            {
                if (tdata.checkCanFinish() == false)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static bool CreateLevel <T>(GameObject settingGameObject, eNodeType nodeType, Transform parent, ref T level) where T : LevelBase, new()
        {
            if (level != null)
            {
                return(false);
            }

            if (settingGameObject == null)
            {
                string[] gameObjectNames = StringUtil.Split(nodeType.ToString(), ".");
                if (gameObjectNames.Any() == false)
                {
                    throw new System.Exception(StringUtil.Format("null is gameObjectNames", nodeType.ToString()));
                }

                settingGameObject     = new GameObject(gameObjectNames[gameObjectNames.Length - 1]);
                settingGameObject.tag = string.IsNullOrEmpty(parent.tag) ? settingGameObject.name : parent.tag;
            }

            level = (T)System.Activator.CreateInstance(typeof(T));
            level.SetParentTransform(settingGameObject, parent);
            return((level != null) ? true : false);
        }
Ejemplo n.º 3
0
        IBaseNode IDecisionTree.CreateNewNode(eNodeType nodeType, IBaseNode parent, string name)
        {
            IBaseNode result = null;

            if (name == "")
            {
                name = GetNodeName(nodeType.ToString(), parent);
            }

            switch (nodeType)
            {
            case eNodeType.Root:
                result = IDecisionTreeInterface.CreateNewNode(typeof(IRootNodeImpl).ToString());
                break;

            case eNodeType.VariableDefinitions:
                name   = Constants.VariableTreeName;
                result = IDecisionTreeInterface.CreateNewNode(typeof(IBaseNodeImpl).ToString());
                break;

            case eNodeType.VarDefinition:
                name   = GetNodeName("variable", parent);
                result = IDecisionTreeInterface.CreateNewNode(typeof(CharVariableImpl).ToString());
                break;

            case eNodeType.DomainObject:
                name   = GetNodeName("domain object", parent);
                result = IDecisionTreeInterface.CreateNewNode(typeof(IDomainObjectImpl).ToString());
                break;

            case eNodeType.Expression:
                result = IDecisionTreeInterface.CreateNewNode(typeof(IExpressionImpl).ToString());
                break;

            case eNodeType.Branch:
                result = IDecisionTreeInterface.CreateNewNode(typeof(IBranchImpl).ToString());
                break;

            case eNodeType.DataObjects:
                name            = Constants.DataNodesTreeName;
                result          = IDecisionTreeInterface.CreateNewNode(typeof(IBaseNodeImpl).ToString());
                result.NodeType = eNodeType.DataObjects;
                break;

            case eNodeType.DataObject:
                name   = GetNodeName("data object", parent);
                result = IDecisionTreeInterface.CreateNewNode(typeof(IDataObjectImpl).ToString());
                break;

            case eNodeType.DataSources:
                name            = Constants.DataSourcesTreeName;
                result          = IDecisionTreeInterface.CreateNewNode(typeof(IBaseNodeImpl).ToString());
                result.NodeType = eNodeType.DataSources;
                break;

            case eNodeType.DataSource:
                name   = GetNodeName("data source", parent);
                result = IDecisionTreeInterface.CreateNewNode(typeof(IDataSourceImpl).ToString());
                break;

            case eNodeType.DataDefinition:
                name   = GetNodeName("data definition", parent);
                result = IDecisionTreeInterface.CreateNewNode(typeof(IDataDefinitionImpl).ToString());
                break;
            }

            if (result != null)
            {
                result.Parent = parent;

                result.NodeType = nodeType;
                result.Name     = name;
                result.Tree     = this;

                if (parent != null)
                {
                    parent.AddNode(result);
                }
            }

            return(result);
        }