// Use this for initialization
    void Awake()
    {
        Application.targetFrameRate = 60;
        Instance      = this;
        RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");
        DateOfExit    = PlayerPrefs.GetString("DateOfExit", "");
        print(DateOfExit);
        Gems  = PlayerPrefs.GetInt("Gems");
        lifes = PlayerPrefs.GetInt("Lifes");
        {//2.2.2 rewarded limit
            dailyRewardedShown     = new int[Enum.GetValues(typeof(RewardedAdsType)).Length];
            dailyRewardedShownDate = new DateTime[Enum.GetValues(typeof(RewardedAdsType)).Length];
            for (int i = 0; i < dailyRewardedShown.Length; i++)
            {
                dailyRewardedShown[i]     = PlayerPrefs.GetInt(((RewardedAdsType)i).ToString());
                dailyRewardedShownDate[i] = DateTimeManager.GetLastDateTime(((RewardedAdsType)i).ToString());
            }
        }
        if (PlayerPrefs.GetInt("Lauched") == 0)
        {    //First lauching
            lifes = CapOfLife;
            PlayerPrefs.SetInt("Lifes", lifes);
            Gems = FirstGems;
            PlayerPrefs.SetInt("Gems", Gems);
            PlayerPrefs.SetInt("Music", 1);
            PlayerPrefs.SetInt("Sound", 1);

            PlayerPrefs.SetInt("Lauched", 1);
            PlayerPrefs.Save();
        }
        rate = Instantiate(Resources.Load("Prefabs/Rate")) as GameObject;
        rate.SetActive(false);
        rate.transform.SetParent(GameObject.Find("CanvasGlobal").transform);
        rate.transform.localPosition = Vector3.zero;
        rate.GetComponent <RectTransform>().anchoredPosition = (Resources.Load("Prefabs/Rate") as GameObject).GetComponent <RectTransform>().anchoredPosition;
        rate.transform.localScale = Vector3.one;

        if (gameObject.GetComponent <AspectCamera>() == null)
        {
            gameObject.AddComponent <AspectCamera>().map = FindObjectOfType <LevelsMap>().transform.Find("map_background_01").GetComponent <SpriteRenderer>().sprite;                                               //gameObject.AddComponent<AspectCamera>().topPanel = GetComponent<LevelManager>().Level.transform.Find("Canvas/Panel/Panel/Panel").GetComponent<RectTransform>();//2.2.2
        }
        GameObject.Find("Music").GetComponent <AudioSource>().volume = PlayerPrefs.GetInt("Music");
        SoundBase.Instance.GetComponent <AudioSource>().volume       = PlayerPrefs.GetInt("Sound");

#if UNITY_ADS//2.1.1
        enableUnityAds = true;
#else
        enableUnityAds = false;
#endif
#if CHARTBOOST_ADS//1.6.1
        enableChartboostAds = true;
#else
        enableChartboostAds = false;
#endif

#if FACEBOOK
        FacebookManager fbManager = gameObject.AddComponent <FacebookManager>();
        fbManager.facebookButton = facebookButton;
#endif


#if GOOGLE_MOBILE_ADS
        enableGoogleMobileAds = true;          //1.6.1
#if UNITY_ANDROID
        MobileAds.Initialize(admobUIDAndroid); //2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#elif UNITY_IOS
        MobileAds.Initialize(admobUIDIOS);//2.1.6
        interstitial = new InterstitialAd(admobUIDIOS);
#else
        MobileAds.Initialize(admobUIDAndroid);//2.1.6
        interstitial = new InterstitialAd(admobUIDAndroid);
#endif

        // Create an empty ad request.
        requestAdmob = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(requestAdmob);
        interstitial.OnAdLoaded       += HandleInterstitialLoaded;
        interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
#else
        enableGoogleMobileAds = false;//1.6.1
#endif
        Transform canvas = GameObject.Find("CanvasGlobal").transform;
        foreach (Transform item in canvas)
        {
            item.gameObject.SetActive(false);
        }
    }