Example #1
0
    // Returns success if health is above threshold or if no hp was found.
    // Returns running if in progress of going to hp.
    public static Node Tree_GetHealthpackIfLow(N_AgentNode.AgentType agent, int threshold)
    {
        N_Selection hpTree          = new N_Selection();
        N_DecFlip   flipHealthCheck = new N_DecFlip(new N_HealthThreshold(agent, threshold));
        N_DecFlip   flipGetHp       = new N_DecFlip(new N_GotoHealthpack(agent));

        hpTree.AddLast(flipHealthCheck);
        hpTree.AddLast(flipGetHp);

        hpTree.IsSubtree = true;
        return(hpTree);
    }
Example #2
0
    // Sequence for moving by patroling or kiting.
    // If an enemy is spotted, there's a probability of the agent either patroling.
    // or kiting. If no enemy, always patrol.
    // Returns success if path found and started.
    // Returns running if in process of walking towards destination.
    public static Node Tree_PatrolOrKite(N_AgentNode.AgentType agent)
    {
        N_ProbabilitySelector kiteOrPatrol = new N_ProbabilitySelector();

        kiteOrPatrol.AddLast(new N_Kite(agent));
        kiteOrPatrol.AddLast(new N_Patrol(agent));
        //N_DecSuccess kiteOrPatrolSuccess = new N_DecSuccess(kiteOrPatrol);

        N_Sequence enemyThenKiteOrPatrol = new N_Sequence();

        enemyThenKiteOrPatrol.AddLast(new N_IsEnemyVisible(agent));
        enemyThenKiteOrPatrol.AddLast(kiteOrPatrol);

        //N_DecSuccess patrolSuccess = new N_DecSuccess(new N_Patrol(agent));
        N_Selection enemyOrPatrol = new N_Selection();

        enemyOrPatrol.AddLast(enemyThenKiteOrPatrol);
        enemyOrPatrol.AddLast(new N_Patrol(agent));

        enemyOrPatrol.IsSubtree = true;
        return(enemyOrPatrol);
    }