private void RandomMakeNodeGroup()
    {
        GameObject nodeObj = null;
        float      randPosX, randPosY;

        if (_resNodePrefabs == null)
        {
            Debug.LogWarning("_resNodePrefabs is null!");
            return;
        }

        // 노드 타입 정하기
        if (_bNodeTypeRandom)
        {
            int nodeTypeMax = System.Enum.GetValues(typeof(eNodeType)).Length;
            _nodeType = (eNodeType)UnityEngine.Random.Range(0, nodeTypeMax);
        }

        // 노드 갯수 정하기
        int nodeLength = UnityEngine.Random.Range(_nodeAmountMin, _nodeAmountMax + 1);

        for (int i = 0; i < nodeLength; i++)
        {
            nodeObj = Instantiate(_resNodePrefabs[(int)_nodeType], transform);

            randPosX = transform.position.x + UnityEngine.Random.Range(-_nodeDist, _nodeDist);
            randPosY = transform.position.y + UnityEngine.Random.Range(-_nodeDist, _nodeDist);

            nodeObj.transform.SetPositionAndRotation(new Vector3(randPosX, randPosY, 0f), Quaternion.identity);
        }
    }
Esempio n. 2
0
        public int NodeIndex(eNodeType nodeType)
        {
            int result = 0;

            switch (nodeType)
            {
            case eNodeType.Root:                result = 1; break;

            case eNodeType.VariableDefinitions: result = 2; break;

            case eNodeType.VarDefinition:       result = 3; break;

            case eNodeType.Expression:          result = 4; break;

            case eNodeType.DomainObject:        result = 5; break;

            case eNodeType.Branch:              result = 6; break;

            case eNodeType.DataObject:          result = 8; break;

            case eNodeType.DataObjects:         result = 9; break;

            case eNodeType.DataSources:         result = 10; break;

            case eNodeType.DataSource:          result = 11; break;

            case eNodeType.DataDefinition:      result = 12; break;
            }

            return(result);
        }
Esempio n. 3
0
        private void AddNode(eNodeType nodeType)
        {
            IBaseNode     currentNode = TreeNodeAsBaseNode(tvDecisionTree.SelectedNode);
            IDecisionTree tree        = currentNode.Tree;

            if (tree != null)
            {
                IBaseNode newNode = tree.CreateNewNode(nodeType, currentNode);
                newNode.Updated += Node_Updated;
                if (newNode.NodeType == eNodeType.VarDefinition)
                {
                    (newNode as IVariableDef).VariableTypeChanged += VariableTypeChanged;
                }

                if (newNode.NodeType == eNodeType.DomainObject)
                {
                    (newNode as IDomainObject).UpdatedAndRefresh += UpdateAdRefresh;
                }

                TreeNode node = modelGUIConfig.BaseNodeAsTreeNode(newNode);

                tvDecisionTree.SelectedNode.Nodes.Add(node);
                tvDecisionTree.SelectedNode.Expand();
                tvDecisionTree.SelectedNode = node;
            }

            App.SelectedTree = tree;
        }
