// Use this for initialization void Start() { float RandomPersonality = Random.value; Debug.Log(gameObject.name + ": " + RandomPersonality); if (RandomPersonality < 0.1f) { Personality = ChickPersonalities.COCKY; } if (RandomPersonality >= 0.1f && RandomPersonality < 0.45f) { Personality = ChickPersonalities.COWARD; } if (RandomPersonality >= 0.45f && RandomPersonality < 0.6f) { Personality = ChickPersonalities.CURIOUS; } if (RandomPersonality >= 0.6f && RandomPersonality < 0.7f) { Personality = ChickPersonalities.SISSY; } if (RandomPersonality >= 0.7f) { Personality = ChickPersonalities.SLY; } CurrentStatus = ChickStatus.ROAMING; RoosterCollider[0] = Rooster.GetComponent <Collider>(); agent = GetComponent <NavMeshAgent>(); }
// Use this for initialization void Start() { float RandomPersonality = Random.value; Debug.Log(gameObject.name + ": " + RandomPersonality); if (RandomPersonality < 0.1f) { Personality = ChickPersonalities.COCKY; } if (RandomPersonality >= 0.1f && RandomPersonality < 0.45f) { Personality = ChickPersonalities.COWARD; } if (RandomPersonality >= 0.45f && RandomPersonality < 0.6f) { Personality = ChickPersonalities.CURIOUS; } if (RandomPersonality >= 0.6f && RandomPersonality < 0.7f) { Personality = ChickPersonalities.SISSY; } if (RandomPersonality >= 0.7f) { Personality = ChickPersonalities.SLY; } movAgent = GetComponent <NavMeshAgent>(); CurrentStatus = ChickStatus.ROAMING; // DT Decisions DTDecision decAnimationStop = new DTDecision(AnimationStop); DTDecision decDistantFromRooster = new DTDecision(DistantFromRooster); DTDecision decHenInFOV = new DTDecision(NearAHen); DTDecision decPlayerInFOV = new DTDecision(PlayerInFOV); DTDecision decPlayerInAlarmRange = new DTDecision(PlayerInAlarmRange); DTDecision decCockyChick = new DTDecision(CockyChick); DTDecision decCuriousChick = new DTDecision(CuriousChick); DTDecision decSissyChick = new DTDecision(SissyChick); DTDecision decSlyChick = new DTDecision(SlyChick); // DT Actions DTAction actWait = new DTAction(Wait); DTAction actChaseRooster = new DTAction(ChaseRooster); DTAction actChasePlayer = new DTAction(ChasePlayer); DTAction actChaseHen = new DTAction(ChaseHen); DTAction actStareAtPlayer = new DTAction(StareAtPlayer); DTAction actFleeFromPlayer = new DTAction(FleeFromPlayer); DTAction actFleeFromHen = new DTAction(FleeFromHen); DTAction actAlarm = new DTAction(Alarm); 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, decPlayerInAlarmRange); decPlayerInFOV.AddLink(false, decSissyChick); decPlayerInAlarmRange.AddLink(true, actAlarm); decPlayerInAlarmRange.AddLink(false, decCockyChick); decCockyChick.AddLink(true, actChasePlayer); decCockyChick.AddLink(false, decCuriousChick); decCuriousChick.AddLink(true, actStareAtPlayer); decCuriousChick.AddLink(false, decSlyChick); decSissyChick.AddLink(true, actFleeFromHen); decSissyChick.AddLink(false, actRoam); decSlyChick.AddLink(true, decHenInFOV); decSlyChick.AddLink(false, actFleeFromPlayer); decHenInFOV.AddLink(true, actChaseHen); decHenInFOV.AddLink(false, actChaseRooster); // Setup DT dt = new DecisionTree(decAnimationStop); RoosterCollider[0] = Rooster.GetComponent <Collider>(); }