示例#1
0
    // Use this for initialization
    void Start()
    {
        float RandomPersonality = Random.value;

        Debug.Log(gameObject.name + ": " + RandomPersonality);
        if (RandomPersonality < 0.2f)
        {
            Personality = HenPersonalities.AGGRESSIVE;
        }
        if (RandomPersonality >= 0.2f && RandomPersonality < 0.5f)
        {
            Personality = HenPersonalities.COWARD;
        }
        if (RandomPersonality >= 0.5f && RandomPersonality < 0.9f)
        {
            Personality = HenPersonalities.PROTECTIVE;
        }
        if (RandomPersonality >= 0.9f)
        {
            Personality = HenPersonalities.UNLIKABLE;
        }
        CurrentStatus = HenStatus.ROAMING;

        agent = GetComponent <NavMeshAgent>();
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        float RandomPersonality = Random.value;

        Debug.Log(gameObject.name + ": " + RandomPersonality);
        if (RandomPersonality < 0.2f)
        {
            Personality = HenPersonalities.AGGRESSIVE;
        }
        if (RandomPersonality >= 0.2f && RandomPersonality < 0.5f)
        {
            Personality = HenPersonalities.COWARD;
        }
        if (RandomPersonality >= 0.5f && RandomPersonality < 0.9f)
        {
            Personality = HenPersonalities.PROTECTIVE;
        }
        if (RandomPersonality >= 0.9f)
        {
            Personality = HenPersonalities.UNLIKABLE;
        }
        CurrentStatus = HenStatus.ROAMING;

        movAgent = GetComponent <NavMeshAgent>();

        // DT Decisions
        DTDecision decAnimationStop       = new DTDecision(AnimationStop);
        DTDecision decDistantFromRooster  = new DTDecision(DistantFromRooster);
        DTDecision decPlayerInFOV         = new DTDecision(PlayerInFOV);
        DTDecision decPlayerInAttackRange = new DTDecision(PlayerInAttackRange);
        DTDecision decChickInAttackRange  = new DTDecision(ChickInAttackRange);
        DTDecision decNearerToTheChick    = new DTDecision(NearerToTheChick);
        DTDecision decCowardHen           = new DTDecision(CowardHen);
        DTDecision decUnlikableHen        = new DTDecision(UnlikableHen);
        DTDecision decProtectiveHen       = new DTDecision(ProtectiveHen);

        // DT Actions
        DTAction actWait         = new DTAction(Wait);
        DTAction actChaseRooster = new DTAction(ChaseRooster);
        DTAction actFlee         = new DTAction(Flee);
        DTAction actProtect      = new DTAction(Protect);
        DTAction actEngageChick  = new DTAction(EngageChick);
        DTAction actEngagePlayer = new DTAction(EngagePlayer);
        DTAction actChasePlayer  = new DTAction(ChasePlayer);
        DTAction actRoam         = new DTAction(Roam);

        // DT Links
        decAnimationStop.AddLink(true, actWait);
        decAnimationStop.AddLink(false, decDistantFromRooster);

        decDistantFromRooster.AddLink(true, actChaseRooster);
        decDistantFromRooster.AddLink(false, decPlayerInFOV);

        decPlayerInFOV.AddLink(true, decCowardHen);
        decPlayerInFOV.AddLink(false, decUnlikableHen);

        decPlayerInAttackRange.AddLink(true, actEngagePlayer);
        decPlayerInAttackRange.AddLink(false, decProtectiveHen);

        decChickInAttackRange.AddLink(true, actEngageChick);
        decChickInAttackRange.AddLink(false, actRoam);

        decNearerToTheChick.AddLink(true, actProtect);
        decNearerToTheChick.AddLink(false, actChasePlayer);

        decCowardHen.AddLink(true, actFlee);
        decCowardHen.AddLink(false, decPlayerInAttackRange);

        decUnlikableHen.AddLink(true, decChickInAttackRange);
        decUnlikableHen.AddLink(false, actRoam);

        decProtectiveHen.AddLink(true, decNearerToTheChick);
        decProtectiveHen.AddLink(false, actChasePlayer);

        // Setup DT
        dt = new DecisionTree(decAnimationStop);
    }