Example #1
0
    private N_CompositionNode RandomComp()
    {
        N_CompositionNode randomComp;
        int randomComposition = UnityEngine.Random.Range(0, 3);

        switch (randomComposition)
        {
        case 0:
            randomComp = new N_Selection();
            break;

        case 1:
            randomComp = new N_Sequence();
            break;

        case 2:
            randomComp = new N_ProbabilitySelector();
            break;

        default:
            randomComp = null;
            Debug.LogError("No comp was chosen for generation of BT.");
            break;
        }
        return(randomComp);
    }
Example #2
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 #3
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);
    }