Beispiel #1
0
    public void LoadUpgrade()
    {
        id = PlayerPrefs.GetInt("SelectedCar");

        Engine     = PlayerPrefs.GetInt("Coins" + id.ToString());
        Fuel       = PlayerPrefs.GetInt("Fuel" + id.ToString());
        Suspension = PlayerPrefs.GetInt("Suspension" + id.ToString());
        Speed      = PlayerPrefs.GetInt("Speed" + id.ToString());


        if (PlayerPrefs.GetString("language") == "English")
        {
            _item[0].levelInfo.text = "Level: " + PlayerPrefs.GetInt("Engine" + id.ToString()).ToString() + " / " + _item[0].price.Length.ToString();
            _item[1].levelInfo.text = "Level: " + PlayerPrefs.GetInt("Suspension" + id.ToString()).ToString() + " / " + _item[1].price.Length.ToString();
            _item[2].levelInfo.text = "Level: " + PlayerPrefs.GetInt("Speed" + id.ToString()).ToString() + " / " + _item[2].price.Length.ToString();
            _item[3].levelInfo.text = "Level: " + PlayerPrefs.GetInt("Fuel" + id.ToString()).ToString() + " / " + _item[3].price.Length.ToString();
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            _item[0].levelInfo.text = Fa.ToPersianNumber(PlayerPrefs.GetInt("Engine" + id.ToString()).ToString()) + " / " + Fa.ToPersianNumber(_item[0].price.Length.ToString()) + Fa.faConvert("سطح : ");
            _item[1].levelInfo.text = Fa.ToPersianNumber(PlayerPrefs.GetInt("Suspension" + id.ToString()).ToString()) + " / " + Fa.ToPersianNumber(_item[1].price.Length.ToString()) + Fa.faConvert("سطح : ");
            _item[2].levelInfo.text = Fa.ToPersianNumber(PlayerPrefs.GetInt("Speed" + id.ToString()).ToString()) + " / " + Fa.ToPersianNumber(_item[2].price.Length.ToString()) + Fa.faConvert("سطح : ");
            _item[3].levelInfo.text = Fa.ToPersianNumber(PlayerPrefs.GetInt("Fuel" + id.ToString()).ToString()) + " / " + Fa.ToPersianNumber(_item[3].price.Length.ToString()) + Fa.faConvert("سطح : ");
        }
    }
Beispiel #2
0
    public void EngineUpgrade()
    {
        if (PlayerPrefs.GetInt("Engine" + id.ToString()) >= _item[0].price.Length)
        {
            return;
        }

        SetChooseItem(0);

        if (PlayerPrefs.GetInt("Engine" + id.ToString()) < _item[0].price.Length)
        {
            if (PlayerPrefs.GetInt("Coins") >= _item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())])
            {
                HomeManager._homeManager.ChangeCoin(_item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())]);
                PlayerPrefs.SetInt("Engine" + id.ToString(), PlayerPrefs.GetInt("Engine" + id.ToString()) + 1);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    _item[0].levelInfo.text = "Level: " + PlayerPrefs.GetInt("Engine" + id.ToString()).ToString() + " / " + _item[0].price.Length.ToString();
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    _item[0].levelInfo.text = Fa.ToPersianNumber(PlayerPrefs.GetInt("Engine" + id.ToString()).ToString()) + " / " + Fa.ToPersianNumber(_item[0].price.Length.ToString()) + Fa.faConvert("سطح : ");
                }

                if (PlayerPrefs.GetInt("Engine" + id.ToString()) < _item[0].price.Length)
                {
                    if (PlayerPrefs.GetString("language") == "English")
                    {
                        priceText.text = "Upgrade cost : " + _item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())].ToString() + " coins";
                    }
                    else if (PlayerPrefs.GetString("language") == "Persion")
                    {
                        priceText.text = Fa.faConvert(" سکه ") + Fa.ToPersianNumber(_item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())].ToString()) + Fa.faConvert("هزينه بهبود کردن : ");
                    }
                }
                else
                {
                    if (PlayerPrefs.GetString("language") == "English")
                    {
                        priceText.text = "Completed";
                    }
                    else if (PlayerPrefs.GetString("language") == "Persion")
                    {
                        priceText.text = Fa.faConvert("تکمیل شد");
                    }
                }
                return;
            }
            else
            {
                HomeManager._homeManager.OpenPurchase();
            }
        }
    }
Beispiel #3
0
    public void UpdateCoin()
    {
        int _coin = PlayerPrefs.GetInt("Coins");

        if (PlayerPrefs.GetString("language") == "English")
        {
            coinText.text = _coin.ToString();
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            coinText.text = Fa.ToPersianNumber(_coin.ToString());
        }
    }
