示例#1
0
    private void Start()
    {
        agent = this.GetComponent <NavMeshAgent>();

        tree = new BehaviourTree();
        Sequence steal = new Sequence("Steal Something");
        // Node goToPoint = new Leaf("Go To Point", GoToPoint);
        Node     goToFrontDoor = new Leaf("Go To FrontDoor", GoToFrontDoor);
        Node     goToBackDoor  = new Leaf("Go To BackDoor", GoToBackDoor);
        Node     goToDiamond   = new Leaf("Go To Diamond", GoToDiamond);
        Node     goToVan       = new Leaf("Go To Van", GoToVan);
        Selector openDoor      = new Selector("Open Door");

        openDoor.AddChild(goToFrontDoor);
        openDoor.AddChild(goToBackDoor);

        //steal.AddChild(goToPoint);
        steal.AddChild(openDoor);
        steal.AddChild(goToFrontDoor);
        //steal.AddChild(goToBackDoor);
        steal.AddChild(goToDiamond);
        //steal.AddChild(goToBackDoor);
        steal.AddChild(goToVan);

        tree.AddChild(steal);

        tree.PrintTree();
    }
    public override BehaviourTree Build()
    {
        var bt     = new BehaviourTree();
        var combat = bt.AddChild <SequenceTask_Correct>();

        combat.AddChild <FindTargetTask>();
        combat.AddChild <PursueTargetTask>();
        combat.AddChild <AttackTargetTask>();
        //var root = bt.AddChild<ExecuteAllTask>();
        //    var combat = root.AddChild<SequenceTask>();
        //        combat.AddChild<FindTargetTask>();
        //        combat.AddChild<AttackTargetTask>();
        //    var movement = root.AddChild<SequenceTask>();
        //        var destination = movement.AddChild<SelectorTask>();
        //            var combatDestination = destination.AddChild<CombatDestinationTask>();
        //            var controlPointDestination = destination.AddChild<SelectorTask>();
        //                controlPointDestination.AddChild<CaptureCPTask>();
        //                controlPointDestination.AddChild<SelectCaptureCPTask>();
        //            var randomDestination = destination.AddChild<SelectorTask>();
        //                randomDestination.AddChild<CheckDestinationTask>();
        //                randomDestination.AddChild<SetRandomDestinationTask>();
        //        movement.AddChild<MoveToTask>();
        return(bt);
    }