Esempio n. 4
0
        // 创建一类节点缓存
        private void CrateModelNodePool(int mType, GameObject prefabe, int num)
        {
            if (_nodePool.ContainsKey(mType))
            {
                Debug.LogWarning("Already contain this type node cache " + mType);
                return;
            }
            if (prefabe == null)
            {
                Debug.LogError("Created failed ,node resource is a null value");
                return;
            }

            List <NodeObject> list = new List <NodeObject>();

            _nodePool.Add(mType, list);

            for (int i = 0; i < num; ++i)
            {
                eNodeType eType = (eNodeType)mType;

                NodeObject node = CreateEmptyNode(eType, prefabe);

                //list.Add(node);
                RecoverNode(node);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eType"></param>
        /// <param name="prefab">源资源prefab</param>
        /// <returns></returns>
        private NodeObject CreateEmptyNode(eNodeType eType, UnityEngine.Object prefab)
        {
            if (prefab == null)
            {
                return(null);
            }

            NodeObject node = null;
            GameObject go   = GameObject.Instantiate(prefab) as GameObject;

            go.name = prefab.name;

            switch (eType)
            {
            case eNodeType.Normal:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Normal;
                break;

            case eNodeType.Len:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Len;
                break;

            case eNodeType.Combine:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Combine;
                break;

            default:
                node = go.GetComponent <NormalNode>();
                if (node == null)
                {
                    node = go.AddComponent <NormalNode>();
                }
                node.eType = eNodeType.Normal;
                break;
            }

            node.Init();

            node.SetParent(cacheRoot);

            //node.SetActive(false);

            return(node);
        }
Esempio n. 6
0
 public AllAssets(AssetGroup parentGroup, eNodeType nodeType)
 {
     _parentGroup = parentGroup;
     _nodeType    = nodeType;
     _branchName  = "";
     _itemValue   = "";
     _tag         = null;
 }
Esempio n. 7
0
 public AllAssets(AssetGroup parentGroup, string branchName)
 {
     _parentGroup = parentGroup;
     _nodeType    = eNodeType.category;
     _branchName  = branchName;
     _itemValue   = "";
     _tag         = null;
 }
Esempio n. 8
0
 public NodeData(eNodeType eType, int nValue)
 {
     m_eNodeType   = eType;
     m_nValue      = nValue;
     m_nString     = null;
     m_vChildNode  = new Dictionary <int, NodeData>();
     m_pParentNode = null;
 }
Esempio n. 9
0
 public AllAssets(AssetGroup parentGroup, int assetID, string itemValue)
 {
     _parentGroup = parentGroup;
     _nodeType    = eNodeType.value;
     _branchName  = "";
     _itemValue   = itemValue;
     _tag         = null;
 }
Esempio n. 10
0
 public AllAssets(AssetGroup parentGroup)
 {
     _parentGroup = parentGroup;
     _nodeType    = eNodeType.root;
     _branchName  = "";
     _itemValue   = "";
     _tag         = null;
 }
Esempio n. 11
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="other"></param>
 public AllAssets(AllAssets other)
 {
     _parentGroup = other.ParentGroup;
     _nodeType    = other.AllAssetType;
     _branchName  = other.BranchName;
     _itemValue   = other.ItemValue;
     _listAssets  = other.ListAssets;
     _tag         = other.Tag;
 }
Esempio n. 12
0
 public void InitDoorState(LevelNode node, int stageId)
 {
     leftDoor.mStageId  = stageId;
     rightDoor.mStageId = stageId;
     leftDoor.SetDoorState(node.left);
     rightDoor.SetDoorState(node.right);
     type         = node.type;
     this.stageId = stageId;
 }
Esempio n. 13
0
 public LevelNode()
 {
     xIndex = 0;
     yIndex = 0;
     left   = false;
     right  = false;
     top    = false;
     bottom = false;
     type   = eNodeType.Normal;
 }
Esempio n. 14
0
        IBaseNode IBaseNode.GetNode(eNodeType nodeType)
        {
            foreach (IBaseNode node in Nodes)
            {
                if (node.NodeType == nodeType)
                {
                    return(node);
                }
            }

            return(null);
        }
        private static string getPath(IBaseNode node, eNodeType rootNode)
        {
            string    result = node.Name;
            IBaseNode parent = node.Parent;

            while (parent != null && parent.NodeType != rootNode)
            {
                result = parent.Name + "." + result;
                parent = parent.Parent;
            }
            return(result);
        }
Esempio n. 16
0
        public NodeLinkForm(IBaseNode selectedNode, eNodeType rootNodeType, string title)
        {
            InitializeComponent();

            Text = title;

            lbxAvailable.DrawItem += lbxAvailable_DrawItem;
            lbxSelected.DrawItem  += lbxAvailable_DrawItem;

            IDecisionTree tree = selectedNode.Tree;

            AddDataNodesToAvailable(tree.RootNode.GetNode(rootNodeType));
        }
Esempio n. 17
0
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     e.Node.BackColor = Color.Yellow;
     if (e.Node.Tag != null)
     {
         NodeData curData = (NodeData)e.Node.Tag;
         m_nCurNodeType = curData.nodeType;
         m_vAddSettingPanel[(int)curData.nodeType].show();
         m_vAddSettingPanel[(int)curData.nodeType].refreshCurNodeData(curData);
         this.infotext.Text = curData.help;
     }
     else
     {
         this.infotext.Text = "no more infogdg";
     }
     this.btnRemoveNode.Enabled = e.Node.Parent != null;
 }
Esempio n. 18
0
        public void RecoverNode(NodeObject node)
        {
            eNodeType         eType = node.eType;
            int               mType = (int)eType;
            List <NodeObject> list  = null;

            if (!_nodePool.TryGetValue(mType, out list))
            {
                GameObject.Destroy(node);

                Debug.LogError("RecoverNode failed not contain this type pool");
                return;
            }

            node.Disappear();

            node.SetParent(cacheRoot);

            node.position = Vector3.zero;

            list.Add(node);
        }
Esempio n. 19
0
        private NodeObject PickAvaliableNode(eNodeType eType)
        {
            int mType = (int)eType;
            List <NodeObject> list = null;
            NodeObject        node = null;

            if (!_nodePool.TryGetValue(mType, out list))
            {
                GameObject prefabe = _prefabList[mType];
                if (prefabe == null)
                {
                    Debug.LogError("Not contain this type prefab " + mType);
                    return(null);
                }
                CrateModelNodePool(mType, prefabe, m_CacheDefualtNum);
            }

            int count = list.Count;

            if (count <= 0)
            {
                Object prefabe = _prefabList[mType];
                if (prefabe == null)
                {
                    Debug.LogError("Not contain this type prefab@@@@@@ " + mType);
                    return(null);
                }

                node = CreateEmptyNode(eType, prefabe);

                return(node);
            }

            node = list[0];
            list.RemoveAt(0);

            return(node);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eType"></param>
        /// <param name="prefab">源资源prefab</param>
        /// <returns></returns>
        private ModelNode CreateEmptyNode(eNodeType eType, UnityEngine.Object prefab)
        {
            if (prefab == null)
            {
                return(null);
            }

            ModelNode  node = null;
            GameObject go   = GameObject.Instantiate(prefab) as GameObject;

            switch (eType)
            {
            case eNodeType.Normal:
                node = new NormalNode(go);
                break;

            default:
                node = new NormalNode(go);
                break;
            }
            node.Init();

            return(node);
        }
Esempio n. 22
0
        public static bool CreateLevelWithTag <T>(string tag, eNodeType nodeType, Transform parent, ref T level) where T : LevelBase, new()
        {
            if (level != null)
            {
                return(false);
            }

            GameObject settingGameObject = null;

            GameObject[] settingGameObjects = GameObject.FindGameObjectsWithTag(tag);
            if (settingGameObjects.Length == 1)
            {
                settingGameObject = settingGameObjects[0];
            }
            else
            {
                if (settingGameObjects.Length > 1)
                {
                    throw new System.Exception(StringUtil.Format("{0}.Length != 1", tag));
                }
            }

            return(CreateLevel <T>(settingGameObject, nodeType, parent, ref level));
        }
Esempio n. 23
0
    public StageLogic GetStage(int levelId, eNodeType type)
    {
        if (type == eNodeType.Start)
        {
            return(GameObject.Instantiate(start).GetComponent <StageLogic>());
        }

        if (type == eNodeType.End)
        {
            return(GameObject.Instantiate(end).GetComponent <StageLogic>());
        }

        if (type == eNodeType.Boss)
        {
            return(GameObject.Instantiate(end).GetComponent <StageLogic>());
        }

        if (type == eNodeType.Normal)
        {
            int index = Random.Range(0, normal.Count);
            return(GameObject.Instantiate(normal[index]).GetComponent <StageLogic>());
        }
        return(null);
    }
Esempio n. 24
0
        }                                                           // псевдоним-описание

        public TableField(object name, eNodeType nt) : base(name, nt)
        {
        }
Esempio n. 25
0
 public IExpressionImpl(string name, eNodeType nodeType) : base(name, eNodeType.Expression)
 {
     NodeType = eNodeType.Expression;
 }
Esempio n. 26
0
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     e.Node.BackColor = Color.Yellow;
     if (e.Node.Tag != null )
     {
         NodeData curData = (NodeData)e.Node.Tag;
         m_nCurNodeType = curData.nodeType;
         m_vAddSettingPanel[(int)curData.nodeType].show();
         m_vAddSettingPanel[(int)curData.nodeType].refreshCurNodeData(curData);
         this.infotext.Text = curData.help;
     }
     else
     {
         this.infotext.Text = "no more infogdg";
     }
     this.btnRemoveNode.Enabled = e.Node.Parent != null;
 }
Esempio n. 27
0
 public NodeData(eNodeType eType, int nValue)
 {
     m_eNodeType = eType;
     m_nValue = nValue;
     m_nString = null;
     m_vChildNode = new Dictionary<int,NodeData>() ;
     m_pParentNode = null;
 }
Esempio n. 28
0
 public ActorEnterInfo(int netID, int table, eNodeType nodeType)
 {
     m_netID    = netID;
     m_tableID  = table;
     m_nodeType = nodeType;
 }
Esempio n. 29
0
 public void SetParent(Node parent, eNodeType nodeType)
 {
     mParent   = parent;
     mNodeType = nodeType;
 }
Esempio n. 30
0
 public Field(object name, eNodeType nt)
 {
     Name = name.ToString();
     Nt   = nt;
 }
Esempio n. 31
0
 public IBaseNodeImpl(string name, eNodeType nodeType)
 {
     _Name    = name;
     NodeType = nodeType;
 }
Esempio n. 32
0
 public IRootNodeImpl(string name, eNodeType nodeType) : base(name, eNodeType.Expression)
 {
     NodeType = eNodeType.Root;
 }