예제 #1
0
    //Activates automatic purchase of resource
    public void BuyAuto()
    {
        if (unlocked && !managed)
        {
            if (gc.DecreaseCure(managerCost))
            {
                managed = true;

                mM.RemoveManager(name);
                managerAlert.SetActive(true);

                Invoke("CloseAlert", 3);
                GameController.instance.OpenMenu();
                GameController.instance.OpenMenu();

                //     PlayerPrefs.SetInt("Managed" + name, 1);
            }
        }
    }
예제 #2
0
    public void DataRecovery()
    {
        int tmpLv = level;

        level = 1;
        InstantUpgrade(tmpLv);

        if (unlocked)
        {
            UnLock();
        }

        upgradeText.text = GameController.ConvertScore(upgradeCost) + "\nFon";

        mM = FindObjectOfType <ManagerMenu>();

        if (managed)
        {
            int   multiples  = 0;
            float difference = 0;
            mM.RemoveManager(name);
            System.DateTime now = System.DateTime.Now;
            if (PlayerPrefs.HasKey("LastSecond"))
            {
                int tmpTime  = 0;
                int tmpValue = PlayerPrefs.GetInt("LastYear");

                if (now.Year != tmpValue)
                {
                    tmpTime += 60 * 60 * 24 * 365 * (now.Year - tmpValue);
                }

                tmpValue = PlayerPrefs.GetInt("LastDay");
                if (now.DayOfYear != tmpValue)
                {
                    tmpTime += 60 * 60 * 24 * (now.DayOfYear - tmpValue);
                }

                tmpValue = PlayerPrefs.GetInt("LastHour");

                if (now.Hour != tmpValue)
                {
                    tmpTime += 60 * 60 * (now.Hour - tmpValue);
                }

                tmpValue = PlayerPrefs.GetInt("LastMinute");

                if (now.Minute != tmpValue)
                {
                    tmpTime += 60 * (now.Minute - tmpValue);
                }

                tmpValue = PlayerPrefs.GetInt("LastSecond");

                tmpTime += (now.Second - tmpValue);



                multiples = (int)(tmpTime / cureTime);
                InstantIncrease(multiples);

                difference = (tmpTime) - (multiples * cureTime);
                StartCoroutine(Increase(difference));
                timeLeft = difference;
            }
            else
            {
                timeLeft = 0;
            }
        }
        else
        {
            timeLeft = 0;
        }

        //if (PlayerPrefs.HasKey("Purchased_Upgrades"))
        //{
        //    for(int i=0; i<PlayerPrefs.GetInt("Purchased_Upgrades"); i++)
        //    {
        //        InstantPurchaseUpgrade();
        //    }
        //}

        int upgradesCounter = purchased_upgrades;

        purchased_upgrades = 0;
        for (int i = 0; i < upgradesCounter; i++)
        {
            InstantPurchaseUpgrade();
        }

        gainText.text = "Guadagno: " + GameController.ConvertScore(CalculateCure());


        if (!unlocked)
        {
            img.color      = new Color(0.1f, 0.1f, 0.1f);
            gainText.color = new Color(1, 1, 1, 0);
            timeText.color = new Color(1, 1, 1, 0);
        }
        else
        {
            img.color      = new Color(1f, 1f, 1f);
            gainText.color = new Color(1, 1, 1, 1);
            timeText.color = new Color(1, 1, 1, 1);
        }

        InvokeRepeating("RecalculateTime", 0, 1);
        recovered = true;
        if (timeLeft == 0)
        {
            timeLeft = cureTime;
        }
        //  upgrade_button.SetName(base.name + " Research x 3");
        // upgrade_button.SetCost(purchased_upgrade_cost);
    }