Exemplo n.º 1
0
    /// <summary>
    /// Checks after secondsToWait if the player is still in line of sight, then switches to shooting/patrol state
    /// </summary>
    public IEnumerator CheckIfHeldLineOfSight()
    {
        float     secondsToWait  = 1;
        float     timeWaited     = 0;
        Coroutine ColorCoroutine = colorController.SwitchToHostileColour();

        while (timeWaited < secondsToWait)
        {
            timeWaited += Time.deltaTime;
            if (!IsPlayerInView())
            {
                colorController.StopCoroutine(ColorCoroutine);
                stateHandler.SwitchToLookAroundState();
                colorController.SwitchToAwareColour(true);
                yield break;
            }
            yield return(new WaitForFixedUpdate());
        }
        if (stateHandler.IsCurrentState(EnemyStateHandler.States.DetectedPlayer))
        {
            stateHandler.SwitchToShootingState();
        }
    }
Exemplo n.º 2
0
 public void SwitchToDetectedPlayerState()
 {
     colorController.SwitchToAwareColour();
     state = States.DetectedPlayer;
     movement.navAgent.isStopped = true;
 }