Example #1
0
    public void Upgrade()
    {
        if (upgradeCost > m_playerLoot.GetSpendableLootCount())
        {
            MessagePanelController.s_instance.SetText(s_kNoMoneyErrorMessage[(int)GameManager.s_instance.gameLanguage]);
            return;
        }

        m_playerUpgradeScript.UpgradeShip();
        m_playerLoot.SpendLoot(upgradeCost);
    }
    public void Repair()
    {
        if (repairCost > m_playerLoot.GetSpendableLootCount())
        {
            MessagePanelController.s_instance.SetText(s_kNoMoneyErrorMessage[(int)GameManager.s_instance.gameLanguage]);
            return;
        }

        if (m_playerShipHealth.healthPercentage >= 1f)
        {
            MessagePanelController.s_instance.SetText(s_kNoDamageErrorMessage[(int)GameManager.s_instance.gameLanguage]);
            return;
        }

        m_playerShipHealth.RecoverToFullHealth();
        m_playerLoot.SpendLoot(repairCost);
    }
    public void Buy()
    {
        int index       = (int)GameManager.s_instance.gameLanguage;
        int numLanguage = (int)Language.kTotalNumLanguage;

        int enterAmount = int.Parse(m_inputField.text);

        if (tradeCost > m_playerLoot.GetSpendableLootCount())
        {
            MessagePanelController.s_instance.SetText(s_kBuyErrorMessage[0 * numLanguage + index]);
            return;
        }

        if (enterAmount + m_playerCannon.cannonballCount > m_playerCannon.GetMaxCannonCount())
        {
            MessagePanelController.s_instance.SetText(s_kBuyErrorMessage[1 * numLanguage + index]);
            return;
        }

        m_playerLoot.SpendLoot(tradeCost);
        m_playerCannon.AddCannon(enterAmount);
    }