Пример #1
0
    public INode CreateRandomSelectorTest()
    {
        NodeFactory      factory          = FactoryManager.Instance.GetFactory <NodeFactory>(FactoryType.Node);
        ConditionFactory conditionFactory = FactoryManager.Instance.GetFactory <ConditionFactory>(FactoryType.Condition);
        DecoratorFactory decoratorFactory = FactoryManager.Instance.GetFactory <DecoratorFactory>(FactoryType.Decorator);

        var rootNode = factory.Create <RootNode>(NodeType.Root);
        RandomSelectorNode randomSelectorNode = factory.Create <RandomSelectorNode>(NodeType.RandomSelector);
        DecoratorNode      decoratorNode      = factory.Create <DecoratorNode>(NodeType.Decorator);
        FalseDecorator     not = decoratorFactory.Create <FalseDecorator>(DecoratorType.False);

        decoratorNode.SetDecoratable(not);
        var actionNode1 = CreateSampleActionNode1();
        var actionNode2 = CreateSampleActionNode1();
        var actionNode3 = CreateSampleActionNode2();

        randomSelectorNode.AddNode(actionNode1);
        randomSelectorNode.AddNode(actionNode2);
        decoratorNode.AddNode(actionNode3);
        randomSelectorNode.AddNode(decoratorNode);
        rootNode.AddNode(randomSelectorNode);
        return(rootNode);
    }