Exemple #1
0
        public override void ExecuteTactic(ImpAi imp)
        {
            if (_impAi == null)
            {
                _impAi = imp;
            }

            if (_impCombatBehaviour == null)
            {
                _impCombatBehaviour = _impAi.GetComponent <ImpCombatBehaviour>();
            }

            if (_attackInstance == null)
            {
                _attackInstance = data.TacticAttack.GetAttack();
            }

            if (_tacticBehaviourTree == null)
            {
                BtCondition isFacingTarget = new BtCondition(IsFacingTarget);
                BtCondition inAttackRange  = new BtCondition(InAttackRange);

                BtAction attack = new BtAction(Attack);

                BtSequence meleeAttack = new BtSequence(new IBtTask[] { isFacingTarget, inAttackRange, attack });

                _tacticBehaviourTree = new BehaviourTree(meleeAttack);
            }

            _tacticBehaviourTree.Run();
        }
Exemple #2
0
        public override void ExecuteTactic(ImpAi imp)
        {
            if (_imp == null)
            {
                _imp = imp;
                //_contextGroupFormation = imp.GetComponent<ContextGroupFormation>();
                _impRecruitBehaviour = imp.GetComponent <ImpRecruitBehaviour>();

                BtAction startRecruit = new BtAction(StartRecruit);
                BtAction stopRecruit  = new BtAction(StopRecruit);
                //BtCondition inPositionCondition = new BtCondition(InPosition);
                BtCondition isRecruiting    = new BtCondition(() => _isRecruiting);
                BtCondition isNotRecruiting = new BtCondition(() => !_isRecruiting);

                BtSelector startRecruitSelector = new BtSelector(new IBtTask[] { isRecruiting, startRecruit });
                BtSelector stopRecruitSelector  = new BtSelector(new IBtTask[] { isNotRecruiting, stopRecruit });

                BtSequence startRecruitSequence =
                    new BtSequence(new IBtTask[] { startRecruitSelector });

                BtSelector recruitTree = new BtSelector(new IBtTask[] { startRecruitSequence, stopRecruitSelector });

                _recruitBehaviourTree = new BehaviourTree(recruitTree);
            }

            _recruitBehaviourTree.Run();
        }