예제 #1
0
        void Start()
        {
            var attackNode = new DecoratorNode(IsHpLessThan, new ActionNode(AttackEnemy));

            var moveTowerNode = new SequencerNode(new BehaviourTreeBase[] {
                new ActionNode(MoveNearTower),
                new ActionNode(Wait)
            });

            var rootNode = new SelectorNode(new BehaviourTreeBase[] {
                attackNode,
                moveTowerNode
            });

            node = new BehaviourTreeInstance(rootNode);
            node.finishRP.Where(item => item != BehaviourTreeInstance.NodeState.READY)
            .Subscribe(item => ResetCoroutineStart());
            node.Excute();
        }
예제 #2
0
        void CreateNodes()
        {
            var attackNode = new SequencerNode(new BehaviourTreeBase[] { new ActionNode(AttackEnemy) });

            var BuildingAttack = new SequencerNode(new BehaviourTreeBase[] { new ActionNode(AttackBuilding) });

            var PlayerAttack = new SequencerNode(new BehaviourTreeBase[] { attackNode });

            var discover = new SelectorNode(new BehaviourTreeBase[] { new ActionNode(PlayerDiscover), new ActionNode(BuildingDiscover) });

            var moveNode = new SelectorNode(new BehaviourTreeBase[] { new ActionNode(RightMove), discover });

            var rootNode = new SelectorNode(new BehaviourTreeBase[] {
                BuildingAttack, PlayerAttack, moveNode
            }
                                            );

            node = new BehaviourTreeInstance(rootNode);
            node.finishRP.Where(p => p != BehaviourTreeInstance.NodeState.READY).Subscribe(p => ResetCoroutineStart());
            node.finishRP.Value = BehaviourTreeInstance.NodeState.READY;
            node.Excute();
        }