Beispiel #4
0
    public void ChangeCoin(int _value)
    {
        int _coin = PlayerPrefs.GetInt("Coins");

        _coin -= _value;
        PlayerPrefs.SetInt("Coins", _coin);
        if (PlayerPrefs.GetString("language") == "English")
        {
            coinText.text = _coin.ToString();
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            coinText.text = Fa.ToPersianNumber(_coin.ToString());
        }
    }
Beispiel #5
0
    public void AddCoin(int coinsCount)
    {
        int _coins = PlayerPrefs.GetInt("Coins");

        _coins += coinsCount;
        PlayerPrefs.SetInt("Coins", _coins);

        if (PlayerPrefs.GetString("language") == "English")
        {
            coinText.text = _coins.ToString();
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            coinText.text = Fa.ToPersianNumber(_coins.ToString());
        }
    }
Beispiel #6
0
 void Update()
 {
     if (Started)
     {
         CoinDistance();
         if (player.position.x >= DistanceTemp)
         {
             if (PlayerPrefs.GetString("language") == "English")
             {
                 DistanceTXT.text = Mathf.Floor(player.position.x).ToString();
             }
             else if (PlayerPrefs.GetString("language") == "Persion")
             {
                 DistanceTXT.text = Fa.ToPersianNumber(Mathf.Floor(player.position.x).ToString());
             }
             DistanceTemp        = player.position.x;
             DitanceSlider.value = player.position.x;
         }
     }
 }
Beispiel #7
0
    //-----------------------------------------------

    //Add Coin-----------------------------------------------
    public void AddCoin(int value)
    {    //add Coin called from coins trigger
        StartCoroutine(TakeCoins());

        CoinTXT.transform.localScale = new Vector3(CoinTXT.transform.localScale.x, CoinTXT.transform.localScale.y + 0.7f,
                                                   CoinTXT.transform.localScale.z);

        if (coinSound)
        {
            coinSound.Play();
        }
        Coins += value;
        if (PlayerPrefs.GetString("language") == "English")
        {
            CoinTXT.text = Coins.ToString();
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            CoinTXT.text = Fa.ToPersianNumber(Coins.ToString());
        }
        PlayerPrefs.SetInt("Coins", Coins);
    }
Beispiel #8
0
    public void SetChooseItem(int _index)
    {
        contentText.text = _item[_index]._content;
        _type            = _index;
        if (_index == 0)
        {
            if (PlayerPrefs.GetInt("Engine" + id.ToString()) == _item[0].price.Length)
            {
                return;
            }
            MainIcon.sprite         = icon1.sprite;
            _item[0]._border.sprite = _select;
            _item[1]._border.sprite = _unSelect;
            _item[2]._border.sprite = _unSelect;
            _item[3]._border.sprite = _unSelect;


            if (PlayerPrefs.GetString("language") == "English")
            {
                priceText.text = "Upgrade cost : " + _item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())].ToString() + " coins";
                headText.text  = "Upgrade Engine";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                priceText.text = Fa.faConvert(" سکه ") + Fa.ToPersianNumber(_item[0].price[PlayerPrefs.GetInt("Engine" + id.ToString())].ToString()) + Fa.faConvert("هزينه بهبود کردن : ");
                headText.text  = Fa.faConvert("بهبود کردن موتور");
            }
        }
        else if (_index == 1)
        {
            MainIcon.sprite         = icon2.sprite;
            _item[0]._border.sprite = _unSelect;
            _item[1]._border.sprite = _select;
            _item[2]._border.sprite = _unSelect;
            _item[3]._border.sprite = _unSelect;
            if (PlayerPrefs.GetString("language") == "English")
            {
                priceText.text = "Upgrade cost : " + _item[1].price[PlayerPrefs.GetInt("Suspension" + id.ToString())].ToString() + " coins";
                headText.text  = "Upgrade Suspension";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                priceText.text = Fa.faConvert(" سکه ") + Fa.ToPersianNumber(_item[1].price[PlayerPrefs.GetInt("Suspension" + id.ToString())].ToString()) + Fa.faConvert("هزينه بهبود کردن : ");
                headText.text  = Fa.faConvert("بهبود کردن چرخ آويزى");
            }
        }
        else if (_index == 2)
        {
            MainIcon.sprite         = icon3.sprite;
            _item[0]._border.sprite = _unSelect;
            _item[1]._border.sprite = _unSelect;
            _item[2]._border.sprite = _select;
            _item[3]._border.sprite = _unSelect;
            if (PlayerPrefs.GetString("language") == "English")
            {
                priceText.text = "Upgrade cost : " + _item[2].price[PlayerPrefs.GetInt("Speed" + id.ToString())].ToString() + " coins";
                headText.text  = "Upgrade Tired";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                priceText.text = Fa.faConvert(" سکه ") + Fa.ToPersianNumber(_item[2].price[PlayerPrefs.GetInt("Speed" + id.ToString())].ToString()) + Fa.faConvert("هزينه بهبود کردن : ");
                headText.text  = Fa.faConvert("بهبود کردن تایر");
            }
        }
        else if (_index == 3)
        {
            MainIcon.sprite         = icon4.sprite;
            _item[0]._border.sprite = _unSelect;
            _item[1]._border.sprite = _unSelect;
            _item[2]._border.sprite = _unSelect;
            _item[3]._border.sprite = _select;
            if (PlayerPrefs.GetString("language") == "English")
            {
                priceText.text = "Upgrade cost : " + _item[3].price[PlayerPrefs.GetInt("Fuel" + id.ToString())].ToString() + " coins";
                headText.text  = "Upgrade Fuel";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                priceText.text = Fa.faConvert(" سکه ") + Fa.ToPersianNumber(_item[3].price[PlayerPrefs.GetInt("Fuel" + id.ToString())].ToString()) + Fa.faConvert("هزينه بهبود کردن : ");
                headText.text  = Fa.faConvert("بهبود کردن سوخت");
            }
        }
    }
