예제 #1
0
    /// <summary>
    /// 点击-升级
    /// </summary>
    public void OnClickForLevel()
    {
        UserDataBean          userData          = uiComponent.handler_GameData.GetUserData();
        UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(modelPartInfo.id);

        if (userModelPartData == null)
        {
            return;
        }
        long levelMoney = modelPartInfo.GetLevelUpMoney(userModelPartData.level);
        bool isPay      = userData.PayMoney(levelMoney);

        if (isPay)
        {
            //升级
            int level = userModelPartData.LevelUp(1);
            //计算收益
            long addPrice = modelPartInfo.GetAddPrice(level);
            //增加收益
            userModelPartData.SetAddPrice(addPrice);
            //设置舰船显示进度
            uiComponent.handler_GameModel.SetPartProgress(modelPartInfo.part_name, userModelPartData.GetProgress(modelPartInfo.max_level));
        }
        else
        {
            LogUtil.Log("升级失败,没有足够的金钱");
        }
    }