예제 #1
0
            public InsertNodeTool(ConversationDataControl content, ConversationNodeDataControl parent, int nodeType, int index)
            {
                this.content    = content;
                this.isRootNode = parent == null;
                this.parent     = isRootNode ? content.getRootNode() : parent;
                ConversationNode node = null;

                switch (nodeType)
                {
                case DIALOG_NODE: node = new DialogueConversationNode(); break;

                case OPTION_NODE: node = new OptionConversationNode(); break;
                }


                this.index = index;
                var parentRect = isRootNode ? new RectInt(0, 25, 0, 0) : parent.getEditorRect();
                var childRect  = isRootNode ? content.getRootNode().getEditorRect() : parent.getChilds()[index].getEditorRect();

                var center = (parentRect.center + childRect.center) / 2f;

                node.setEditorX((int)(center.x - node.getEditorWidth() / 2f));
                node.setEditorY((int)(center.y - node.getEditorHeight() / 2f));

                this.newNode  = ConversationNodeDataControlFactory.Instance.CreateDataControlFor(content, node);
                this.subTools = CreateTools();
            }