Beispiel #9
0
    //Start-----------------------------------------------
    IEnumerator Start()
    {
        Time.timeScale = 1f;
        Application.targetFrameRate = 60;
        if (PlayerPrefs.GetString("language") == "English")
        {
            DistanceTXT.text = "0";
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            DistanceTXT.text = Fa.ToPersianNumber("0");
        }
        DitanceSlider.gameObject.SetActive(true);
        DitanceSlider.maxValue = targetDistance;
        if (PlayerPrefs.GetString("language") == "English")
        {
            //Coins Initialization-----------------------------------------------
            Coins        = PlayerPrefs.GetInt("Coins"); //read total scrore from saved Coins
            CoinTXT.text = Coins.ToString();            // Display total coins on Start
                                                        //-----------------------------------------------
        }
        else if (PlayerPrefs.GetString("language") == "Persion")
        {
            //Coins Initialization-----------------------------------------------
            Coins        = PlayerPrefs.GetInt("Coins");          //read total scrore from saved Coins
            CoinTXT.text = Fa.ToPersianNumber(Coins.ToString()); // Display total coins on Start

            //-----------------------------------------------
        }

        //Start Main Game   -----------------------------------------------
        yield return(new WaitForEndOfFrame());   //Player is Spawned afer milisecond. we wait .3 and then find it

        player   = GameObject.FindGameObjectWithTag("Player").transform;
        Started  = true;          // The game is now started. you can run your codes on update function
        Finished = false;
        //-----------------------------------------------
        ////-----------------------------------------------
        ///
        // Read if distance based award is already gived for current level, Set it to gived
        if (PlayerPrefs.GetInt("c500" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c500 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:500";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("500") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c1000" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c1000 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:1000";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("1000") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c1500" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c1500 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:1500";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("1500") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c2000" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c2000 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:2000";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("2000") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c2500" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c2500 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:2500";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("2500") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c3000" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c3000 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:3000";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("3000") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c3500" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c3500 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:3500";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("3500") + Fa.faConvert("رکورد :");
            }
        }
        if (PlayerPrefs.GetInt("c4000" + PlayerPrefs.GetInt("SelectedLevel").ToString()) == 3)
        {
            c4000 = true;
            if (PlayerPrefs.GetString("language") == "English")
            {
                LastRecord.text = "Record:4000";
            }
            else if (PlayerPrefs.GetString("language") == "Persion")
            {
                LastRecord.text = Fa.ToPersianNumber("4000") + Fa.faConvert("رکورد :");
            }
        }



        //Fuel Decreso  r//-----------------------------------------------
        while (!Finished)          //responsible to decrese fuel amount by   time and value read from upgrade   menu
        {
            yield return(new WaitForSeconds(FuelTime));

            TotalFuel       -= FuelVal;
            FuelSlider.value = TotalFuel;
            if (TotalFuel >= 0)
            {
                if (PlayerPrefs.GetString("language") == "English")
                {
                    FuelTXT.text = Mathf.Floor(TotalFuel).ToString();
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    FuelTXT.text = Fa.ToPersianNumber(Mathf.Floor(TotalFuel).ToString());
                }
            }
            if (TotalFuel < 0)
            {
                //youLostMenu.SetActive (true);
                //Time.timeScale = 0;
                fuelFinished = true;
                StartFuelFinish();
            }
        }
    }
