Esempio n. 1
0
 public Wait(BehaviourTree tree, float minTime, float maxTime)
     : base(tree)
 {
     randomTime = true;
     this.minTime = minTime;
     this.maxTime = maxTime;
 }
Esempio n. 2
0
 public override void TreeCompleted(bool success, BehaviourTree tree)
 {
     base.TreeCompleted (success, tree);
     if(behaviourQueue.Count == 0){
         AddTree(new ReceptionistIdle(this, 4, 30, reception), 1);
     }
 }
Esempio n. 3
0
	// Use this for initialization
	void Start () 
    {
        puppet = gameObject.GetComponent<PuppetScript>();
        behaviourTree = gameObject.GetComponent<BehaviourTree>();
        switch (trainerType)
        {
            case TRAINER_TYPE.ATTACK_TOP:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.SLASH_TOP));
                break;
            case TRAINER_TYPE.ATTACK_LEFT:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.SLASH_LEFT));
                break;
            case TRAINER_TYPE.ATTACK_RIGHT:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.SLASH_RIGHT));
                break;
            case TRAINER_TYPE.GUARD_LEFT:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.GUARD_LEFT, 1.5f));
                break;
            case TRAINER_TYPE.GUARD_RIGHT:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.GUARD_RIGHT, 1.5f));
                break;
            case TRAINER_TYPE.GUARD_TOP:
                behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.GUARD_TOP, 1.5f));
                break;
			case TRAINER_TYPE.IDLE:
				break;
        }

        behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.WINDOW_OF_OPPORTUNITY, 1.5f));
	}
Esempio n. 4
0
 public Repeater(BehaviourTree tree, int repeatNTimes, RepeatType repeatType, Node[] children)
     : base(children)
 {
     this.repeatNTimes = repeatNTimes;
     this.repeatType = repeatType;
     base.tree = tree;
 }
 private static BehaviourTree<BehaviourTreeTests.Blackboard> CreateBehaviourTree()
 {
     BehaviourTree<BehaviourTreeTests.Blackboard> behaviourTree =
         new BehaviourTree<BehaviourTreeTests.Blackboard>(
             "Base Tree",
             new Sequence<BehaviourTreeTests.Blackboard>(
                 "My sequence",
                 new UtilitySelector<BehaviourTreeTests.Blackboard>(
                     new TaskUtility<BehaviourTreeTests.Blackboard>(
                         new Add<BehaviourTreeTests.Blackboard>(
                             new BlackboardFloatFunction<BehaviourTreeTests.Blackboard>("Gooba", null),
                             new FloatConstant<BehaviourTreeTests.Blackboard>(7)),
                             new Fail<BehaviourTreeTests.Blackboard>()),
                     new TaskUtility<BehaviourTreeTests.Blackboard>(new FloatConstant<BehaviourTreeTests.Blackboard>(12), new Succeed<BehaviourTreeTests.Blackboard>())),
                 new AlwaysFail<BehaviourTreeTests.Blackboard>(new Succeed<BehaviourTreeTests.Blackboard>()),
                 //new BooleanToState<BehaviourTreeTests.Blackboard>(
                 //  new TrueConstant<BehaviourTreeTests.Blackboard>()),
                 new Fail<BehaviourTreeTests.Blackboard>(),
                 new Succeed<BehaviourTreeTests.Blackboard>(),
                 new KeepRunning<BehaviourTreeTests.Blackboard>(),
                 new Invert<BehaviourTreeTests.Blackboard>(new Fail<BehaviourTreeTests.Blackboard>()),
                 new UntilFail<BehaviourTreeTests.Blackboard>(new Fail<BehaviourTreeTests.Blackboard>()),
                 new UntilSuccess<BehaviourTreeTests.Blackboard>(new Fail<BehaviourTreeTests.Blackboard>()),
                 new KeepRunning<BehaviourTreeTests.Blackboard>(),
                 new NamedCoroutine<BehaviourTreeTests.Blackboard>("mybob", new NamedCoroutineCreator("RunRunFail", null)),
                 new Selector<BehaviourTreeTests.Blackboard>(
                     "My selector",
                     new Counter<BehaviourTreeTests.Blackboard>(
                         new FixedResultState<BehaviourTreeTests.Blackboard>(TaskState.Failure)),
                     new FixedResultState<BehaviourTreeTests.Blackboard>(TaskState.Success),
                     new FixedResultState<BehaviourTreeTests.Blackboard>(TaskState.Success))));
     return behaviourTree;
 }
Esempio n. 6
0
        public ActionStates Update(BehaviourTree tree)
        {
            if (State == ActionStates.None)
            {
                if (tree != null)
                    tree.Execution.Push(this);

                OnBegin();
            }

            // Check in case an Update is called after the task is done.
            if (State == ActionStates.Running)
                State = OnExecute(tree);

            if (State != ActionStates.Running)
            {
                OnEnd();

                if (tree != null)
                {
                    tree.Execution.Pop();

                    if (tree.Execution.Count > 0)
                        return tree.Execution.Peek().Update(tree);
                }
            }

            return State;
        }
Esempio n. 7
0
    public override void TreeCompleted(bool success, BehaviourTree tree)
    {
        base.TreeCompleted(success, tree);

        if(tree is SimpleRandomMove){
            AddTree(NewRandomDestinationTree());
        }
    }
Esempio n. 8
0
    public ConstructSentence(BehaviourTree tree, string noun1Key, Sentence.Verb verb, string noun2Key, string sentenceKey)
        : base(tree)
    {
        this.noun1Key = noun1Key;
        this.verb = verb;
        this.noun2Key = noun2Key;

        this.sentenceKey = sentenceKey;
    }
Esempio n. 9
0
 public override void TreeCompleted(bool success, BehaviourTree tree)
 {
     //base.TreeCompleted (success, tree);
     if(!test){
         test = true;
         AddTree(new SecretRomance(this, "lover", secretLover), 11);
     }
     else{
         base.TreeCompleted (success, tree);
     }
 }
Esempio n. 10
0
        public override ActionStates OnExecute(BehaviourTree tree)
        {
            if (currentTaskIndex >= actions.Length)
                return ActionStates.Failure;

            var result = actions[currentTaskIndex++].Update(tree);

            if (result == ActionStates.Success)
                return ActionStates.Success;
            else
                return ActionStates.Running;
        }
Esempio n. 11
0
 //Another character can push a tree onto this queue - it will only accept if it is the highest priority,
 //unless force is set to true (i.e. set force to true if it's a task to complete, force to false if it's synchronisation stuff)
 public bool PushTree(BehaviourTree tree, int priority, bool force)
 {
     if(behaviourQueue.Count == 0 || behaviourQueue[0].priority < priority || force){
         AddTree(tree, priority);
         return true;
     }
     else{
         //Debug.Log (behaviourQueue[0].priority);
         //Debug.Log(priority);
         return false;
     }
 }
