private SceneSoundLibrary soundLibrary;  // Script wich contains all the used sounds for the scene.

    // Use this for initialization
    void Start()
    {
        trackController = GameObject.FindObjectOfType <TrackController>().GetComponent <TrackController>();
        soundLibrary    = GameObject.FindObjectOfType <SceneSoundLibrary>().GetComponent <SceneSoundLibrary>();

        if (trackController == null)
        {
            Debug.LogError("TrackController never got instanciated (Scene persistent object)");
        }
        if (soundLibrary == null)
        {
            Debug.LogError("SceneSoundLibrary not found in the scene");
        }
        if (MuteIconArray.Length != 3)
        {
            Debug.LogError("'MuteIconArray' not set correctly in 'VolSlidersController': 0 is background, 1 is FX, 2 is UI");
        }
        if (soundIcon == null || mutedIcon == null)
        {
            Debug.LogError("Mute/Unmute icons not set in 'VolSlidersController' in the settings object of the UI");
        }

        // Multiplies on 100 to set the correct slider values (o - 100 instead of 0 - 1)
        master.value     = trackController.masterVolume * 100;
        background.value = trackController.backgroundVolume * 100;
        fx.value         = trackController.fxVolume * 100;
        ui.value         = trackController.uiVolume * 100;
    }
Exemple #2
0
    void Start()
    {
        trackController = GameObject.FindObjectOfType <TrackController>().GetComponent <TrackController>();
        soundLibrary    = GameObject.FindObjectOfType <SceneSoundLibrary>().GetComponent <SceneSoundLibrary>();

        if (trackController == null)
        {
            Debug.LogError("TrackController never got instanciated (Scene persistent object)");
        }
        if (soundLibrary == null)
        {
            Debug.LogError("SceneSoundLibrary not found in the scene");
        }
    }
Exemple #3
0
    void Start() // Called everytime the object loads on a new scene
    {
        // Loads the new scene sound library
        soundLibrary = GameObject.FindObjectOfType <SceneSoundLibrary>().GetComponent <SceneSoundLibrary>();
        if (soundLibrary == null)
        {
            Debug.LogError("SceneSoundLibrary not found in the scene");
        }

        if (soundLibrary.backgroundLibrary.Length != 0) // Checks if there is any background clip to play on the scene
        {
            // Plays the new scene background cancelling the last one
            PlayBackgroundClip(soundLibrary.SelectSound("background", 0));
        }
        else
        {
            backgroundTrack.Stop(); // Avoids sounds from last scene keep playing when a new background is not set.
        }
    }
Exemple #4
0
    void Start()
    {
        Utils.freezed = false;
        myCollider    = GetComponent <BoxCollider2D>();
        if (myCollider == null)
        {
            Debug.LogError("Button collider for hovering not found.");
        }

        trackController = GameObject.FindObjectOfType <TrackController>().GetComponent <TrackController>();
        soundLibrary    = GameObject.FindObjectOfType <SceneSoundLibrary>().GetComponent <SceneSoundLibrary>();

        if (trackController == null)
        {
            Debug.LogError("TrackController never got instanciated (Scene persistent object)");
        }
        if (soundLibrary == null)
        {
            Debug.LogError("SceneSoundLibrary not found in the scene");
        }
    }
    public void Initialize(GridCell positionToHit, float timeToFall, float timeToStart, float warningSetTime, GameController controller, Shape shape)
    {
        // Starting audio components
        trackController = GameObject.FindObjectOfType <TrackController>().GetComponent <TrackController>();
        soundLibrary    = GameObject.FindObjectOfType <SceneSoundLibrary>().GetComponent <SceneSoundLibrary>();

        if (trackController == null)
        {
            Debug.LogError("TrackController never got instanciated (Scene persistent object)");
        }
        if (soundLibrary == null)
        {
            Debug.LogError("SceneSoundLibrary not found in the scene");
        }

        if (soundLibrary.meteorLibrary.Length != meteorFallingTimers.Length)
        {
            Debug.LogError("Check the audio arrays coherence in meteor lib with the sound timers array in the meteor.");
        }

        // It may be suitable to change the collision sound to a new lib in the SceneSoundLibrary & change code line 100 to the new lib array
        if (soundLibrary.fxLibrary.Length != meteorCollisionTimers.Length)
        {
            Debug.LogError("Check the audio arrays coherence in fx lib with the sound timers array in the meteor.");
        }

        // Rest of initialization
        hitShape           = shape;
        _fallingPosition   = positionToHit;
        transform.position = Camera.main.ScreenToWorldPoint(new Vector3(_fallingPosition.getScreenPosition().x, _fallingPosition.getScreenPosition().y, Camera.main.nearClipPlane + 1.0f));
        fallingTimeLeft    = timeToFall;
        timeToStartFalling = timeToStart;
        warningTime        = warningSetTime;
        _gameController    = controller;
        screenPosition     = positionToHit.getScreenPosition();
        fallingSoundIndex  = Random.Range(0, soundLibrary.meteorLibrary.Length); // Selects the falling audio to clip
        collideSoundIndex  = Random.Range(0, soundLibrary.fxLibrary.Length);     // Selects the collision audio to clip
        initialized        = true;
    }