示例#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);
        }
        protected override INode CreateTree()
        {
            var context = (EnemyBehaviourTreeContext)_context;

            var abilityBlock = context.Self.GetAbilityManager().Get(AbilityType.BLOCK);
            var turn         = new TurnNode(1f);

            var isTargetInVision     = new IsTargetInRangeNode(context.Self.GetAttributeManager().ValueOf(AttributeType.Vision));
            var isTargetInBlockRange = new IsTargetInRangeNode(abilityBlock.Range);

            var seqBlock = new Sequence("BlockSequence",
                                        isTargetInBlockRange,
                                        new ActivateAbilityNode(abilityBlock.Type),
                                        turn);

            var seqChase = new Sequence("ChaseSequence",
                                        isTargetInVision,
                                        new DeactivateAbilityNode(abilityBlock.Type),
                                        new LockOnTargetNode(),
                                        new WalkNode());

            var selector = new Selector("BlockChaseSelector",
                                        new Inverter(new HasTarget()),
                                        seqBlock,
                                        seqChase);

            var repeater = new Repeater(selector);

            return(repeater);
        }
        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);
        }
示例#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);
        }