Beispiel #10
0
    // Distance based award
    void CoinDistance()
    {
        if (!c500)
        {
            if (player.transform.position.x >= 500 && player.transform.position.x < 1000)
            {
                AddCoin(50);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "50 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert(" سکه جایزه داده شد  ") + Fa.ToPersianNumber("50");
                }
                StartCoroutine(Awardfalse());
                c500 = true;
                PlayerPrefs.SetInt("c500" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:500";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("500") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c1000 && c500)
        {
            if (player.transform.position.x >= 1000 && player.transform.position.x < 1500)
            {
                AddCoin(100);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "100 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert(" سکه جایزه داده شد") + Fa.ToPersianNumber("100");
                }
                StartCoroutine(Awardfalse());
                c1000 = true;
                PlayerPrefs.SetInt("c1000" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:1000";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("1000") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c1500 && c1000)
        {
            if (player.transform.position.x >= 1500 && player.transform.position.x < 2000)
            {
                AddCoin(150);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "150 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert(" سکه جایزه داده شد  ") + Fa.ToPersianNumber("150");
                }
                StartCoroutine(Awardfalse());
                c1500 = true;
                PlayerPrefs.SetInt("c1500" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:1500";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("1500") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c2000 && c1500)
        {
            if (player.transform.position.x >= 2000 && player.transform.position.x < 2500)
            {
                AddCoin(200);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "200 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert("سکه جایزه داده شد  ") + Fa.ToPersianNumber("200");
                }
                StartCoroutine(Awardfalse());
                c2000 = true;
                PlayerPrefs.SetInt("c2000" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:2000";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("2000") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c2500 && c2000)
        {
            if (player.transform.position.x >= 2500 && player.transform.position.x < 3000)
            {
                AddCoin(250);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "250 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert("سکه جایزه داده شد  ") + Fa.ToPersianNumber("250");
                }
                StartCoroutine(Awardfalse());
                c2500 = true;
                PlayerPrefs.SetInt("c2500" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:2500";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("2500") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c3000 && c2500)
        {
            if (player.transform.position.x >= 3000 && player.transform.position.x < 3500)
            {
                AddCoin(300);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "300 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert("سکه جایزه داده شد  ") + Fa.ToPersianNumber("300");
                }
                StartCoroutine(Awardfalse());
                c3000 = true;
                PlayerPrefs.SetInt("c3000" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:3000";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("3000") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c3500 && c3000)
        {
            if (player.transform.position.x >= 3500 && player.transform.position.x < 4000)
            {
                AddCoin(350);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "350 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert("سکه جایزه داده شد  ") + Fa.ToPersianNumber("350");
                }
                StartCoroutine(Awardfalse());
                c3500 = true;
                PlayerPrefs.SetInt("c3500" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:3500";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("3500") + Fa.faConvert("رکورد :");
                }
            }
        }
        if (!c4000 && c3500)
        {
            if (player.transform.position.x >= 4000 && player.transform.position.x < 4500)
            {
                AddCoin(400);
                coinAwardedBox.SetActive(true);
                awardAnimator.SetBool("Award", true);
                if (PlayerPrefs.GetString("language") == "English")
                {
                    awardedText.text = "400 Coins Awarded";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    awardedText.text = Fa.faConvert("سکه جایزه داده شد  ") + Fa.ToPersianNumber("400");
                }
                StartCoroutine(Awardfalse());
                c4000 = true;
                PlayerPrefs.SetInt("c4000" + PlayerPrefs.GetInt("SelectedLevel").ToString(), 3);                   // 3 => true | 0 => false
                if (PlayerPrefs.GetString("language") == "English")
                {
                    LastRecord.text = "Record:4000";
                }
                else if (PlayerPrefs.GetString("language") == "Persion")
                {
                    LastRecord.text = Fa.ToPersianNumber("4000") + Fa.faConvert("رکورد :");
                }               //youWinMenu.SetActive (true);
                                //AddCoin (winnerAwardedCoins);
                                //GameObject.FindGameObjectWithTag ("Player").GetComponent<Rigidbody2D> ().isKinematic = true;
            }
        }
        //Debug.Log ("Distance " + player.transform.position.x);
        if (player.transform.position.x >= targetDistance && !Finished)
        {
            Finished = true;
            //AdsControl.Instance.showAds ();

            // deprecated one:
            //PlayerPrefs.SetInt ("BestDistance" + (Application.loadedLevel - 1).ToString (), Mathf.CeilToInt (player.position.x));

            //new one:
            PlayerPrefs.SetInt("BestDistance" + (SceneManager.GetActiveScene().buildIndex - 1).ToString(), Mathf.CeilToInt(player.position.x));

            youWinMenu.SetActive(true);
            Time.timeScale = 0;

            AddCoin(winnerAwardedCoins);
            GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody2D> ().isKinematic = true;
        }
    }