Пример #1
0
 public FilterNode(ConfigNode node)
 {
     Checks = new List <CheckNode>();
     foreach (ConfigNode subNode in node.GetNodes("CHECK"))
     {
         CheckNode c = CheckNodeFactory.MakeCheck(subNode);
         if (c != null)
         {
             Checks.Add(c);
         }
     }
     bool.TryParse(node.GetValue("invert"), out bool tmp);
     Invert = tmp;
 }
Пример #2
0
    private void SetDecisionTree()
    {
        CheckNode playerVisible      = new CheckNode(PlayerVisible);
        CheckNode playerWithinRange  = new CheckNode(PlayerWithinRange);
        CheckNode playerSeenRecently = new CheckNode(PlayerSeenRecently);

        ActionNode attack       = new ActionNode(Attack);
        ActionNode moveToPlayer = new ActionNode(MoveToPlayer);
        ActionNode wander       = new ActionNode(Wander);

        playerVisible.True  = playerWithinRange;
        playerVisible.False = playerSeenRecently;

        playerWithinRange.True  = attack;
        playerWithinRange.False = moveToPlayer;

        playerSeenRecently.True  = moveToPlayer;
        playerSeenRecently.False = wander;

        decisionTree = new DecisionTree(playerVisible);
    }
Пример #3
0
    private void SetDecisionTree()
    {
        //we need to create a decision tree for the behaviour of the non-tag npc's
        //first the check node to see if the it player is visible by us
        CheckNode it_player_visible = new CheckNode(ItPlayerVisible);

        //------------------- LEFT SUBTREE --------------------//
        //next a node to tell us if someone else can see the it player
        CheckNode it_player_spotted = new CheckNode(Manager.ItPlayerSpotted);
        //next a node to tell us if the last person to see the it player can still see him
        CheckNode it_player_still_visible = new CheckNode(ItPlayerStillVisible);

        //now the action nodes
        ActionNode Wander            = new ActionNode(SetWander);
        ActionNode MoveToLastSpotter = new ActionNode(SetMoveToLastSpotter);
        ActionNode Flank             = new ActionNode(SetFlank);

        //------------------- RIGHT SUBTREE ------------------//
        CheckNode  close_enough_to_tag = new CheckNode(ItPlayerInProximity);
        ActionNode ItPlayerNotClose    = new ActionNode(() => { }); //we do nothing in this case
        ActionNode ItPlayerClose       = new ActionNode(SetTagging);

        //now setting the relationships
        it_player_visible.False = it_player_spotted;
        it_player_visible.True  = close_enough_to_tag;

        it_player_spotted.False = Wander;
        it_player_spotted.True  = it_player_still_visible;

        it_player_still_visible.False = MoveToLastSpotter;
        it_player_still_visible.True  = Flank;

        close_enough_to_tag.False = ItPlayerNotClose;
        close_enough_to_tag.True  = ItPlayerClose;

        decisionTree = new DecisionTree(it_player_visible);
    }