Пример #1
0
    //Plays a set of functions like audio noises based on the ghost's distance from the player
    private void PerformDistanceFunctions(string newDistanceState)
    {
        //Depending on the ghost proximity to the player
        //Play the heart beat sound and ghost noises
        switch (newDistanceState)
        {
        case "Closeby":
            playerAudio.PlayGhostNoise(this.gameObject, (float)ghostDistance.Near);
            chasingPlayer = true;
            playerAudio.Heartbeat(this.gameObject, "rapidbeat");
            currentDistanceState = ghostDistance.Closeby;
            break;

        case "Near":
            playerAudio.PlayGhostNoise(this.gameObject, (float)ghostDistance.Near);
            chasingPlayer = true;
            playerAudio.Heartbeat(this.gameObject, "fastbeat");
            currentDistanceState = ghostDistance.Near;
            break;

        case "Middle":
            if (!enteredDetectionDistance)
            {
                enteredDetectionDistance = true;
                playerAudio.AddToGhostList(this.gameObject);
            }
            playerAudio.StopGhostNoises(this.gameObject, false);
            chasingPlayer = true;
            playerAudio.Heartbeat(this.gameObject, "slowbeat");
            currentDistanceState = ghostDistance.Middle;
            break;

        case "Far":
            if (enteredDetectionDistance)
            {
                enteredDetectionDistance = false;
                playerAudio.RemoveFromGhostList(this.gameObject);
            }
            playerAudio.StopGhostNoises(this.gameObject, true);
            currentDistanceState = ghostDistance.Far;
            break;

        default:
            Debug.LogWarning("Warning: Player distance state could not be detected!");
            break;
        }
    }