예제 #1
0
    private static BaseNode __addNode(NodeType node_type, Vector2 mousePosition)
    {
        BaseNode node = null;

        switch (node_type)
        {
        case NodeType.BehaviourNode:
            node = new BehaviourNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.ExcelNode:
            node = new ExcelNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <ExcelNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.ActionNode:
            node = new ActionNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.ConditionNode:
            node = new ConditionNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.WaitNode:
            node = new WaitNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.SequenceNode:
            node = new SequenceNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.SelectorNode:
            node = new SelectorNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;

        case NodeType.LoopNode:
            node = new LoopNode();
            node.Init(mousePosition, OnClickNode);
            NodeDataManager.CreateNodeData <BaseNodeData>(node);
            nodes_list.Add(node);
            break;
        }

        if (node != null && nodes_list.Count == 1)
        {
            rootNode = node;
        }
        return(node);
    }