Beispiel #1
0
    public void SeekPlaque()
    {
        var prof = GetMemorizedProfessor(CurrentProfName);

        if (prof != null)
        {
            CurrentProf = prof;
            SeekProf();
            return;
        }

        CurrentStatus = Status.SeekingPlaque;

        if (student.path.Count == 0)
        {
            var currentCell = gameManager.Grid.WorldPointToCell(student.transform.position.x, student.transform.position.z);
            currentPlaqueInd = student.getNearestPlaqueIndex(currentCell);
        }
        else
        {
            currentPlaqueInd = student.getNearestPlaqueIndex(student.path[student.path.Count - 1].cell);
        }

        CurrentPlaque   = gameManager.Plaques[currentPlaqueInd];
        DestinationCell = CurrentPlaque.GetTargetCell();
    }
Beispiel #2
0
 public void SeekNextPlaque()
 {
     CurrentStatus    = Status.SeekingPlaque;
     currentPlaqueInd = (currentPlaqueInd + 1) % gameManager.Plaques.Length;
     CurrentPlaque    = gameManager.Plaques[currentPlaqueInd];
     DestinationCell  = CurrentPlaque.GetTargetCell();
 }
Beispiel #3
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;
        }
    }