예제 #1
0
        public override bool AddChild(int outputIndex, BehaviorNodeWindow child)
        {
            if (outputIndex == 0 && conditionNode == null)
            {
                if (child.NodeType == BehaviorNodeType.Condition)
                {
                    conditionNode        = child;
                    conditionNode.Parent = this;
                    return(true);
                }
                return(false);
            }

            if (outputIndex == 1 && successNode == null)
            {
                successNode        = child;
                successNode.Parent = this;
                return(true);
            }

            if (outputIndex == 2 && failureNode == null)
            {
                failureNode        = child;
                failureNode.Parent = this;
                return(true);
            }

            return(false);
        }
예제 #2
0
        public override bool RemoveChild(BehaviorNodeWindow child)
        {
            var result = base.RemoveChild(child);

            if (result)
            {
                childNode = null;
            }
            return(result);
        }
예제 #3
0
        public override bool AddChild(int outputIndex, BehaviorNodeWindow child)
        {
            if (childNode != null || child.NodeType != BehaviorNodeType.Action)
            {
                return(false);
            }

            childNode        = child;
            childNode.Parent = this;
            return(true);
        }
예제 #4
0
        public override bool AddChild(int outputIndex, BehaviorNodeWindow child)
        {
            if (childNodes.Contains(child))
            {
                return(false);
            }

            child.Parent = this;
            childNodes.Add(child);
            return(true);
        }
예제 #5
0
        /// <summary>
        /// 创建节点
        /// </summary>
        private BehaviorNodeWindow CreateBehaviorNodeWindow(int nodeID, BehaviorNodeType type, Vector2 pos)
        {
            BehaviorNodeWindow nodeWindow = null;

            switch (type)
            {
            case BehaviorNodeType.Action:
                nodeWindow = new ActionNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Condition:
                nodeWindow = new ConditionNodeWindow(nodeID);
                break;

            case BehaviorNodeType.IfElse:
                nodeWindow = new IfElseNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Selector:
                nodeWindow = new SelectorNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Sequence:
                nodeWindow = new SequenceNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Time:
                nodeWindow = new TimeNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Parallel:
                nodeWindow = new ParallelNodeWindow(nodeID);
                break;

            case BehaviorNodeType.Loop:
                nodeWindow = new LoopNodeWindow(nodeID);
                break;
            }

            if (nodeWindow != null)
            {
                nodeWindow.WindowArea = new Rect(pos.x, pos.y, nodeWindow.WindowWidth, nodeWindow.WindowHeight);
                nodeWindows.Add(nodeWindow.ID, nodeWindow);
            }

            return(nodeWindow);
        }
예제 #6
0
        public override bool RemoveChild(BehaviorNodeWindow child)
        {
            var result = base.RemoveChild(child);

            if (result)
            {
                if (conditionNode == child)
                {
                    conditionNode = null;
                }
                else if (successNode == child)
                {
                    successNode = null;
                }
                else if (failureNode == child)
                {
                    failureNode = child;
                }
            }
            return(result);
        }
예제 #7
0
 public MouseTransitionLine(BehaviorNodeWindow startNodeWindow, int outputIndex)
 {
     StartNodeWindow = startNodeWindow;
     OutputIndex     = outputIndex;
 }
예제 #8
0
 public NodeTransitionLine(BehaviorNodeWindow startNodeWindow, int outputIndex, BehaviorNodeWindow endNodeWindow)
 {
     StartNodeWindow = startNodeWindow;
     OutputIndex     = outputIndex;
     EndNodeWindow   = endNodeWindow;
 }