﻿using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IngameController : MonoBehaviour {

    public bool isGamePaused;
    public AudioSource musicNormal;
    public AudioSource musicNyan;

    // Use this for initialization
    void Start ()
    {
        GetComponent<GameSettings>().LoadSave();
        GameObject.Find("Player").GetComponent<PlayerController>().coins = GetComponent<GameSettings>().activeSaveGame.spaceCoins;
    }
	
	// Update is called once per frame
	void Update ()
    {
        if (musicNormal.volume != GetComponent<GameSettings>().activeConfig.musicVolume)
        {
            musicNormal.volume = GetComponent<GameSettings>().activeConfig.musicVolume;
        }

        if (musicNyan.volume != GetComponent<GameSettings>().activeConfig.musicVolume)
        {
            musicNyan.volume = GetComponent<GameSettings>().activeConfig.musicVolume;
        }


        if (isGamePaused)
        {
            if(Time.timeScale != 0)
            {
                Time.timeScale = 0;
                musicNormal.volume = 0;
                musicNyan.volume = 0;
            }
        }

        else
        {
            if (Time.timeScale != 1)
            {
                Time.timeScale = 1;
                musicNormal.volume = 0.25f;
                musicNyan.volume = 1;
            }
        }
	}

    
}

