Beispiel #1
0
        public FPSAgentKebabiste()
        {
            selector = new Selector();

            // Si vie inférieur à un montant, va se cacher
            SequenceAction    wantToHide            = new SequenceAction(() => SetIntent(Action.Hide));
            SequenceCondition sequenceConditionHide = new SequenceCondition(CheckLowLife, wantToHide);

            selector.AddNode(sequenceConditionHide);

            // Si ammo inférieur à un montant, va recharger
            SequenceAction    wantToReload            = new SequenceAction(() => SetIntent(Action.Reload), EndReload);
            SequenceCondition sequenceConditionReload = new SequenceCondition(CheckAmmo, wantToReload);

            selector.AddNode(sequenceConditionReload);

            // Si Ok
            Selector       findOrShootSelector = new Selector();
            NodeAlwaysTrue shootOrMove         = new NodeAlwaysTrue(findOrShootSelector);

            // Si cible en vue, tire
            SequenceAction    shootOpponent             = new SequenceAction(() => SetIntent(Action.Shoot));
            SequenceCondition sequenceConditionCanShoot = new SequenceCondition(CanShootOpponent, shootOpponent);

            findOrShootSelector.AddNode(sequenceConditionCanShoot);

            // Si cible non en vu, se déplacer
            SequenceAction goNearAction     = new SequenceAction(() => SetIntent(Action.GoNear));
            NodeAlwaysTrue alwaysTrueGoNear = new NodeAlwaysTrue(goNearAction);

            findOrShootSelector.AddNode(alwaysTrueGoNear);

            selector.AddNode(shootOrMove);
        }
Beispiel #2
0
        public AgentKebabiste()
        {
            selector = new Selector();

            // Init different sequences

            // Si le stress est trop haut
            SequenceAction sequenceTakeBreak = new SequenceAction(() =>
                                                                  SetIntent(new KebabisteIntent {
                action = Action.TakeBreak
            })
                                                                  );
            SequenceCondition sequenceCheckStress = new SequenceCondition(CheckStressCondition, sequenceTakeBreak);

            selector.AddNode(sequenceCheckStress);

            // Si il manque des ingrédients pour la recette
            CreateSequenceForRecipe();

            // Si l'adversaire à un niveau de stress élevé ou il est trop en avance
            SequenceAction sequenceAttackOpponent = new SequenceAction(() =>
            {
                Action attackAction = Random.Range(0, 2) == 0 ? Action.FakeClient : Action.Corrupt;
                SetIntent(new KebabisteIntent
                {
                    action = attackAction
                });
            });
            SequenceCondition sequenceOpponentCondition =
                new SequenceCondition(CheckOpponentStressCondition, sequenceAttackOpponent);

            selector.AddNode(sequenceOpponentCondition);

            // Si le seuil d'ingredient préparé est trop bas
            CreateSequencePrepareIngredient();

            // Si un plat est attendu et peut être préparé
            SequenceAction sequencePrepareRecipe = new SequenceAction(() =>
                                                                      SetIntent(new KebabisteIntent {
                action = Action.CreateDish
            })
                                                                      );
            SequenceCondition sequenceRecipeCanBeMade =
                new SequenceCondition(CheckRecipeCanBeMade, sequencePrepareRecipe);

            selector.AddNode(sequenceRecipeCanBeMade);

            // action par defaut;
            NodeAlwaysTrue defaultSequence = new NodeAlwaysTrue();

            selector.AddNode(defaultSequence);
        }