Exemplo n.º 1
0
    public void OnClickForAddGoldPrice()
    {
        UserDataBean    userData        = uiComponent.handler_GameData.GetUserData();
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();

        int maxLevel = uiComponent.handler_GameData.GetLevelMaxForGoldPrice();

        gameDataHandler.GetLevelUpDataForGoldPrice(gameData.levelForGoldPrice, out int addPrice, out long prePriceGold);
        if (!gameData.HasEnoughGold(prePriceGold))
        {
            //钱不够
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1001));
            return;
        }

        bool isLevelUp = gameData.LevelUpForGoldPrice(maxLevel, addPrice);

        if (!isLevelUp)
        {
            //升级失败
            uiComponent.manager_Msg.ShowMsg(GameCommonInfo.GetUITextById(1002));
            return;
        }

        //支付金币
        gameData.PayGold(prePriceGold);

        RefreshUI();
    }
Exemplo n.º 2
0
    public void RefreshUI()
    {
        GameBean        gameData        = uiComponent.handler_Game.GetGameData();
        GameDataHandler gameDataHandler = uiComponent.handler_GameData;

        gameDataHandler.GetLevelLevelUpDataForSpeed(gameData.levelForSpeed, out float addSpeed, out long preSpeedGold);
        SetTextForAttribute(ui_TvSpeedLevel, ui_TvSpeedMoney, gameData.levelForSpeed, gameDataHandler.GetLevelMaxForSpeed(), preSpeedGold);
        SetButtonStatusForAttribute(ui_BtSpeedAdd, preSpeedGold);

        gameDataHandler.GetLevelLevelUpDataForNumber(gameData.levelForPirateNumber, out int addNumber, out long preNumberGold);
        SetTextForAttribute(ui_TvNumberLevel, ui_TvNumberMoney, gameData.levelForPirateNumber, gameDataHandler.GetLevelMaxForNumber(), preNumberGold);
        SetButtonStatusForAttribute(ui_BtNumberAdd, preNumberGold);

        gameDataHandler.GetLevelUpDataForGoldPrice(gameData.levelForGoldPrice, out int addPrice, out long prePriceGold);
        SetTextForAttribute(ui_TvGoldPriceLevel, ui_TvGoldPriceMoney, gameData.levelForGoldPrice, gameDataHandler.GetLevelMaxForGoldPrice(), prePriceGold);
        SetButtonStatusForAttribute(ui_BtGoldPriceAdd, prePriceGold);
    }