Exemplo n.º 1
0
    void Start()
    {
        try
        {
            soundData data = saveSystem.LoadSoundPref();
            music = data.music;
        }catch (Exception e)
        {
            music = true;
        }

        if (music)
        {
            StartCoroutine(AudioController.FadeIn(GetComponent <AudioSource>(), 1f));
        }

        showSettings = false;
        //soundEnabled = true;
        //musicEnabled = true;
        StartCoroutine(startSunlightAnimation());
        LoadData();
        LoadPLayerData();
        //save both information
        playerObject.GetComponent <SpriteRenderer>().sprite = GameAssets.i.GetCharacterSprite(index);
        playerObject.GetComponent <Animator>().runtimeAnimatorController = GameAssets.i.controllers[index];
    }
Exemplo n.º 2
0
    // ------------------------------------------------------------- //
    public static void SaveSoundPref(bool music, bool sound)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/mus.nfo";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        soundData data = new soundData(music, sound);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemplo n.º 3
0
    public static soundData LoadSoundPref()
    {
        string path = Application.persistentDataPath + "/mus.nfo";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            soundData       data      = formatter.Deserialize(stream) as soundData;
            stream.Close();
            return(data);
        }
        else
        {
            throw new Exception("Save file not found in " + path);
        }
    }
Exemplo n.º 4
0
 private void Awake()
 {
     try
     {
         soundData data = saveSystem.LoadSoundPref();
         music = data.music;
     }
     catch (System.Exception e)
     {
         music = true;
     }
     LoadGameData();
     if (music)
     {
         StartCoroutine(AudioController.FadeIn(GetComponent <AudioSource>(), 1f));
     }
 }
Exemplo n.º 5
0
    private void Awake()
    {
        try
        {
            soundData data = saveSystem.LoadSoundPref();
            soundEnabled = data.sound;
        }catch (Exception e)
        {
            soundEnabled = true;
        }

        foreach (Sound s in sounds)
        {
            s.source      = gameObject.AddComponent <AudioSource>();
            s.source.clip = s.clip;

            s.source.volume = s.volume;
            s.source.pitch  = s.pitch;
            s.source.mute   = !soundEnabled;
        }
    }
Exemplo n.º 6
0
    private void Awake()
    {
        try
        {
            soundData data = saveSystem.LoadSoundPref();
            musicEnabled = data.music;
            soundEnabled = data.sound;
        }
        catch (Exception e)
        {
            musicEnabled = true;
            soundEnabled = true;
        }

        if (!musicEnabled)
        {
            musicIcon.GetComponent <Image>().color = new Color32(168, 117, 68, 255);
        }

        if (!soundEnabled)
        {
            soundIcon.GetComponent <Image>().color = new Color32(168, 117, 68, 255);
        }
    }