Exemplo n.º 1
0
        public void MakeChildOfTest()
        {
            BaseNode parent  = new BaseNode();
            BaseNode child0  = new BaseNode();
            BaseNode child00 = new BaseNode();
            BaseNode child01 = new BaseNode();

            parent.AddChild(child0);
            child0.AddChild(child00);
            child0.AddChild(child01);

            child01.MakeChildOf(parent);
            Assert.AreEqual(1, child0.Children.Count);
            Assert.AreEqual(2, parent.Children.Count);
            Assert.AreEqual("a01", child01.Name);
        }
Exemplo n.º 2
0
        public void AddChildTest()
        {
            BaseNode parent  = new BaseNode();
            BaseNode child0  = new BaseNode();
            BaseNode child1  = new BaseNode();
            BaseNode child2  = new BaseNode();
            BaseNode child20 = new BaseNode();

            parent.AddChild(child0);
            parent.AddChild(child1);
            parent.AddChild(child2);
            child2.AddChild(child20);
            Assert.AreEqual("a00", child0.Name);
            Assert.AreEqual("a01", child1.Name);
            Assert.AreEqual("a02", child2.Name);
            Assert.AreEqual("a0200", child20.Name);
        }
Exemplo n.º 3
0
        public void FindTest()
        {
            BaseNode parent    = new BaseNode();
            BaseNode child00   = new BaseNode();
            BaseNode child01   = new BaseNode();
            BaseNode child0000 = new BaseNode();

            parent.AddChild(child00);
            parent.AddChild(child01);
            child00.AddChild(child0000);
            BaseNode found = parent.Find("a00");

            Assert.AreSame(child00, found);
            found = parent.Find("a01");
            Assert.AreSame(child01, found);
            found = parent.Find("a0000");
            Assert.AreSame(child0000, found);
        }
Exemplo n.º 4
0
 static void CreateNodeForTrans(Transform parentTrans, BaseNode parentNode)
 {
     foreach (Transform t in parentTrans)
     {
         var node = GameObjectToNode(t.gameObject);
         if (null != node)
         {
             parentNode.AddChild(node);
             CreateNodeForTrans(t, node);
         }
     }
 }
Exemplo n.º 5
0
 public override void SetInput(BaseNode input, Vector2 clickPos)
 {
     clickPos.x -= WindowRect.x;
     clickPos.y -= WindowRect.y;
     for (int i = 0; i < ParentRoomNodes.Count; i++)
     {
         if (ParentNodeRects[i].Contains(clickPos))
         {
             ParentRoomNodes[i] = (RoomNode)input;
             input.AddChild(this);
             break;
         }
     }
 }
Exemplo n.º 6
0
        public void DeleteTest()
        {
            BaseNode parent      = new BaseNode();
            BaseNode child00     = new BaseNode();
            BaseNode child0000   = new BaseNode();
            BaseNode child0001   = new BaseNode();
            BaseNode child000000 = new BaseNode();

            parent.AddChild(child00);
            child00.AddChild(child0000);
            child00.AddChild(child0001);
            child0000.AddChild(child000000);

            child00.Delete(false);
            Assert.AreEqual(2, parent.Children.Count);
            Assert.AreEqual("a00", child0000.Name);
            Assert.AreEqual("a01", child0001.Name);
            Assert.AreEqual("a0000", child000000.Name);

            child0001.Delete(true);
            Assert.AreEqual(1, parent.Children.Count);
            child0000.Delete(true);
            Assert.AreEqual(0, parent.Children.Count);
        }
Exemplo n.º 7
0
        public void RenameTest()
        {
            BaseNode parent  = new BaseNode();
            BaseNode child0  = new BaseNode();
            BaseNode child00 = new BaseNode();

            parent.AddChild(child0);
            child0.AddChild(child00);
            child0.Name = "a01";
            child0.Rename();
            Assert.AreEqual("a0100", child00.Name);
            parent.Rename();
            Assert.AreEqual("a00", child0.Name);
            Assert.AreEqual("a0000", child00.Name);
        }
Exemplo n.º 8
0
        private void DrawChangeTypeGroup(BaseNode node, BaseNode parent, bool canAddChildren)
        {
            GUILayout.BeginHorizontal();

            if (!selectorIndexes.ContainsKey(node.GetId()))
            {
                hashedIndexes.Add(node.GetId(), nodes.IndexOf(node.GetType().ToString()));
                selectorIndexes.Add(node.GetId(), nodes.IndexOf(node.GetType().ToString()));
            }

            hashedIndexes[node.GetId()]   = selectorIndexes[node.GetId()];
            selectorIndexes[node.GetId()] = EditorGUILayout.Popup(selectorIndexes[node.GetId()], nodesArr);
            if (hashedIndexes[node.GetId()] != selectorIndexes[node.GetId()])
            {
                ChangeFieldType(node, parent, selectorIndexes[node.GetId()]);
            }
            ;

            GUILayout.Space(50);
            if (canAddChildren)
            {
                if (GUILayout.Button("+", GUILayout.Width(25)))
                {
                    var id = typeof(SequenceNode).Name + "_" + GetRandomHexNumber(4);
                    node.AddChild(new SequenceNode(new List <BaseNode> {
                    }, id));
                    selectorIndexes.Add(id, 1);
                }
            }
            if (GUILayout.Button("-", GUILayout.Width(25)))
            {
                if (parent != null)
                {
                    selectorIndexes.Remove(node.GetId());
                    var ind = parent.GetChildren().IndexOf(node);
                    parent.RemoveChildAt(ind);
                }
            }

            GUILayout.EndHorizontal();
        }
 public void AddChild(Node child)
 {
     _base.AddChild(child);
 }