Beispiel #1
0
    // called after the last state is finished
    // implementation of the behavior tree
    public void NextState()
    {
        switch (CurrentStatus) // checking the previous status
        {
        case Status.SeekingPlaque:
            if (last4Professors.Count >= 4)
            {
                last4Professors.RemoveAt(0);
            }
            last4Professors.Add(CurrentPlaque.GetProfessor());

            if (CurrentPlaque.HasProfessor(CurrentProfName)) // plaque found
            {
                CurrentProf = CurrentPlaque.GetProfessor();
                SeekProf();
            }
            else // find next plaque
            {
                SeekNextPlaque();
            }
            break;

        case Status.SeekingProf:
            ConsultProf();
            break;

        case Status.ConsultingProf:
            ConsultProfIdle();
            break;

        case Status.ConsultingProfIdling:
            IsIdling = false;
            if (Random.value < 0.5f) // 50/50 chance of idling or seeking the next prof
            {
                SeekIdlingCell();
            }
            else
            {
                SeekPlaque();
            }
            break;

        case Status.SeekingIdleCell:
            RandomIdle();
            break;

        case Status.RandomIdling:
            IsIdling = false;
            SeekPlaque();
            break;
        }
    }