Exemplo n.º 1
0
        protected override INode CreateTree()
        {
            var context = (EnemyBehaviourTreeContext)_context;
            var ability = context.Self.GetAbilityManager().Get(AbilityType.JUMP_ATTACK);

            var hold = new HoldNode();

            var isJumpAttackOnCooldown = new IsAbilityOnCooldownNode(AbilityType.JUMP_ATTACK);
            var seqCooldownHold        = new Sequence("CooldownHoldSequence", isJumpAttackOnCooldown, hold);

            var isTargetInRangeForAttack = new IsTargetInRangeNode(ability.Range);
            var activateJumpAttack       = new ActivateAbilityNode(AbilityType.JUMP_ATTACK);
            var seqJumpAttack            = new Sequence("JumpAttackSequence", isTargetInRangeForAttack, activateJumpAttack);

            var isTargetInRangeForChase = new IsTargetInRangeNode(context.Self.GetAttributeManager().ValueOf(AttributeType.Vision));
            var lockOnTarget            = new LockOnTargetNode();
            var run      = new RunNode();
            var seqChase = new Sequence("ChaseSequence", isTargetInRangeForChase, lockOnTarget, run);

            var selector = new Selector("JumpAttackSelector",
                                        new Inverter(new HasTarget()),
                                        seqCooldownHold,
                                        seqJumpAttack,
                                        seqChase,
                                        hold);

            var repeater = new Repeater(selector);

            return(repeater);
        }
Exemplo n.º 2
0
        protected override INode CreateTree()
        {
            var doNothing = new DoNothingNode();

            var lockOn = new LockOnTargetNode();

            var checkDistanceForHold = new IsArrivedToDestinationNode(2f);
            var hold = new HoldNode();
            var seqCheckDistanceHold = new Sequence("MoveSequence", lockOn, checkDistanceForHold, hold);

            var move = new WalkNode();

            var selector = new Selector("NothingMoveSelector", doNothing, seqCheckDistanceHold, move);

            var repeater = new Repeater(selector);

            return(repeater);
        }
Exemplo n.º 3
0
        protected override INode CreateTree()
        {
            var context = (EnemyBehaviourTreeContext)_context;
            var ability = context.Self.GetAbilityManager().Get(AbilityType.SPEAR_LUNGE);

            var hold = new HoldNode();
            var isTargetInRangeForChase = new IsTargetInRangeNode(context.Self.GetAttributeManager().ValueOf(AttributeType.Vision));
            var isTargetInRangeForLunge = new IsTargetInRangeNode(ability.Range);

            var seqCooldownHold = new Sequence("CooldownHoldSequence",
                                               new IsAbilityOnCooldownNode(AbilityType.SPEAR_LUNGE),
                                               hold);

            var seqLunge = new Sequence("LungeSequence",
                                        isTargetInRangeForLunge,
                                        new Selector("LockSequence",
                                                     new IsAbilityActiveNode(AbilityType.SPEAR_LUNGE),
                                                     new LockOnTargetNode()),
                                        new ActivateAbilityNode(AbilityType.SPEAR_LUNGE));

            var seqChase = new Sequence("ChaseSequence",
                                        isTargetInRangeForChase,
                                        new Inverter(new IsAbilityActiveNode(AbilityType.SPEAR_LUNGE)),
                                        new LockOnTargetNode(),
                                        new RunNode());

            var selector = new Selector("LungeSelector",
                                        new Inverter(new HasTarget()),
                                        seqCooldownHold,
                                        seqLunge,
                                        seqChase,
                                        hold);

            var repeater = new Repeater(selector);

            return(repeater);
        }
Exemplo n.º 4
0
        protected override INode CreateTree()
        {
            var context      = (EnemyBehaviourTreeContext)_context;
            var abilityShoot = context.Self.GetAbilityManager().Get(AbilityType.SHOOT);
            var abilityDodge = context.Self.GetAbilityManager().Get(AbilityType.DODGE_LEFT);

            var hold             = new HoldNode();
            var isTargetInVision = new IsTargetInRangeNode(context.Self.GetAttributeManager().ValueOf(AttributeType.Vision));

            // Lock Target

            var lockSequence = new Sequence("LockSequence",
                                            isTargetInVision,
                                            new LockOnTargetNode());

            //

            // Actions

            var seqDodge = new Sequence("DodgeSequence",
                                        new IsTargetInRangeNode(abilityDodge.Range),
                                        new Inverter(new IsAbilityOnCooldownNode(AbilityType.DODGE_LEFT)),
                                        new Inverter(new IsAbilityOnCooldownNode(AbilityType.DODGE_RIGHT)),
                                        new Selector("DodgeSideSelector",
                                                     new RandomBinary(new ActivateAbilityNode(AbilityType.DODGE_LEFT)),
                                                     new RandomBinary(new ActivateAbilityNode(AbilityType.DODGE_RIGHT))),
                                        new DeactivateAbilityNode(AbilityType.SHOOT));

            var selectorDodge = new Selector("DodgeSelector",
                                             new IsAbilityActiveNode(AbilityType.DODGE_LEFT),
                                             new IsAbilityActiveNode(AbilityType.DODGE_RIGHT),
                                             seqDodge);

            var seqCooldownHold = new Sequence("CooldownHoldSequence",
                                               new IsAbilityOnCooldownNode(AbilityType.SHOOT),
                                               hold);

            var seqShoot = new Sequence("ShootSequence",
                                        new IsTargetInRangeNode(abilityShoot.Range),
                                        new ActivateAbilityNode(AbilityType.SHOOT));

            var seqChase = new Sequence("ChaseSequence",
                                        isTargetInVision,
                                        new RunNode());
            //

            var selectorAction = new Selector("ActionSelector",
                                              seqCooldownHold,
                                              seqShoot,
                                              seqChase,
                                              hold);

            var sequenceMain = new Sequence("MainSequence",
                                            new HasTarget(),
                                            new Inverter(selectorDodge),
                                            new Succeeder(lockSequence),
                                            selectorAction);

            var repeater = new Repeater(sequenceMain);

            return(repeater);
        }