Example #1
0
    public void BuyBonus()
    {
        ShopController  shopController  = FindObjectOfType <ShopController>();
        SceneController sceneController = FindObjectOfType <SceneController>();
        BonusController bonusController = FindObjectOfType <BonusController>();

        m_profile = FindObjectOfType <Profile>();

        if (sceneController.Score >= bonusController.GetPrice(m_type))
        {
            int currScore = sceneController.Score;
            int count     = m_profile.GetBoughtBonus(Type);
            count     += m_bonusCountMultiplier;
            currScore -= (m_price * m_bonusCountMultiplier);
            m_profile.SetScore(currScore);
            m_profile.SetBoughtBonus(Type, count);
            m_profile.Save();
            sceneController.Score = currScore;
            shopController.BuyBonus(m_type);
        }
        else
        {
            Debug.Log("You don't have enough Points!");
        }
    }