Esempio n. 12
0
    void Start()
    {
        tree = new BehaviourTree();
        teste = new TestBehaviourInstant(this);
        teste2 = new TestBehaviour5Times(this);
        sequence = new Sequence(tree);
        sequence.AddChild(teste);
        sequence.AddChild(teste2);

        tree.Insert(sequence, null);

        manager = new ActionManager();
    }
Esempio n. 13
0
	// Use this for initialization
	void Start () 
    {
        enemyState = ENEMY_STATE.PATROL;
        puppet = GetComponent<PuppetScript>();
        player = GameObject.FindGameObjectWithTag("Player");
        noticeArea = gameObject.GetComponent<SphereCollider>();
        behaviourTree = gameObject.GetComponent<BehaviourTree>();
        behaviourTree.FuckYouUnity(); 
        foreach (GameObject patrolPoint in patrolPoints)
        {
            behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.PATROL, patrolPoint.transform.position, 0.0f));    
        }
        if(patrolPoints.Length == 0)
        {
            behaviourTree.AddBehaviour(new AIBehaviour(AI_STATE.PATROL, gameObject.transform.position, 0.0f));
        }
    }
Esempio n. 14
0
    public override void TreeCompleted(bool success, BehaviourTree tree)
    {
        base.TreeCompleted (success, tree);

        if(behaviourQueue.Count == 0){
            AddRandomFluffTree();
        }

        //Consider new affair
        if(UnityEngine.Random.value < affairChance){
            GameObject romanceTarget;

            if((knowledgeBase.Affairs(gameObject, SO) >= affairLimit || UnityEngine.Random.value > newAffairChance) && knowledgeBase.Affairs(gameObject, SO) >= 1){
                //Use current target
                romanceTarget = knowledgeBase.RandomAffair(gameObject, SO);

            }
            else{
                do{
                    romanceTarget = RandomFromArray(otherGuests);
                }while (romanceTarget == SO);
            }

            AddTree(new SecretRomance(this, "romanceTarget", romanceTarget), 15);
        }

        //Confess?
        if(!confessed && knowledgeBase.Affairs(gameObject, SO) >= 1 && UnityEngine.Random.value < confessAffairChance){
            confessed = true;
            AddTree(new ConfessAffair(this, knowledgeBase.RandomAffair(gameObject, SO)), 19);
        }

        if(UnityEngine.Random.value < gossipChance){
            AddGossip();
        }
    }
    private void OnGUI()
    {
        funcstionsSrc = source.GetComponent <Functions>();
        Type t = funcstionsSrc.GetType();

        functionListSrc = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
        for (int i = 0; i < functionListSrc.Length; i++)
        {
            //functionList[i] = functionListSrc[i].Name;
            functionList.Add(functionListSrc[i].Name);
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("AI Actor", EditorStyles.boldLabel);
        source = (GameObject)EditorGUILayout.ObjectField(source, typeof(GameObject), true);
        EditorGUILayout.EndHorizontal();


        //Stops things from drawing if there is no gameobject assgined
        if (source != null)
        {
            if (GUILayout.Button("Create Behaviour Tree"))
            {
                if (source.GetComponent <BehaviourTree>() == null)
                {
                    source.AddComponent <BehaviourTree>();
                    behaviourTreeSrc = source.GetComponent <BehaviourTree>();

                    behaviourTreeSrc.CreateRoot(true, "Behaviour Tree Root");
                    currentNode = behaviourTreeSrc.GetRoot();
                }
            }
            if (GUILayout.Button("Find"))
            {
                behaviourTreeSrc = null;
                //behaviourTree.SetRoot(behaviourTree.GetRoot());
                behaviourTreeSrc = source.GetComponent <BehaviourTree>();
                behaviourTreeSrc.SetRoot(source.GetComponent <BehaviourTree>().GetRoot());
            }
            if (GUILayout.Button("Clear"))
            {
                DestroyImmediate(source.GetComponent <BehaviourTree>());
                behaviourTreeSrc = null;
            }

            if (behaviourTreeSrc != null)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Root", EditorStyles.boldLabel);
                GUILayout.Box(behaviourTreeSrc.GetRoot().GetName());
                EditorGUILayout.EndHorizontal();
                //---------------------------------------------------
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Node name:", EditorStyles.boldLabel);
                //nodeName = EditorGUILayout.TextField("", nodeName);
                nodeName = EditorGUILayout.TextField(nodeName);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Functions", EditorStyles.boldLabel);
                //EditorGUILayout.DropdownButton(funclist, FocusType.Passive);
                index = EditorGUILayout.Popup(index, functionList.ToArray());
                EditorGUILayout.EndHorizontal();


                //if (currentNode.GetType() != typeof(ActionNode))
                //{
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Create Sequence"))
                {
                    ConnorNode temp = (ConnorNode)currentNode;
                    if (temp != null)
                    {
                        temp.AddChild(new ConnorNode(true, nodeName));
                    }
                }
                if (GUILayout.Button("Create Selector"))
                {
                    ConnorNode temp = (ConnorNode)currentNode;
                    if (temp != null)
                    {
                        temp.AddChild(new ConnorNode(false, nodeName));
                        //GetWindow<BehaviourTreeEditor>("Name");
                    }
                }
                if (GUILayout.Button("Create Action"))
                {
                    ConnorNode temp = (ConnorNode)currentNode;
                    if (temp != null)
                    {
                        temp.AddChild(new ActionNode((ActionNode.ActionNodeDelegate)Delegate.CreateDelegate(typeof(ActionNode.ActionNodeDelegate), source.GetComponent <Functions>(), functionListSrc[index]), nodeName));
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
        }

        if (behaviourTreeSrc != null)
        {
            if (behaviourTreeSrc.GetRoot() != null)
            {
                behaviourTreeSrc.GetRoot().PrintGUIElement(this);
            }
        }
    }
Esempio n. 16
0
 public CheckInRange(BehaviourTree tree, string targetKey, float range)
     : base(tree)
 {
     this.range = range;
     this.targetKey = targetKey;
 }
Esempio n. 17
0
 public TreeServiceLeafNode(BehaviourTree tree, Context parentCtx) :
     base(tree, parentCtx)
 {
 }
Esempio n. 18
0
 public BT_Timing(BehaviourTree _tree, bool _isOverwrite, bool _isMultiple) : base()
 {
     tree        = _tree;
     isOverwrite = _isOverwrite;
     isMultiple  = _isMultiple;
 }
Esempio n. 19
0
    public void FrameCounterMultipleTest()
    {
        //FrameCounter Multiple Test
        //
        // root - ex1 - ex_target - if1 - timing
        //
        // timing : this is a framecounter node which waits 1 frames.
        // if1 : should be positive at first and second frames.

        BT_Root       root      = new BT_Root();
        BehaviourTree tree      = new BehaviourTree(root);
        BT_Execute    ex1       = new BT_Execute();
        BT_Execute    ex_target = new BT_Execute();
        BT_If         if1       = new BT_If();
        BT_Timing     timing    = new BT_Timing(tree, false, true);

        root.AddChild(ex1);
        ex1.AddChild(ex_target);
        ex_target.AddChild(if1);
        if1.AddChild(timing);

        timing.SetTimingCreator(() => {
            return(new FrameCounter(ex_target, 1));
        });

        bool isOK1 = false, isOK2 = false;

        ex1.AddEvent(() => {
            isOK1 = !isOK1;
        });

        ex_target.AddEvent(() => {
            isOK2 = !isOK2;
        });

        int count = 0;

        if1.SetCondition(() => {
            count++;
            return(count <= 2);
        });

        // first timing is created.
        tree.Tick();
        Assert.AreEqual(true, isOK1);
        Assert.AreEqual(true, isOK2);

        // first timing hasn't activated yet. second timing is created.
        tree.Tick();
        Assert.AreEqual(false, isOK1);
        Assert.AreEqual(false, isOK2);

        // first timing has activated. second timing hasn't activated yet. if node become negative.
        tree.Tick();
        Assert.AreEqual(false, isOK1);
        Assert.AreEqual(true, isOK2);

        //second timing has activated.
        tree.Tick();
        Assert.AreEqual(false, isOK1);
        Assert.AreEqual(false, isOK2);

        //start from root
        tree.Tick();
        Assert.AreEqual(true, isOK1);
        Assert.AreEqual(true, isOK2);
    }
Esempio n. 20
0
 public BTComposite(BehaviourTree tree, BTNode[] nodes) : base(tree)
 {
     Children = new List <BTNode>(nodes);
 }
Esempio n. 21
0
 /// <summary>
 /// Constructs a new Repeat decorator behaviour.
 /// </summary>
 /// <param name="tree">The <see cref="BehaviourTree"/> this <see cref="IBehavior"/> belongs to.</param>
 /// <param name="child">The child behaviour we want to repeat.</param>
 /// <param name="count">The amount of times we want to repeat the <paramref name="child"/>.</param>
 public FiniteRepeater(BehaviourTree tree, IBehavior child, int count) : base(tree, child)
 {
     _count = count;
 }
 public BTSendTroopsToCelestialBody(BehaviourTree t) : base(t)
 {
 }
Esempio n. 23
0
        private void Start()
        {
            foreach(GameObject group in GroupsManager.Instance.Groups.Values)
            {
                _groupAggros.Add(group.GetComponent<GroupAggro>());
            }

            #region Behaviour tree

            #region Target selection

            BtCondition isTargetStillValid = new BtCondition(() => _currentTargetStillValid);

            BtAction tryChooseByAggro = new BtAction(TryChooseByAggro);

            BtSequence byAggroSequence = new BtSequence(new IBtTask[] { tryChooseByAggro });

            BtSelector targetSelection = new BtSelector(new IBtTask[] { isTargetStillValid, byAggroSequence });

            #endregion

            #region Attack

            BtCondition lastAttackDone = new BtCondition(() => _lastAttackDone);
            BtCondition isFacingTarget = new BtCondition(IsFacingTarget);
            BtCondition inAttackRange = new BtCondition(InAttackRange);

            BtAction chooseAttack = new BtAction(ChooseAttack);
            BtAction attack = new BtAction(Attack);

            BtSequence attackSequence = new BtSequence(new IBtTask[]
            {
                lastAttackDone,
                isFacingTarget,
                inAttackRange,
                chooseAttack,
                attack
            });

            #endregion

            BtSequence combatSequence = new BtSequence(new IBtTask[] { targetSelection, attackSequence });

            #endregion

            #region FSM

            FSMState idle = new FSMState();
            FSMState combat = new FSMState();

            combat.enterActions.Add(StartCombat);

            FSMTransition battleEnter = new FSMTransition(() => _inCombat);

            idle.AddTransition(battleEnter, combat);

            #endregion

            _combatBehaviourTree = new BehaviourTree(combatSequence);

            _bossFsm = new FSM(idle);

            _runFsmCoroutine = StartCoroutine(BossFsmUpdate());
        }
 public override bool Initialize(BehaviourTree behaviourTree)
 {
     return(behaviourTree is AIBehaviorTree && this.Initialize(behaviourTree as AIBehaviorTree));
 }
Esempio n. 25
0
 public BTDecoratorNode(BehaviourTree t, BTNode child) : base(t)
 {
     this.Child = child;
 }
Esempio n. 26
0
 public override void TreeCompleted(bool success, BehaviourTree tree)
 {
     base.TreeCompleted (success, tree);
 }
Esempio n. 27
0
 public void SetTreeSelection(BehaviourTree tree)
 {
     referencedNodes.Clear();
     ClearSelection();
     Selection.activeObject = tree;
 }
 public TreeLeafDebugNode(BehaviourTree tree, Context parentCtx) :
     base(tree, parentCtx)
 {
 }
Esempio n. 29
0
 public Leaf_Wait(BehaviourTree tree)
 {
     base.tree = tree;
 }
Esempio n. 30
0
 /// <summary>
 /// Construct a new <see cref="Filter"/> for the <paramref name="tree"/>.
 /// </summary>
 /// <param name="tree"></param>
 public Filter(BehaviourTree tree) : base(tree)
 {
 }
Esempio n. 31
0
 /// <summary>
 /// Builds the <see cref="Condition"/>.
 /// </summary>
 /// <param name="tree">The tree the resulting <see cref="Condition"/> is to be a part of.</param>
 /// <returns>The build <see cref="Condition"/>.</returns>
 public override IBehavior Build(BehaviourTree tree)
 {
     enabled = false;
     return(new Condition(tree, ValidateCondition, _mode));
 }
Esempio n. 32
0
 public abstract void SetTree(BehaviourTree _mTree);
Esempio n. 33
0
    public void Init()
    {
        BT_Root      root = new BT_Root(); behaviourTree = new BehaviourTree(root); BT_Execute firstEx = new BT_Execute();
        BT_Interrupt InterruptTest     = new BT_Interrupt();
        BT_Execute   itrEx             = new BT_Execute();
        BT_Interrupt IfTest            = new BT_Interrupt();
        BT_If        if1               = new BT_If();
        BT_Execute   ifEx1             = new BT_Execute();
        BT_If        if2               = new BT_If();
        BT_Execute   ifEx2             = new BT_Execute();
        BT_If        if3               = new BT_If();
        BT_Execute   ifEx3             = new BT_Execute();
        BT_Interrupt WhileTest         = new BT_Interrupt();
        BT_While     while1            = new BT_While();
        BT_Execute   whileEx1          = new BT_Execute();
        BT_Execute   whileEx2          = new BT_Execute();
        BT_Interrupt SelectorTest      = new BT_Interrupt();
        BT_Selector  selector1         = new BT_Selector();
        BT_Execute   selectorEx2       = new BT_Execute();
        BT_If        selectorIf1       = new BT_If();
        BT_Execute   selectorEx1       = new BT_Execute();
        BT_Execute   selectorEx3       = new BT_Execute();
        BT_Interrupt SequenceTest      = new BT_Interrupt();
        BT_Sequence  sequence1         = new BT_Sequence();
        BT_Execute   sequenceEx1       = new BT_Execute();
        BT_If        sequenceIf1       = new BT_If();
        BT_Execute   sequenceEx2       = new BT_Execute();
        BT_Execute   sequenceEx3       = new BT_Execute();
        BT_Interrupt frameCounterTest  = new BT_Interrupt();
        BT_Execute   frameCounterEx1   = new BT_Execute();
        BT_Timing    frameCounter1     = new BT_Timing(behaviourTree, false, false, "frameCounter1");
        BT_Interrupt frameCounterTest2 = new BT_Interrupt();
        BT_Execute   frameCounterEx2   = new BT_Execute();
        BT_Interrupt frameCounterTest3 = new BT_Interrupt();
        BT_Execute   frameCounterEx3   = new BT_Execute();
        BT_Timing    frameCounter2     = new BT_Timing(behaviourTree, false, true, "frameCounter2");
        BT_Interrupt frameCounterTest4 = new BT_Interrupt();
        BT_Execute   frameCounterEx4   = new BT_Execute();
        BT_Timing    frameCounter3     = new BT_Timing(behaviourTree, true, false, "frameCounter3");
        BT_Interrupt frameCounterTest5 = new BT_Interrupt();
        BT_Execute   frameCounterEx5   = new BT_Execute();
        BT_Interrupt timerTest         = new BT_Interrupt();
        BT_Execute   timerTestEx1      = new BT_Execute();
        BT_Timing    timer1            = new BT_Timing(behaviourTree, false, false, "timer1");
        BT_Interrupt timerTest2        = new BT_Interrupt();
        BT_Execute   timerTestEx2      = new BT_Execute();
        BT_Interrupt timerTest3        = new BT_Interrupt();
        BT_Execute   timerTestEx3      = new BT_Execute();
        BT_Timing    timer2            = new BT_Timing(behaviourTree, false, true, "timer2");
        BT_Interrupt timerTest4        = new BT_Interrupt();
        BT_Execute   timerTestEx4      = new BT_Execute();
        BT_Timing    timer3            = new BT_Timing(behaviourTree, true, false, "timer3");
        BT_Interrupt timerTest5        = new BT_Interrupt();
        BT_Execute   timerTestEx5      = new BT_Execute();
        BT_Success   NextSequence      = new BT_Success();
        BT_Interrupt setParameterTest  = new BT_Interrupt();
        BT_Execute   SetBool1          = new BT_Execute();
        BT_Execute   SetBool2          = new BT_Execute();
        BT_Sequence  sequence          = new BT_Sequence();
        BT_If        setParameterIf1   = new BT_If();
        BT_Execute   setParameterEx1   = new BT_Execute();
        BT_If        setParameterIf2   = new BT_If();
        BT_Execute   setParameterEx2   = new BT_Execute();
        BT_Execute   SetBool3          = new BT_Execute();
        BT_If        setParameterIf3   = new BT_If();
        BT_Execute   setParameterEx3   = new BT_Execute();
        BT_Execute   SetInt1           = new BT_Execute();
        BT_If        setParameterIf4   = new BT_If();
        BT_Execute   setParameterEx4   = new BT_Execute();
        BT_Execute   SetInt2           = new BT_Execute();
        BT_If        setParameterIf5   = new BT_If();
        BT_Execute   setParameterEx5   = new BT_Execute();
        BT_Execute   SetFloat1         = new BT_Execute();
        BT_If        setParameterIf6   = new BT_If();
        BT_Execute   setParameterEx6   = new BT_Execute();
        BT_Execute   SetFloat2         = new BT_Execute();
        BT_If        setParameterIf7   = new BT_If();
        BT_Execute   setParameterEx7   = new BT_Execute();
        BT_While     while2            = new BT_While();
        BT_Execute   whileEx3          = new BT_Execute();
        BT_Interrupt CancelTest1Itr    = new BT_Interrupt();
        BT_Timing    CancelTest1FC     = new BT_Timing(behaviourTree, false, false, "CancelTest1FC");
        BT_Execute   CancelTest1Cancel = new BT_Execute();
        BT_If        CancelTest1If     = new BT_If();
        BT_Execute   CencelTest1Ex2    = new BT_Execute();
        BT_Execute   CencelTest1Ex1    = new BT_Execute();
        BT_Interrupt CancelTest2Itr    = new BT_Interrupt();
        BT_Execute   CencelTest2Ex1    = new BT_Execute();
        BT_Timing    CancelTest2FC     = new BT_Timing(behaviourTree, false, false, "CancelTest2FC");
        BT_Execute   CancelTest2Cancel = new BT_Execute();
        BT_If        CancelTest2If     = new BT_If();
        BT_Execute   CencelTest2Ex2    = new BT_Execute();
        BT_Timing    CancelTest2Timer  = new BT_Timing(behaviourTree, false, false, "CancelTest2Timer");

        firstEx.AddEvent(() => {
            first_ev.Invoke();
        });
        root.AddChild(firstEx);
        InterruptTest.SetCondition(() => {
            return(case2);
        });
        behaviourTree.AddInterrupt(InterruptTest);
        InterruptTest.AddChild(itrEx);
        itrEx.AddEvent(() => {
            itr_ev.Invoke();
        });
        IfTest.SetCondition(() => {
            return(case3);
        });
        behaviourTree.AddInterrupt(IfTest);
        IfTest.AddChild(if1);
        if1.SetCondition(() => {
            return(if_bool1);
        });
        if1.AddChild(ifEx1);
        ifEx1.AddEvent(() => {
            if_ev1.Invoke();
        });
        ifEx1.AddChild(if2);
        if2.SetCondition(() => {
            return(if_int1 > 10);
        });
        if2.AddChild(ifEx2);
        ifEx2.AddEvent(() => {
            if_ev2.Invoke();
        });
        ifEx2.AddChild(if3);
        if3.SetCondition(() => {
            return(if_float1 < 10.0f);
        });
        if3.AddChild(ifEx3);
        ifEx3.AddEvent(() => {
            if_ev3.Invoke();
        });
        while2.SetCondition(() => {
            return(while_bool2);
        });
        while2.AddChild(whileEx3);
        whileEx3.AddEvent(() => {
            while_ev3.Invoke();
        });
        while1.SetCondition(() => {
            return(while_bool1);
        });
        while1.AddChild(whileEx2);
        WhileTest.SetCondition(() => {
            return(case4);
        });
        behaviourTree.AddInterrupt(WhileTest);
        WhileTest.AddChild(whileEx1);
        whileEx1.AddEvent(() => {
            while_ev1.Invoke();
        });
        whileEx1.AddChild(while1);
        whileEx2.AddEvent(() => {
            while_ev2.Invoke();
        });
        whileEx2.AddChild(while2);
        selectorIf1.SetCondition(() => {
            return(selector_bool1);
        });
        selectorIf1.AddChild(selectorEx1);
        selectorEx1.AddEvent(() => {
            selector_ev1.Invoke();
        });
        SelectorTest.SetCondition(() => {
            return(case5);
        });
        behaviourTree.AddInterrupt(SelectorTest);
        SelectorTest.AddChild(selector1);
        selectorEx2.AddEvent(() => {
            selector_ev2.Invoke();
        });

        selector1.AddChild(selectorIf1);
        selector1.AddChild(selectorEx2);
        selector1.AddChild(selectorEx3);
        selectorEx3.AddEvent(() => {
            selector_ev3.Invoke();
        });
        sequenceEx1.AddEvent(() => {
            sequence_ev1.Invoke();
        });
        sequenceEx1.AddChild(NextSequence);

        SequenceTest.SetCondition(() => {
            return(case6);
        });
        behaviourTree.AddInterrupt(SequenceTest);
        SequenceTest.AddChild(sequence1);

        sequence1.AddChild(sequenceEx1);
        sequence1.AddChild(sequenceIf1);
        sequence1.AddChild(sequenceEx3);
        sequenceIf1.SetCondition(() => {
            return(sequence_bool1
                   );
        });
        sequenceIf1.AddChild(sequenceEx2);
        sequenceEx2.AddEvent(() => {
            sequence_ev2.Invoke();
        });
        sequenceEx3.AddEvent(() => {
            sequence_ev3.Invoke();
        });
        frameCounterEx2.AddEvent(() => {
            frameCounter_ev2.Invoke();
        });
        frameCounterTest.SetCondition(() => {
            return(case7);
        });
        behaviourTree.AddInterrupt(frameCounterTest);
        frameCounterTest.AddChild(frameCounterEx1);
        frameCounter1.SetTimingCreator(() => {
            return(new FrameCounter(frameCounterTest2, 1));
        });
        frameCounterTest2.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(frameCounterTest2);
        frameCounterTest2.AddChild(frameCounterEx2);
        frameCounterEx1.AddEvent(() => {
            frameCounter_ev1.Invoke();
        });
        frameCounterEx1.AddChild(frameCounter1);
        frameCounterTest3.SetCondition(() => {
            return(case8);
        });
        behaviourTree.AddInterrupt(frameCounterTest3);
        frameCounterTest3.AddChild(frameCounterEx3);
        frameCounterEx3.AddEvent(() => {
            frameCounter_ev3.Invoke();
        });
        frameCounterEx3.AddChild(frameCounter2);
        frameCounter2.SetTimingCreator(() => {
            return(new FrameCounter(frameCounterTest4, 1));
        });
        frameCounterTest4.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(frameCounterTest4);
        frameCounterTest4.AddChild(frameCounterEx4);
        frameCounterEx4.AddEvent(() => {
            frameCounter_ev4.Invoke();
        });
        frameCounterEx4.AddChild(frameCounter3);
        frameCounter3.SetTimingCreator(() => {
            return(new FrameCounter(frameCounterTest5, 1));
        });
        frameCounterTest5.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(frameCounterTest5);
        frameCounterTest5.AddChild(frameCounterEx5);
        frameCounterEx5.AddEvent(() => {
            frameCounter_ev5.Invoke();
        });
        timerTest.SetCondition(() => {
            return(case9);
        });
        behaviourTree.AddInterrupt(timerTest);
        timerTest.AddChild(timerTestEx1);
        timerTestEx1.AddEvent(() => {
            timerTest_ev1.Invoke();
        });
        timerTestEx1.AddChild(timer1);
        timer1.SetTimingCreator(() => {
            return(new Timer(timerTest2, 3));
        });
        timerTest2.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(timerTest2);
        timerTest2.AddChild(timerTestEx2);
        timerTestEx2.AddEvent(() => {
            timerTest_ev2.Invoke();
        });
        timerTest3.SetCondition(() => {
            return(case10);
        });
        behaviourTree.AddInterrupt(timerTest3);
        timerTest3.AddChild(timerTestEx3);
        timerTestEx3.AddEvent(() => {
            timerTest_ev3.Invoke();
        });
        timerTestEx3.AddChild(timer2);
        timer2.SetTimingCreator(() => {
            return(new Timer(timerTest4, 1.5));
        });
        timerTest4.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(timerTest4);
        timerTest4.AddChild(timerTestEx4);
        timerTestEx4.AddEvent(() => {
            timerTest_ev4.Invoke();
        });
        timerTestEx4.AddChild(timer3);
        timer3.SetTimingCreator(() => {
            return(new Timer(timerTest5, 3));
        });
        timerTest5.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(timerTest5);
        timerTest5.AddChild(timerTestEx5);
        timerTestEx5.AddEvent(() => {
            timerTest_ev5.Invoke();
        });
        SetBool1.AddEvent(() => {
            setParameterBool1 = true;
        });
        SetBool1.AddChild(setParameterIf1);
        SetBool2.AddEvent(() => {
            setParameterBool2 = false;
        });
        SetBool2.AddChild(setParameterIf2);
        setParameterIf1.SetCondition(() => {
            return(setParameterBool1);
        });
        setParameterIf1.AddChild(setParameterEx1);
        setParameterIf2.SetCondition(() => {
            return(!setParameterBool2);
        });
        setParameterIf2.AddChild(setParameterEx2);
        SetBool3.AddEvent(() => {
            setParameterBool2 = setParameterBool1;
        });
        SetBool3.AddChild(setParameterIf3);
        setParameterIf3.SetCondition(() => {
            return(setParameterBool2);
        });
        setParameterIf3.AddChild(setParameterEx3);
        setParameterEx3.AddEvent(() => {
            setParameterEv3.Invoke();
        });
        setParameterEx1.AddEvent(() => {
            setParameterEv1.Invoke();
        });
        setParameterEx1.AddChild(SetBool2);
        setParameterEx2.AddEvent(() => {
            setParameterEv2.Invoke();
        });
        setParameterEx2.AddChild(SetBool3);
        setParameterTest.SetCondition(() => {
            return(case11);
        });
        behaviourTree.AddInterrupt(setParameterTest);
        setParameterTest.AddChild(sequence);
        setParameterIf4.SetCondition(() => {
            return(setParameterInt1 == 1);
        });
        setParameterIf4.AddChild(setParameterEx4);
        setParameterIf5.SetCondition(() => {
            return(setParameterInt2 == 1);
        });
        setParameterIf5.AddChild(setParameterEx5);

        sequence.AddChild(SetBool1);
        sequence.AddChild(SetInt1);
        sequence.AddChild(SetFloat1);
        SetInt1.AddEvent(() => {
            setParameterInt1 = 1;
        });
        SetInt1.AddChild(setParameterIf4);
        setParameterEx4.AddEvent(() => {
            setParameterEv4.Invoke();
        });
        setParameterEx4.AddChild(SetInt2);
        SetInt2.AddEvent(() => {
            setParameterInt2 = setParameterInt1;
        });
        SetInt2.AddChild(setParameterIf5);
        setParameterEx5.AddEvent(() => {
            setParameterEv5.Invoke();
        });
        setParameterIf6.SetCondition(() => {
            return(setParameterFloat1 > 1.0f);
        });
        setParameterIf6.AddChild(setParameterEx6);
        setParameterEx6.AddEvent(() => {
            setParameterEv6.Invoke();
        });
        setParameterEx6.AddChild(SetFloat2);
        setParameterIf7.SetCondition(() => {
            return(setParameterFloat1 < 1.0f);
        });
        setParameterIf7.AddChild(setParameterEx7);
        SetFloat1.AddEvent(() => {
            setParameterFloat1 = 1.5f;
        });
        SetFloat1.AddChild(setParameterIf6);
        SetFloat2.AddEvent(() => {
            setParameterFloat1 = setParameterFloat2;
        });
        SetFloat2.AddChild(setParameterIf7);
        setParameterEx7.AddEvent(() => {
            setParameterEv7.Invoke();
        });
        CancelTest1Itr.SetCondition(() => {
            return(case12);
        });
        behaviourTree.AddInterrupt(CancelTest1Itr);
        CancelTest1Itr.AddChild(CencelTest1Ex1);
        CancelTest1FC.SetTimingCreator(() => {
            return(new FrameCounter(CencelTest1Ex2, 0));
        });
        CancelTest1FC.AddChild(CancelTest1Cancel);
        CancelTest1Cancel.AddEvent(() => {
            behaviourTree.CancelTiming(false, "", "CancelTest1FC");
        });
        CancelTest1Cancel.AddChild(CancelTest1If);
        CencelTest1Ex1.AddEvent(() => {
            cancelTest1ev1.Invoke();
        });
        CencelTest1Ex1.AddChild(CancelTest1FC);
        CancelTest1If.SetCondition(() => {
            return(false);
        });
        CancelTest1If.AddChild(CencelTest1Ex2);
        CencelTest1Ex2.AddEvent(() => {
            cancelTest1ev2.Invoke();
        });
        CancelTest2Itr.SetCondition(() => {
            return(case13);
        });
        behaviourTree.AddInterrupt(CancelTest2Itr);
        CancelTest2Itr.AddChild(CencelTest2Ex1);
        CencelTest2Ex1.AddEvent(() => {
            cancelTest2ev1.Invoke();
        });
        CencelTest2Ex1.AddChild(CancelTest2FC);
        CancelTest2FC.SetTimingCreator(() => {
            return(new FrameCounter(CencelTest2Ex2, 0));
        });
        CancelTest2FC.AddChild(CancelTest2Timer);
        CancelTest2Cancel.AddEvent(() => {
            behaviourTree.CancelTiming(true, "");
        });
        CancelTest2Cancel.AddChild(CancelTest2If);
        CancelTest2Timer.SetTimingCreator(() => {
            return(new Timer(CencelTest2Ex2, 0.5));
        });
        CancelTest2Timer.AddChild(CancelTest2Cancel);
        CancelTest2If.SetCondition(() => {
            return(false);
        });
        CancelTest2If.AddChild(CencelTest2Ex2);
        CencelTest2Ex2.AddEvent(() => {
            cancelTest2ev2.Invoke();
        });


        calledFlag = new Dictionary <string, bool>();
        calledFlag.Add("firstEx", false);
        first_ev.AddListener(() => {
            calledFlag["firstEx"] = true;
        }); calledFlag.Add("itrEx", false);
        itr_ev.AddListener(() => {
            calledFlag["itrEx"] = true;
        }); calledFlag.Add("ifEx1", false);
        if_ev1.AddListener(() => {
            calledFlag["ifEx1"] = true;
        }); calledFlag.Add("ifEx2", false);
        if_ev2.AddListener(() => {
            calledFlag["ifEx2"] = true;
        }); calledFlag.Add("ifEx3", false);
        if_ev3.AddListener(() => {
            calledFlag["ifEx3"] = true;
        }); calledFlag.Add("whileEx1", false);
        while_ev1.AddListener(() => {
            calledFlag["whileEx1"] = true;
        }); calledFlag.Add("whileEx2", false);
        while_ev2.AddListener(() => {
            calledFlag["whileEx2"] = true;
        }); calledFlag.Add("selectorEx2", false);
        selector_ev2.AddListener(() => {
            calledFlag["selectorEx2"] = true;
        }); calledFlag.Add("selectorEx1", false);
        selector_ev1.AddListener(() => {
            calledFlag["selectorEx1"] = true;
        }); calledFlag.Add("selectorEx3", false);
        selector_ev3.AddListener(() => {
            calledFlag["selectorEx3"] = true;
        }); calledFlag.Add("sequenceEx1", false);
        sequence_ev1.AddListener(() => {
            calledFlag["sequenceEx1"] = true;
        }); calledFlag.Add("sequenceEx2", false);
        sequence_ev2.AddListener(() => {
            calledFlag["sequenceEx2"] = true;
        }); calledFlag.Add("sequenceEx3", false);
        sequence_ev3.AddListener(() => {
            calledFlag["sequenceEx3"] = true;
        }); calledFlag.Add("frameCounterEx1", false);
        frameCounter_ev1.AddListener(() => {
            calledFlag["frameCounterEx1"] = true;
        }); calledFlag.Add("frameCounterEx2", false);
        frameCounter_ev2.AddListener(() => {
            calledFlag["frameCounterEx2"] = true;
        }); calledFlag.Add("frameCounterEx3", false);
        frameCounter_ev3.AddListener(() => {
            calledFlag["frameCounterEx3"] = true;
        }); calledFlag.Add("frameCounterEx4", false);
        frameCounter_ev4.AddListener(() => {
            calledFlag["frameCounterEx4"] = true;
        }); calledFlag.Add("frameCounterEx5", false);
        frameCounter_ev5.AddListener(() => {
            calledFlag["frameCounterEx5"] = true;
        }); calledFlag.Add("timerTestEx1", false);
        timerTest_ev1.AddListener(() => {
            calledFlag["timerTestEx1"] = true;
        }); calledFlag.Add("timerTestEx2", false);
        timerTest_ev2.AddListener(() => {
            calledFlag["timerTestEx2"] = true;
        }); calledFlag.Add("timerTestEx3", false);
        timerTest_ev3.AddListener(() => {
            calledFlag["timerTestEx3"] = true;
        }); calledFlag.Add("timerTestEx4", false);
        timerTest_ev4.AddListener(() => {
            calledFlag["timerTestEx4"] = true;
        }); calledFlag.Add("timerTestEx5", false);
        timerTest_ev5.AddListener(() => {
            calledFlag["timerTestEx5"] = true;
        }); calledFlag.Add("setParameterEx1", false);
        setParameterEv1.AddListener(() => {
            calledFlag["setParameterEx1"] = true;
        }); calledFlag.Add("setParameterEx2", false);
        setParameterEv2.AddListener(() => {
            calledFlag["setParameterEx2"] = true;
        }); calledFlag.Add("setParameterEx3", false);
        setParameterEv3.AddListener(() => {
            calledFlag["setParameterEx3"] = true;
        }); calledFlag.Add("setParameterEx4", false);
        setParameterEv4.AddListener(() => {
            calledFlag["setParameterEx4"] = true;
        }); calledFlag.Add("setParameterEx5", false);
        setParameterEv5.AddListener(() => {
            calledFlag["setParameterEx5"] = true;
        }); calledFlag.Add("setParameterEx6", false);
        setParameterEv6.AddListener(() => {
            calledFlag["setParameterEx6"] = true;
        }); calledFlag.Add("setParameterEx7", false);
        setParameterEv7.AddListener(() => {
            calledFlag["setParameterEx7"] = true;
        }); calledFlag.Add("whileEx3", false);
        while_ev3.AddListener(() => {
            calledFlag["whileEx3"] = true;
        }); calledFlag.Add("CencelTest1Ex2", false);
        cancelTest1ev2.AddListener(() => {
            calledFlag["CencelTest1Ex2"] = true;
        }); calledFlag.Add("CencelTest1Ex1", false);
        cancelTest1ev1.AddListener(() => {
            calledFlag["CencelTest1Ex1"] = true;
        }); calledFlag.Add("CencelTest2Ex1", false);
        cancelTest2ev1.AddListener(() => {
            calledFlag["CencelTest2Ex1"] = true;
        }); calledFlag.Add("CencelTest2Ex2", false);
        cancelTest2ev2.AddListener(() => {
            calledFlag["CencelTest2Ex2"] = true;
        });
    }
Esempio n. 34
0
 /// <inheritdoc />
 protected override Composite ConstructComposite(BehaviourTree tree)
 {
     return(new Filter(tree));
 }
        void Start()
        {
            var bt = new BehaviourTree <TestDataStore> ();

            // BehaviourTreeSequence test.
            bt.GetRootNode()
            .Then(bt, OnNode1)
            .Then(bt, OnNode2)
            .Then(bt, t => {
                Debug.Log("lambda node - ok");
                return(BehaviourTreeResult.Success);
            })
            // Nested BehaviourTreeSequence test.
            .Sequence().Then(bt, t => {
                Debug.Log("internal_sequence1 - ok");
                return(BehaviourTreeResult.Success);
            })
            .Then(bt, t => {
                Debug.Log("internal_sequence2 - ok");
                return(BehaviourTreeResult.Success);
            });

            // BehaviourTreeParallel test.
            bt.GetRootNode()
            .Parallel()
            .Then(bt, t => {
                Debug.Log("parallel_node1 - ok");
                return(BehaviourTreeResult.Success);
            })
            .Then(bt, t => {
                _pending2++;
                if (_pending2 < 2)
                {
                    Debug.Log("parallel_node2 - pending");
                    return(BehaviourTreeResult.Pending);
                }
                Debug.Log("parallel_node2 - ok");
                return(BehaviourTreeResult.Success);
            })

            // BehaviourTreeCondition test.
            .When(bt, t => {
                _pending3++;
                return(_pending3 >= 2 ? BehaviourTreeResult.Success : BehaviourTreeResult.Fail);
            })
            .Then(bt, t => {
                Debug.Log("wow, pending counter >= 2!");
                return(BehaviourTreeResult.Success);
            });

            // BehaviourTreeSelector test.
            bt.GetRootNode()
            .Select()
            .Then(bt, t => {
                Debug.Log("will be processed");
                return(BehaviourTreeResult.Fail);
            })
            .Then(bt, t => {
                Debug.Log("will be processed too");
                return(BehaviourTreeResult.Fail);
            })
            .Then(bt, t => {
                Debug.Log("will be processed and stopped on it");
                return(BehaviourTreeResult.Success);
            })
            .Then(bt, t => {
                Debug.Log("will not be processed because previous node returned positive result");
                return(BehaviourTreeResult.Fail);
            });

            // behaviour tree ready to process.

            BehaviourTreeResult res;

            do
            {
                res = bt.Process();
                Debug.Log(">>> " + res);
            } while (res == BehaviourTreeResult.Pending);
        }
Esempio n. 36
0
    override public void MakeTree()
    {
        base.MakeTree();
        BT_Root      root = new BT_Root(); behaviourTree = new BehaviourTree(root); BT_Selector selector1 = new BT_Selector();
        BT_Execute   attack               = new BT_Execute();
        BT_Execute   chase                = new BT_Execute();
        BT_Execute   patrol               = new BT_Execute();
        BT_Selector  selector2            = new BT_Selector();
        BT_If        if_found             = new BT_If();
        BT_If        If_attack            = new BT_If();
        BT_Execute   attackable_check     = new BT_Execute();
        BT_Execute   moveableCheck        = new BT_Execute();
        BT_If        if_patrol            = new BT_If();
        BT_If        If_chase             = new BT_If();
        BT_If        If_escape            = new BT_If();
        BT_Execute   escape               = new BT_Execute();
        BT_Interrupt DamageInterrupt      = new BT_Interrupt();
        BT_Execute   ResetDamageFlag      = new BT_Execute();
        BT_Execute   ActivateEscape       = new BT_Execute();
        BT_Timing    EscapeTimer          = new BT_Timing(behaviourTree, true, false);
        BT_Interrupt EscapeResetInterrupt = new BT_Interrupt();
        BT_Execute   EscapeResetter       = new BT_Execute();
        BT_Execute   SetFound             = new BT_Execute();

        If_escape.SetCondition(() => {
            return(IsEscape && IsMoveable);
        });
        If_escape.AddChild(escape);
        escape.AddEvent(() => {
            escape_event.Invoke();
        });
        if_found.SetCondition(() => {
            return(IsFound);
        });
        if_found.AddChild(selector2);
        If_attack.SetCondition(() => {
            return(IsAttackable);
        });
        If_attack.AddChild(attack);
        attackable_check.AddEvent(() => {
            attackablecheck_event.Invoke();
        });
        attackable_check.AddChild(If_attack);

        selector2.AddChild(If_escape);
        selector2.AddChild(attackable_check);
        selector2.AddChild(If_chase);
        attack.AddEvent(() => {
            attack_event.Invoke();
        });
        root.AddChild(moveableCheck);

        selector1.AddChild(if_found);
        selector1.AddChild(if_patrol);
        moveableCheck.AddEvent(() => {
            moveablecheck_event.Invoke();
        });
        moveableCheck.AddChild(selector1);
        if_patrol.SetCondition(() => {
            return(IsMoveable);
        });
        if_patrol.AddChild(patrol);
        patrol.AddEvent(() => {
            patrol_event.Invoke();
        });
        EscapeTimer.SetTimingCreator(() => {
            return(new Timer(EscapeResetInterrupt, 3.0));
        });
        EscapeTimer.AddChild(moveableCheck);
        ResetDamageFlag.AddEvent(() => {
            IsGotDamage = false;
        });
        ResetDamageFlag.AddChild(ActivateEscape);
        ActivateEscape.AddEvent(() => {
            IsEscape = true;
        });
        ActivateEscape.AddChild(EscapeTimer);
        SetFound.AddEvent(() => {
            IsFound = true;
        });
        SetFound.AddChild(ResetDamageFlag);
        If_chase.SetCondition(() => {
            return(IsMoveable);
        });
        If_chase.AddChild(chase);
        DamageInterrupt.SetCondition(() => {
            return(IsGotDamage);
        });
        behaviourTree.AddInterrupt(DamageInterrupt);
        DamageInterrupt.AddChild(SetFound);
        chase.AddEvent(() => {
            chase_event.Invoke();
        });
        EscapeResetInterrupt.SetCondition(() => {
            return(false);
        });
        behaviourTree.AddInterrupt(EscapeResetInterrupt);
        EscapeResetInterrupt.AddChild(EscapeResetter);
        EscapeResetter.AddEvent(() => {
            IsEscape = false;
        });
        EscapeResetter.AddChild(moveableCheck);
    }
Esempio n. 37
0
    public override bool Initialize(BehaviourTree behaviourTree)
    {
        QuestBehaviour questBehaviour = behaviourTree as QuestBehaviour;

        return(questBehaviour != null && this.Initialize(questBehaviour));
    }
Esempio n. 38
0
 public TreeRootNode(BehaviourTree tree, Context parentCtx) :
     base(tree, parentCtx)
 {
     context = new Context(null, this);
 }
Esempio n. 39
0
 public void Push(BTAsset asset, BehaviourTree instance)
 {
     m_history.Add(new Tuple <string, BehaviourTree>(AssetDatabase.GetAssetPath(asset), instance));
     AddRecentFile(asset);
     SaveRecentFiles();
 }
Esempio n. 40
0
 public BroadcastSentence(BehaviourTree tree, string sentenceKey, float range)
     : base(tree)
 {
     this.sentenceKey = sentenceKey;
     this.range = range;
 }
Esempio n. 41
0
 public BTNode(BehaviourTree t)
 {
     Tree = t;
 }
Esempio n. 42
0
 public SetRandomRoom(BehaviourTree tree, string destinationKey, string roomKey)
     : base(tree)
 {
     this.destinationKey = destinationKey;
     this.roomKey = roomKey;
 }
Esempio n. 43
0
 public CopyToNewKey(BehaviourTree tree, string key, string copyKey)
     : base(tree)
 {
     this.key = key;
     this.copyKey = copyKey;
 }
Esempio n. 44
0
 public DebugMessage(BehaviourTree tree, string message)
     : base(tree)
 {
     this.message = message;
 }
Esempio n. 45
0
 public Follow(BehaviourTree tree, string targetKey)
     : base(tree)
 {
     this.targetKey = targetKey;
 }
Esempio n. 46
0
 public SetSpeed(BehaviourTree tree, float speed)
     : base(tree)
 {
     this.speed = speed;
 }
Esempio n. 47
0
 public Sequencer(BehaviourTree t, BehaviourTreeNode[] children) : base(t, children)
 {
 }
Esempio n. 48
0
 public Follow(BehaviourTree tree, string targetKey, float stopping)
     : base(tree)
 {
     this.targetKey = targetKey;
     this.stopping = stopping;
 }
Esempio n. 49
0
 public SetResponse(BehaviourTree tree, Sentence inputSentence, string responseKey)
     : base(tree)
 {
     this.inputSentence = inputSentence;
     this.responseKey = responseKey;
 }
Esempio n. 50
0
 /// <inheritdoc />
 protected override Composite ConstructComposite(BehaviourTree tree)
 {
     return(new Monitor(tree, _successPolicy, _failurePolicy));
 }
Esempio n. 51
0
 public Repeater(BehaviourTree t, BehaviourTreeNode c) : base(t, c)
 {
 }
Esempio n. 52
0
 /// <summary>
 /// Construct a new <see cref="StatusRepeater"/>.
 /// </summary>
 /// <param name="tree">The tree that this <see cref="IBehavior"/> is a part of.</param>
 /// <param name="child">The child that this <see cref="Decorator"/> decorates.</param>
 /// <param name="repeatStatus">The terminating status for which we will repeat the child.</param>
 public StatusRepeater(BehaviourTree tree, IBehavior child, Status repeatStatus) : base(tree, child)
 {
     _repeatStatus = repeatStatus;
 }
Esempio n. 53
0
 public SetAloneWith(BehaviourTree tree, string locationKey, string aloneWithKey)
     : base(tree)
 {
     this.locationKey = locationKey;
     this.aloneWithKey = aloneWithKey;
 }
Esempio n. 54
0
 protected override IBehavior BuildDecorator(BehaviourTree tree, IBehavior child)
 {
     return(new FiniteRepeater(tree, child, _repeatCount));
 }
Esempio n. 55
0
 public Kill(BehaviourTree tree, string victimKey)
     : base(tree)
 {
     this.victimKey = victimKey;
 }
Esempio n. 56
0
 public Root(BehaviourTree tree, Node[] children)
     : base(children)
 {
     base.tree = tree;
 }
Esempio n. 57
0
 public WaitUntilTime(BehaviourTree tree, float time)
     : base(tree)
 {
     this.time = time;
 }
Esempio n. 58
0
 /// <summary>
 /// Construct a new Decorator Behavior.
 /// </summary>
 /// <param name="tree">The behaviour tree this node is a part of.</param>
 /// <param name="child"><see cref="Child"/>.</param>
 protected Decorator(BehaviourTree tree, IBehavior child) : base(tree)
 {
     Child = child;
 }
		public override void initialize (BehaviourTree.DataContext dataContext)
		{
			this._person = dataContext.person;

			base.initialize (dataContext);
		}
Esempio n. 60
0
 public BTRandomWalk(BehaviourTree tree) : base(tree)
 {
     NextDestination = Vector3.zero;
     FindNextDestination();
 }