示例#1
0
    void CheckWaypointBehaviour(Waypoint waypoint)
    {
        Waypoint.EnemyWaypointBehaviour behaviour = waypoint.wayPointBehaviour;
        if (waypoint.destroyAfterUse)
        {
            waypointHandler.DestroyWaypoint(waypointHandler.curWaypointTargetIndex);
        }
        else
        {
            waypointHandler.UpdateNextWaypointTargetIndex();
        }
        switch (behaviour)
        {
        case Waypoint.EnemyWaypointBehaviour.Continue:
            movement.MoveToNextWaypoint();
            break;

        case Waypoint.EnemyWaypointBehaviour.LookAround:
            stateHandler.SwitchToLookAroundState();
            break;

        default:
            break;
        }
    }
示例#2
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();
        }
    }