/// <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("升级失败,没有足够的金钱"); } }
/// <summary> /// 升级部件 /// </summary> /// <param name="partId"></param> /// <param name="addLevel"></param> public void LevelUpPart(long partId, int addLevel) { if (listUnlockPart == null) { return; } for (int i = 0; i < listUnlockPart.Count; i++) { UserModelPartDataBean itemPartData = listUnlockPart[i]; if (partId == itemPartData.partId) { itemPartData.LevelUp(addLevel); return; } } }