예제 #1
0
        public NodeWindow(NodeEditorObject nodeObj)
        {
            var ohBehave = EditorWindow.GetWindow <OhBehaveEditorWindow>();

            treeBlueprint = ohBehave.treeBlueprint;
            nodeObject    = nodeObj;
            nodeName      = nodeObj.displayName;

            switch (nodeObj.nodeType)
            {
            case NodeType.Leaf:
                nodeStyle  = OhBehaveEditorWindow.LeafNodeStyle;
                bgColor    = NodeStyle.LeafColor;
                labelStyle = NodeStyle.LeafLabelStyle;
                break;

            case NodeType.Selector:
                nodeStyle  = OhBehaveEditorWindow.SelectorNodeStyle;
                bgColor    = NodeStyle.SelectorColor;
                labelStyle = NodeStyle.SelectorLabelStyle;
                outPoint   = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint);
                break;

            case NodeType.Sequence:
                nodeStyle  = OhBehaveEditorWindow.SequenceNodeStyle;
                bgColor    = NodeStyle.SequenceColor;
                labelStyle = NodeStyle.SequencerLabelStyle;
                outPoint   = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint);
                break;

            case NodeType.Inverter:
                nodeStyle  = OhBehaveEditorWindow.InverterNodeStyle;
                bgColor    = NodeStyle.InverterColor;
                labelStyle = NodeStyle.InverterLabelStyle;
                outPoint   = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint);
                break;
            }

            currentStyle = nodeStyle.defaultStyle;

            if (nodeObject.index != OhBehaveTreeBlueprint.ROOT_INDEX)
            {
                inPoint = new ConnectionPoint(this, ConnectionPointType.In, ConnectionControls.OnClickInPoint);
            }

            NodeEditorObject prntObj = nodeObject.Parent;

            if (prntObj != null)
            {
                parent = (IParentNodeWindow)prntObj.GetWindow();
                if (parent == null)
                {
                    refreshConnection = true;
                }
            }
            else
            {
                bgColor = NodeStyle.RootColor;
            }
        }
예제 #2
0
        public void SetParentWindow(IParentNodeWindow newParent)
        {
            if (parent != null)
            {             // TODO: cleanup old connection
                throw new Exception("Must handle situation where child already has parent!");
            }

            parent = newParent;
        }
예제 #3
0
        public void ParentRemoved()
        {
            if (parent == null)
            {
                return;
            }

            parent = null;
        }
예제 #4
0
        protected void RefreshConnection()
        {
            NodeEditorObject prntObj = nodeObject.Parent;

            if (prntObj != null)
            {
                parent = (IParentNodeWindow)prntObj.GetWindow();
                if (parent != null)
                {
                    refreshConnection = false;
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Called when Remove Connection selected from context menu.
 /// </summary>
 private void DisconnectParent(IParentNodeWindow parent)
 {
     NodeEditorObject.DisconnectNodes(((NodeWindow)parent).nodeObject, nodeWindow.nodeObject);
 }