From c5609f4867ab0cf4e96d80ee40129a0dacd2c3ea Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Tue, 23 May 2023 19:08:26 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9A=84buff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 2 ++ .../battle/helper/battle_buff_handle.lua | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 9611ef7f..99108f09 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -287,6 +287,8 @@ local BUFF_NAME = { SKILL_HURT_ADD = "skill_hurt_add", DEATH_SUMMON = "death_summon", LOCK = "lock", + SHIELD_REBOUND_400 = "shield_rebound_400", + SHIELD_ICE_REBOUND_400 = "shield_ice_rebound_400", } BattleConst.BUFF_NAME = BUFF_NAME diff --git a/lua/app/module/battle/helper/battle_buff_handle.lua b/lua/app/module/battle/helper/battle_buff_handle.lua index f063ca9c..1803da19 100644 --- a/lua/app/module/battle/helper/battle_buff_handle.lua +++ b/lua/app/module/battle/helper/battle_buff_handle.lua @@ -140,6 +140,20 @@ BattleBuffHandle.addShield = { target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, 20000, false) return shieldNum end, + -- 反弹目标伤害的400%,直接写死 + [BUFF_NAME.SHIELD_REBOUND_400] = function(unitComp, buff, target, buffEffect) + local shieldNum = target.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR + target:addShield(shieldNum, buffEffect) + target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, 40000, false) + return shieldNum + end, + -- 反弹目标伤害的400%,直接写死 + [BUFF_NAME.SHIELD_ICE_REBOUND_400] = function(unitComp, buff, target, buffEffect) + local shieldNum = target.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR + target:addShield(shieldNum, buffEffect) + target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, 40000, false) + return shieldNum + end, } BattleBuffHandle.removeShield = { @@ -147,6 +161,14 @@ BattleBuffHandle.removeShield = { target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, -20000, false) target:removeShield(buffEffect) end, + [BUFF_NAME.SHIELD_REBOUND_400] = function(unitComp, buff, target, buffEffect) + target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, -40000, false) + target:removeShield(buffEffect) + end, + [BUFF_NAME.SHIELD_ICE_REBOUND_400] = function(unitComp, buff, target, buffEffect) + target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, -40000, false) + target:removeShield(buffEffect) + end, } local function _takeEffectShield(unitComp, buff, target, buffEffect) From 715408f15f508eb46fcdafe6ff9a365f845a91b1 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Tue, 23 May 2023 20:09:09 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=8F=8D=E5=87=BB=E8=A1=A8=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/team/battle_team.lua | 13 ++++++++++--- lua/app/ui/battle/battle_ui.lua | 10 +++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 653df0bb..8128adfe 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -554,10 +554,17 @@ function BattleTeam:onActionOver() self:getMainUnit().unitEntity:clearCounterAttackCount() local teamAction = function() - self.battleController.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ATK_STEP - self.battleController.curTeam = self.battleController.atkTeam ---- 普攻 - local skillMatch = self:getMainUnit().unitEntity:getMatchType() + local skillMatch + if self.side == BattleConst.SIDE_ATK then + self.battleController.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ATK_STEP + self.battleController.curTeam = self.battleController.atkTeam + skillMatch = self:getMainUnit().unitEntity:getMatchType() + else + self.battleController.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_DEF_STEP + self.battleController.curTeam = self.battleController.defTeam + end + self:useNormalSkill(skillMatch, counterAttackCount, true, BattleConst.EFFECT_TYPE.COUNTERATTACK, function() self.battleController:enterNextTeamAction() end) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index c908cd6a..428e6d0e 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -530,16 +530,24 @@ end function BattleUI:initCounterAttack() self.counterAttackNode = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack"] self.counterTx = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack.text_number"] + self.counterTxTmp = self.counterTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) + self.counterTxbgComp = self.uiMap["battle_ui.battle_root.top_node.counter_attack.bg"] self.counterAttackNode:setVisible(false) end function BattleUI:showCounterAttack(count, side) local x = 280 + local horizontal = 180 if side == GConst.BattleConst.SIDE_ATK then x = -280 + horizontal = 0 + self.counterTxTmp.alignment = CS.TMPro.TextAlignmentOptions.MidlineLeft + else + self.counterTxTmp.alignment = CS.TMPro.TextAlignmentOptions.MidlineRight end + self.counterTxbgComp:setEulerAngles(0, horizontal, 0) self.counterAttackNode:setAnchoredPositionX(x) - self.counterTx:setText(I18N:getGlobalText(I18N.GlobalConst.COUNTER_ATTACK_DESC) .. "+" .. count) + self.counterTx:setText(I18N:getGlobalText(I18N.GlobalConst.COUNTER_ATTACK_DESC) .. "x" .. count) self.counterAttackNode:setVisible(true) end From bff772a1de5e971b83714125d87d7bc8e172bb68 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 24 May 2023 10:01:36 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E8=81=94=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/bi_report.lua | 1 + lua/app/common/event_manager.lua | 3 +- lua/app/module/battle/battle_manager.lua | 18 ++++++++ .../battle/controller/battle_controller.lua | 8 +++- lua/app/proto/proto_msg_type.lua | 6 +++ .../ui/battle/battle_skill_select_comp.lua | 41 +++++++++++++++++-- lua/app/ui/battle/battle_ui.lua | 6 +++ lua/app/userdata/battle/battle_data.lua | 17 ++++++++ 8 files changed, 95 insertions(+), 5 deletions(-) diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index 77396059..f77dccef 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -78,6 +78,7 @@ BIReport.ITEM_GET_TYPE = { SUMMON = "Summon", PLAYER_LV_UP = "PlayerLvUp", GOLD_PIG = "GoldPig", + BATTLE_SKILL_REFRESH = "BattleSkillRefresh", } BIReport.ADS_CLICK_TYPE = { diff --git a/lua/app/common/event_manager.lua b/lua/app/common/event_manager.lua index 8af4354b..20e2c3ce 100644 --- a/lua/app/common/event_manager.lua +++ b/lua/app/common/event_manager.lua @@ -25,7 +25,8 @@ EventManager.CUSTOM_EVENT = { LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS", DAILY_TASK_ADD_PROGRESS = "DAILY_TASK_ADD_PROGRESS", BOSS_ENTER_ANI_OVER = "BOSS_ENTER_ANI_OVER", - TIME_TRIGGERED_NEW_EMAIL = "TIME_TRIGGERED_NEW_EMAIL" -- 邮件到时间请求是否有新邮件 + TIME_TRIGGERED_NEW_EMAIL = "TIME_TRIGGERED_NEW_EMAIL", -- 邮件到时间请求是否有新邮件 + SKILL_REFRESH_SUCC = "SKILL_REFRESH_SUCC", -- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN", -- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER" } diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index 099e0450..01420281 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -22,6 +22,24 @@ function BattleManager:showBoxOpenUI(rewards, callback) UIManager:showUI("app/ui/battle/battle_box_open_ui", {rewards = rewards, callback = callback}) end +function BattleManager:reqSkillRefresh(isAd) + if not isAd then + local cost = GFunc.getConstReward("refresh_skill_cost") + if not GFunc.checkCost(GFunc.getRewardId(cost), GFunc.getRewardNum(cost), true) then + return + end + end + + self:sendMessage(ProtoMsgType.FromMsgEnum.BattleSkillRefreshReq, {ad = isAd}, {}, self.rspSkillRefresh, BIReport.ITEM_GET_TYPE.BATTLE_SKILL_REFRESH, true) +end + +function BattleManager:rspSkillRefresh(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + DataManager.BattleData:addRefreshSkillCount(result.reqData.ad) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.SKILL_REFRESH_SUCC) + end +end + function BattleManager:playBattle(battleType, params, returnFunc) params = params or {} if self.battleController then -- 同一时间只能有一场战斗 diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index e976f226..ebd07266 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1624,7 +1624,7 @@ function BattleController:findSkillInfluenceGrids() end end -function BattleController:getRandomSkillList(getCount, onlyCommonSkill) +function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeMap) local fixedList = self:getFixedRogueSkill() if fixedList[1] then return table.remove(fixedList, 1) @@ -1668,6 +1668,12 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill) return table.shuffle(result) end + + if excludeMap then + for skillId, _ in pairs(excludeMap) do + map[skillId] = true + end + end for elementType, list in pairs(skillPool) do if self.battleData:isUnlockedSkillElementType(elementType) then diff --git a/lua/app/proto/proto_msg_type.lua b/lua/app/proto/proto_msg_type.lua index 22694295..8a75a20b 100644 --- a/lua/app/proto/proto_msg_type.lua +++ b/lua/app/proto/proto_msg_type.lua @@ -82,6 +82,8 @@ local ProtoMsgType = { [3440328467] = "PigLevelUpNtf", [3555824176] = "TaskDailyInfoReq", [3555826009] = "TaskDailyInfoRsp", + [3597633120] = "BattleSkillRefreshReq", + [3597634953] = "BattleSkillRefreshRsp", [3607879254] = "AuthReq", [3607881087] = "AuthRsp", [3624439233] = "NewMailNtf", @@ -186,6 +188,8 @@ local ProtoMsgType = { PigLevelUpNtf = 3440328467, TaskDailyInfoReq = 3555824176, TaskDailyInfoRsp = 3555826009, + BattleSkillRefreshReq = 3597633120, + BattleSkillRefreshRsp = 3597634953, AuthReq = 3607879254, AuthRsp = 3607881087, NewMailNtf = 3624439233, @@ -290,6 +294,8 @@ local ProtoMsgType = { PigLevelUpNtf = "PigLevelUpNtf", TaskDailyInfoReq = "TaskDailyInfoReq", TaskDailyInfoRsp = "TaskDailyInfoRsp", + BattleSkillRefreshReq = "BattleSkillRefreshReq", + BattleSkillRefreshRsp = "BattleSkillRefreshRsp", AuthReq = "AuthReq", AuthRsp = "AuthRsp", NewMailNtf = "NewMailNtf", diff --git a/lua/app/ui/battle/battle_skill_select_comp.lua b/lua/app/ui/battle/battle_skill_select_comp.lua index 98220432..153d6457 100644 --- a/lua/app/ui/battle/battle_skill_select_comp.lua +++ b/lua/app/ui/battle/battle_skill_select_comp.lua @@ -19,7 +19,6 @@ end function BattleSkillSelectComp:_display() local uiMap = self:getUIMap() - uiMap["battle_select_skill_comp.skill_node.ad_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_3)) local bg2 = uiMap["battle_select_skill_comp.bg_2"] bg2:setVisible(self.onlyCommonSkill) local bg = uiMap["battle_select_skill_comp.bg_1"] @@ -32,6 +31,7 @@ function BattleSkillSelectComp:_display() bg:setVisible(true) end + self:refreshBtns() self:refreshRogueSkill() end @@ -43,11 +43,18 @@ function BattleSkillSelectComp:_addListeners() end SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.BATTLE_SKILL_REFRESH, function() - self.skillList = ModuleManager.BattleManager.battleController:getRandomSkillList(nil, self.onlyCommonSkill) - self:refreshRogueSkill() + ModuleManager.BattleManager:reqSkillRefresh(true) end) end) + uiMap["battle_select_skill_comp.skill_node.diamond_btn"]:addClickListener(function() + if not ModuleManager.BattleManager.battleController then + return + end + + ModuleManager.BattleManager:reqSkillRefresh(false) + end) + self.canvasGroup = uiMap["battle_select_skill_comp.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP) self.canvasGroup.alpha = 1 self.bg = uiMap["battle_select_skill_comp.bg_1"] @@ -62,6 +69,34 @@ function BattleSkillSelectComp:_addListeners() end) end +function BattleSkillSelectComp:refreshBtns() + local uiMap = self:getUIMap() + uiMap["battle_select_skill_comp.skill_node.ad_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_3)) + uiMap["battle_select_skill_comp.skill_node.diamond_btn.tx"]:setText(GFunc.getRewardNum(GFunc.getConstReward("refresh_skill_cost"))) + + local cfgAdCount = GFunc.getConstIntValue("ad_refresh_skill") + local cfgRefreshCount = GFunc.getConstIntValue("diamond_refresh_skill") + cfgAdCount + local adCount = DataManager.BattleData:getADRefreshSkillCount() + local refreshCount = DataManager.BattleData:getRefreshSkillCount() + local showAdBtn = cfgAdCount > adCount + uiMap["battle_select_skill_comp.skill_node.ad_btn"]:setActive(showAdBtn) + local showBtn = refreshCount < cfgRefreshCount + if showAdBtn then + showBtn = false + end + uiMap["battle_select_skill_comp.skill_node.diamond_btn"]:setActive(showBtn) +end + +function BattleSkillSelectComp:getNewRandomSkill() + self:refreshBtns() + local excludeMap = {} + for _, id in ipairs(self.skillList) do + excludeMap[id] = true + end + self.skillList = ModuleManager.BattleManager.battleController:getRandomSkillList(nil, self.onlyCommonSkill, excludeMap) + self:refreshRogueSkill() +end + function BattleSkillSelectComp:refreshRogueSkill() local uiMap = self:getUIMap() if not self.selectSkillCells then diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 428e6d0e..ff40fb45 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -79,6 +79,12 @@ function BattleUI:_addListeners() self:addEventListener(EventManager.CUSTOM_EVENT.SHOW_ELIMINATION_TUTORAIL, function(posIdList) self:showTutorialFinger(posIdList) end) + + self:addEventListener(EventManager.CUSTOM_EVENT.SKILL_REFRESH_SUCC, function(posIdList) + if self.selectSkillComp then + self.selectSkillComp:getNewRandomSkill() + end + end) end function BattleUI:_bind() diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index bf3af345..400ebf0a 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -27,6 +27,8 @@ function BattleData:init() self.lockElementMap = {} self.data.timeSpeed = 1 self.data.lvDirty = false + self.adRefreshSkillCount = 0 + self.refreshSkillCount = 0 BattleSkillEntity.sid = 0 self.atkTeam = self:initTeam(BattleConst.SIDE_ATK) self.defTeam = self:initTeam(BattleConst.SIDE_DEF) @@ -532,6 +534,21 @@ function BattleData:useCommonSelectSkillCount() return true end +function BattleData:addRefreshSkillCount(isAd) + if isAd then + self.adRefreshSkillCount = self.adRefreshSkillCount + 1 + end + self.refreshSkillCount = self.refreshSkillCount + 1 +end + +function BattleData:getRefreshSkillCount() + return self.refreshSkillCount +end + +function BattleData:getADRefreshSkillCount() + return self.adRefreshSkillCount +end + function BattleData:initTeam(side) local data = nil if side == BattleConst.SIDE_ATK then From 4e5316033a0ca355bdcdfaef60bf1c0ec54ac95e Mon Sep 17 00:00:00 2001 From: CloudJ Date: Wed, 24 May 2023 10:07:07 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/shop/box_reward_ui.lua | 1 + lua/app/userdata/summon/summon_data.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/app/ui/shop/box_reward_ui.lua b/lua/app/ui/shop/box_reward_ui.lua index fa54609b..4ba7373c 100644 --- a/lua/app/ui/shop/box_reward_ui.lua +++ b/lua/app/ui/shop/box_reward_ui.lua @@ -35,6 +35,7 @@ function BoxRewardUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() self.titleTx = self.uiMap["box_reward_ui.title.text"] + self.titleTx:setText("恭喜获得TD") -- TODOJ self.scrollRectObj = self.uiMap["box_reward_ui.scroll_rect"] self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) diff --git a/lua/app/userdata/summon/summon_data.lua b/lua/app/userdata/summon/summon_data.lua index 3c6f7449..f8775b9e 100644 --- a/lua/app/userdata/summon/summon_data.lua +++ b/lua/app/userdata/summon/summon_data.lua @@ -71,10 +71,11 @@ function SummonData:getSummonRewardByLv(summonType, level) end function SummonData:getSummonTotalRewardByLv(summonType, level) + level = level or self:getSummonLevel() local rewards = {} - for i = 1, level do - local lvRewards = self:getSummonRewardByLv(summonType) + for lv = 1, level do + local lvRewards = self:getSummonRewardByLv(summonType, lv) for _, reward in ipairs(lvRewards) do table.insert(rewards, reward) end From 21f1a9cd8971094830948a25d1ca2353e6f28107 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Wed, 24 May 2023 10:44:11 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/data_manager.lua | 2 +- lua/app/config/strings/cn/item.lua | 4 + lua/app/module/shop/shop_manager.lua | 4 + lua/app/ui/shop/box_level_ui.lua | 28 +++- lua/app/ui/shop/box_level_up_ui.lua | 163 +++++++++++++++++++++++ lua/app/ui/shop/box_level_up_ui.lua.meta | 10 ++ lua/app/ui/shop/box_reward_ui.lua | 9 +- lua/app/ui/shop/cell/box_sell_cell.lua | 7 + lua/app/userdata/summon/summon_data.lua | 23 +++- 9 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 lua/app/ui/shop/box_level_up_ui.lua create mode 100644 lua/app/ui/shop/box_level_up_ui.lua.meta diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 1ce79946..86659c6f 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -132,7 +132,7 @@ function DataManager:initWithServerData(data) self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包 self.ShopData:initGrowUpGift(data.act_grow_up_gift) -- 成长礼包 self.ShopData:initLevelUpGift(data.act_level_up_gift) -- 助力礼包 - self.SummonData:init(data.summon) + self.SummonData:init(data.summon, true) self:scheduleGlobal() self:checkDataBind() diff --git a/lua/app/config/strings/cn/item.lua b/lua/app/config/strings/cn/item.lua index 52bfd102..add33c70 100644 --- a/lua/app/config/strings/cn/item.lua +++ b/lua/app/config/strings/cn/item.lua @@ -75,6 +75,10 @@ local item = { ["name"]="随机碎片", ["desc"]="挂机可获得随机碎片,领取后数量和品质将根据关卡提升。" }, + [12001]={ + ["name"]="红SR-克劳德", + ["desc"]="凑齐可解锁或升级。" + }, [13001]={ ["name"]="红SR-克劳德", ["desc"]="凑齐可解锁或升级。" diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index 404f3481..1e978d93 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -17,6 +17,10 @@ function ShopManager:showBoxRewardUI(params) UIManager:showUI("app/ui/shop/box_reward_ui", params) end +function ShopManager:showBoxLevelUpUI(params) + UIManager:showUI("app/ui/shop/box_level_up_ui", params) +end + -- 购买每日特惠商品 function ShopManager:buyMallDailyGift(id, isAd) if not DataManager.ShopData:getMallDailyIsOpen() then diff --git a/lua/app/ui/shop/box_level_ui.lua b/lua/app/ui/shop/box_level_ui.lua index 8a974162..5d202806 100644 --- a/lua/app/ui/shop/box_level_ui.lua +++ b/lua/app/ui/shop/box_level_ui.lua @@ -94,7 +94,6 @@ function BoxLevelUI:refresh() self.rightArrow:setSprite(GConst.ATLAS_PATH.COMMON, "common_arrow_2") end - -- 目前文档没有写要屏蔽3级宝箱 所以暂不处理 if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.STORE_BOX_3_OPEN, true) then self.box3Node:setVisible(false) self.bg:setSizeDeltaY(BG_WITHOUT_3_BOX_HEIGHT) @@ -137,16 +136,25 @@ function BoxLevelUI:refresh() self.box1Add1Node:setVisible(true) self.box1Add1ItemCell:refreshByCfg(reward1[1].id, 0) self.box1Add1ItemCell:setNum("") + self.box1Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[1].id, self.box1Add1ItemCell:getBaseObject()) + end) self.box1Add1Text:setText("+" .. tostring(reward1[1].num)) else self.box1Add1Node:setVisible(true) self.box1Add1ItemCell:refreshByCfg(reward1[1].id, 0) self.box1Add1ItemCell:setNum("") + self.box1Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[1].id, self.box1Add1ItemCell:getBaseObject()) + end) self.box1Add1Text:setText("+" .. tostring(reward1[1].num)) self.box1Add2Node:setVisible(true) self.box1Add2ItemCell:refreshByCfg(reward1[2].id, 0) self.box1Add2ItemCell:setNum("") + self.box1Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[2].id, self.box1Add2ItemCell:getBaseObject()) + end) self.box1Add2Text:setText("+" .. tostring(reward1[2].num)) end @@ -155,16 +163,25 @@ function BoxLevelUI:refresh() self.box2Add1Node:setVisible(true) self.box2Add1ItemCell:refreshByCfg(reward2[1].id, 0) self.box2Add1ItemCell:setNum("") + self.box2Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[1].id, self.box2Add1ItemCell:getBaseObject()) + end) self.box2Add1Text:setText("+" .. tostring(reward2[1].num)) else self.box2Add1Node:setVisible(true) self.box2Add1ItemCell:refreshByCfg(reward2[1].id, 0) self.box2Add1ItemCell:setNum("") + self.box2Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[1].id, self.box2Add1ItemCell:getBaseObject()) + end) self.box2Add1Text:setText("+" .. tostring(reward2[1].num)) self.box2Add2Node:setVisible(true) self.box2Add2ItemCell:refreshByCfg(reward2[2].id, 0) self.box2Add2ItemCell:setNum("") + self.box2Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[2].id, self.box2Add2ItemCell:getBaseObject()) + end) self.box2Add2Text:setText("+" .. tostring(reward2[2].num)) end @@ -173,16 +190,25 @@ function BoxLevelUI:refresh() self.box3Add1Node:setVisible(true) self.box3Add1ItemCell:refreshByCfg(reward3[1].id, 0) self.box3Add1ItemCell:setNum("") + self.box3Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[1].id, self.box3Add1ItemCell:getBaseObject()) + end) self.box3Add1Text:setText("+" .. tostring(reward3[1].num)) else self.box3Add1Node:setVisible(true) self.box3Add1ItemCell:refreshByCfg(reward3[1].id, 0) self.box3Add1ItemCell:setNum("") + self.box3Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[1].id, self.box3Add1ItemCell:getBaseObject()) + end) self.box3Add1Text:setText("+" .. tostring(reward3[1].num)) self.box3Add2Node:setVisible(true) self.box3Add2ItemCell:refreshByCfg(reward3[2].id, 0) self.box3Add2ItemCell:setNum("") + self.box3Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[2].id, self.box3Add2ItemCell:getBaseObject()) + end) self.box3Add2Text:setText("+" .. tostring(reward3[2].num)) end end diff --git a/lua/app/ui/shop/box_level_up_ui.lua b/lua/app/ui/shop/box_level_up_ui.lua new file mode 100644 index 00000000..033a0420 --- /dev/null +++ b/lua/app/ui/shop/box_level_up_ui.lua @@ -0,0 +1,163 @@ +local BoxLevelUpUI = class("BoxLevelUpUI", BaseUI) + +function BoxLevelUpUI:ctor(params) + params = params or {} + self.level = params.level or DataManager.SummonData:getSummonLevel() +end + +function BoxLevelUpUI:isFullScreen() + return true +end + +function BoxLevelUpUI:getPrefabPath() + return "assets/prefabs/ui/shop/box_level_up_ui.prefab" +end + +function BoxLevelUpUI:onLoadRootComplete() + self.uiMap = self.root:genAllChildren() + self.uiMap["box_level_up_ui.mask"]:addClickListener(function() + self:closeUI() + end) + + self.titleTx = self.uiMap["box_level_up_ui.title.text"] + self.lvTx = self.uiMap["box_level_up_ui.lv_up.text"] + + self.box1Node = self.uiMap["box_level_up_ui.box_1"] + self.box1Add1Node = self.uiMap["box_level_up_ui.box_1.add_node_1"] + self.box1Add1ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_1.add_node_1.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box1Add1Text = self.uiMap["box_level_up_ui.box_1.add_node_1.text"] + self.box1Add2Node = self.uiMap["box_level_up_ui.box_1.add_node_2"] + self.box1Add2ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_1.add_node_2.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box1Add2Text = self.uiMap["box_level_up_ui.box_1.add_node_2.text"] + self.box1Desc = self.uiMap["box_level_up_ui.box_1.none_text"] + self.box1Desc:setText("无额外奖励加成TD") -- TODOJ + + self.box2Node = self.uiMap["box_level_up_ui.box_2"] + self.box2Add1Node = self.uiMap["box_level_up_ui.box_2.add_node_1"] + self.box2Add1ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_2.add_node_1.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box2Add1Text = self.uiMap["box_level_up_ui.box_2.add_node_1.text"] + self.box2Add2Node = self.uiMap["box_level_up_ui.box_2.add_node_2"] + self.box2Add2ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_2.add_node_2.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box2Add2Text = self.uiMap["box_level_up_ui.box_2.add_node_2.text"] + self.box2Desc = self.uiMap["box_level_up_ui.box_2.none_text"] + self.box2Desc:setText("无额外奖励加成TD") -- TODOJ + + self.box3Node = self.uiMap["box_level_up_ui.box_3"] + self.box3Add1Node = self.uiMap["box_level_up_ui.box_3.add_node_1"] + self.box3Add1ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_3.add_node_1.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box3Add1Text = self.uiMap["box_level_up_ui.box_3.add_node_1.text"] + self.box3Add2Node = self.uiMap["box_level_up_ui.box_3.add_node_2"] + self.box3Add2ItemCell = CellManager:addCellComp(self.uiMap["box_level_up_ui.box_3.add_node_2.item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL) + self.box3Add2Text = self.uiMap["box_level_up_ui.box_3.add_node_2.text"] + self.box3Desc = self.uiMap["box_level_up_ui.box_3.none_text"] + self.box3Desc:setText("无额外奖励加成TD") -- TODOJ + + self.closeTx = self.uiMap["box_level_up_ui.close_tx"] + + self:refresh() +end + +function BoxLevelUpUI:refresh() + self.titleTx:setText("宝箱等级提升!TD") -- TODOJ + self.lvTx:setText("Lv." .. tostring(self.level)) + self.closeTx:setText("点击继续TD") -- TODOJ + + self.box1Add1Node:setVisible(false) + self.box1Add2Node:setVisible(false) + self.box1Desc:setVisible(false) + + self.box2Add1Node:setVisible(false) + self.box2Add2Node:setVisible(false) + self.box2Desc:setVisible(false) + + self.box3Add1Node:setVisible(false) + self.box3Add2Node:setVisible(false) + self.box3Desc:setVisible(false) + + local reward1 = DataManager.SummonData:getSummonRewardByLv(GConst.SummonConst.SUMMON_TYPE.LV_1, self.level) + local reward2 = DataManager.SummonData:getSummonRewardByLv(GConst.SummonConst.SUMMON_TYPE.LV_2, self.level) + local reward3 = DataManager.SummonData:getSummonRewardByLv(GConst.SummonConst.SUMMON_TYPE.LV_3, self.level) + + local count = #reward1 + if count == 1 then + self.box1Add1Node:setVisible(true) + self.box1Add1ItemCell:refreshByCfg(reward1[1].id, 0) + self.box1Add1ItemCell:setNum("") + self.box1Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[1].id, self.box1Add1ItemCell:getBaseObject()) + end) + self.box1Add1Text:setText("+" .. tostring(reward1[1].num)) + else + self.box1Add1Node:setVisible(true) + self.box1Add1ItemCell:refreshByCfg(reward1[1].id, 0) + self.box1Add1ItemCell:setNum("") + self.box1Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[1].id, self.box1Add1ItemCell:getBaseObject()) + end) + self.box1Add1Text:setText("+" .. tostring(reward1[1].num)) + + self.box1Add2Node:setVisible(true) + self.box1Add2ItemCell:refreshByCfg(reward1[2].id, 0) + self.box1Add2ItemCell:setNum("") + self.box1Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward1[2].id, self.box1Add2ItemCell:getBaseObject()) + end) + self.box1Add2Text:setText("+" .. tostring(reward1[2].num)) + end + + local count = #reward2 + if count == 1 then + self.box2Add1Node:setVisible(true) + self.box2Add1ItemCell:refreshByCfg(reward2[1].id, 0) + self.box2Add1ItemCell:setNum("") + self.box2Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[1].id, self.box2Add1ItemCell:getBaseObject()) + end) + self.box2Add1Text:setText("+" .. tostring(reward2[1].num)) + else + self.box2Add1Node:setVisible(true) + self.box2Add1ItemCell:refreshByCfg(reward2[1].id, 0) + self.box2Add1ItemCell:setNum("") + self.box2Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[1].id, self.box2Add1ItemCell:getBaseObject()) + end) + self.box2Add1Text:setText("+" .. tostring(reward2[1].num)) + + self.box2Add2Node:setVisible(true) + self.box2Add2ItemCell:refreshByCfg(reward2[2].id, 0) + self.box2Add2ItemCell:setNum("") + self.box2Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward2[2].id, self.box2Add2ItemCell:getBaseObject()) + end) + self.box2Add2Text:setText("+" .. tostring(reward2[2].num)) + end + + local count = #reward3 + if count == 1 then + self.box3Add1Node:setVisible(true) + self.box3Add1ItemCell:refreshByCfg(reward3[1].id, 0) + self.box3Add1ItemCell:setNum("") + self.box3Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[1].id, self.box3Add1ItemCell:getBaseObject()) + end) + self.box3Add1Text:setText("+" .. tostring(reward3[1].num)) + else + self.box3Add1Node:setVisible(true) + self.box3Add1ItemCell:refreshByCfg(reward3[1].id, 0) + self.box3Add1ItemCell:setNum("") + self.box3Add1ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[1].id, self.box3Add1ItemCell:getBaseObject()) + end) + self.box3Add1Text:setText("+" .. tostring(reward3[1].num)) + + self.box3Add2Node:setVisible(true) + self.box3Add2ItemCell:refreshByCfg(reward3[2].id, 0) + self.box3Add2ItemCell:setNum("") + self.box3Add2ItemCell:addClickListener(function() + ModuleManager.TipsManager:showItemTips(reward3[2].id, self.box3Add2ItemCell:getBaseObject()) + end) + self.box3Add2Text:setText("+" .. tostring(reward3[2].num)) + end +end + +return BoxLevelUpUI \ No newline at end of file diff --git a/lua/app/ui/shop/box_level_up_ui.lua.meta b/lua/app/ui/shop/box_level_up_ui.lua.meta new file mode 100644 index 00000000..2d5eb8ae --- /dev/null +++ b/lua/app/ui/shop/box_level_up_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a0c868370ad4a41428279122b3d5dc49 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/box_reward_ui.lua b/lua/app/ui/shop/box_reward_ui.lua index 4ba7373c..df9fa8be 100644 --- a/lua/app/ui/shop/box_reward_ui.lua +++ b/lua/app/ui/shop/box_reward_ui.lua @@ -61,8 +61,15 @@ function BoxRewardUI:onLoadRootComplete() self.closeTx = self.uiMap["box_reward_ui.close_tx"] self.closeTx:setText("点击关闭TD") -- TODOJ - self.closeTx:addClickListener(function() + + self.mask = self.uiMap["box_reward_ui.mask"] + self.mask:addClickListener(function() self:closeUI() + -- 如果宝箱等级提升了 则要弹出宝箱等级提升UI + if DataManager.SummonData:checkNeedPopBoxLvUpUI() then + DataManager.SummonData:clearNeedPopBoxLvUpUI() + ModuleManager.ShopManager:showBoxLevelUpUI() + end end) end diff --git a/lua/app/ui/shop/cell/box_sell_cell.lua b/lua/app/ui/shop/cell/box_sell_cell.lua index 4f9a90f9..46c1de02 100644 --- a/lua/app/ui/shop/cell/box_sell_cell.lua +++ b/lua/app/ui/shop/cell/box_sell_cell.lua @@ -116,6 +116,13 @@ function BoxSellCell:refreshCost() end function BoxSellCell:onClickBox(summonType) + local costItem, cost = DataManager.SummonData:getSummonCost(summonType) + if not GFunc.checkCost(costItem.id, costItem.num, false) then + if not GFunc.checkCost(cost.id, cost.num, true) then + return + end + end + ModuleManager.ShopManager:showBoxHeroUI(summonType) end diff --git a/lua/app/userdata/summon/summon_data.lua b/lua/app/userdata/summon/summon_data.lua index f8775b9e..d7e4d7a4 100644 --- a/lua/app/userdata/summon/summon_data.lua +++ b/lua/app/userdata/summon/summon_data.lua @@ -18,16 +18,24 @@ function SummonData:initCrossDay() end) end -function SummonData:init(summon) +function SummonData:init(summon, isInit) if EDITOR_MODE then Logger.logHighlight("召唤初始化") Logger.printTable(summon) end + local lastLv = self.level + summon = summon or {} self.level = summon.level or 1 self.exp = summon.exp or 0 + if not isInit then + if lastLv and lastLv < self.level then + self:markNeedPopBoxLvUpUI() + end + end + self:setDirty() end @@ -110,4 +118,17 @@ function SummonData:getLastSummonRewards() return self.summonRewards or {} end +-- 如果宝箱等级提升了 则标记 +function SummonData:markNeedPopBoxLvUpUI() + self.needPopBoxLvUpUI = true +end + +function SummonData:clearNeedPopBoxLvUpUI() + self.needPopBoxLvUpUI = false +end + +function SummonData:checkNeedPopBoxLvUpUI() + return self.needPopBoxLvUpUI +end + return SummonData \ No newline at end of file From db985c714c67040f27daf945b31c759a36cedd7a Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 24 May 2023 11:02:26 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E7=9B=B8=E4=BA=92=E5=8F=8D=E5=87=BB?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 6 ++++- .../battle/component/battle_unit_comp.lua | 26 +++++++++++-------- .../battle/controller/battle_controller.lua | 9 +++---- lua/app/module/battle/team/battle_team.lua | 14 +++++----- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 99108f09..563b76b8 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -128,6 +128,11 @@ BattleConst.UNIT_STATE = { VERITGO = 12, -- 昏睡 } +BattleConst.ATTACK_ACTION_STATE = { + NORMAL = "normal", + COUNTERATTACK = "counterattack", +} + BattleConst.MATCH_DMG_ADDITION_NAME = { [0] = "dmg_addition_none", [1] = "dmg_addition_red", @@ -194,7 +199,6 @@ BattleConst.EFFECT_TYPE = { HEAL = 101, HOT = 102, REBOUND = 201, -- 反弹 - COUNTERATTACK = 301, -- 反击 } ---- 特殊的伤害类型,其余都是buffname diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index fe5800b9..eb346460 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -286,12 +286,14 @@ function BattleUnitComp:getIsCentralizedAttack() return self.team:getCentralizedAttack() end -function BattleUnitComp:beforeAttack(effectType) +function BattleUnitComp:getCurAttackActionState() + return self.curAttackActionState +end + +function BattleUnitComp:beforeAttack(actionState) self.team:setCentralizedAttack(true) self.battleController:setIsPauseHpProgress(true) - if effectType == BattleConst.EFFECT_TYPE.DIRECT then - self:checkPassiveEvent(PASSIVE_EVENT.ON_UNI_ATTACK_START, self) - end + self.curAttackActionState = actionState end function BattleUnitComp:useAssistingSkill(count, delay, callback) @@ -1509,6 +1511,15 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d self:showEffectNumber(effectColor, direction, damageStr, x, y, delayTime) end end + if atker:getCurAttackActionState() == BattleConst.ATTACK_ACTION_STATE.NORMAL then + if self.unitEntity:getCounterAttack() > 0 then -- 触发反击 + local counterattack = self.unitEntity:getCounterAttack() + if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率 + self.unitEntity:addCounterAttackCount(1) + self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side) + end + end + end if effectType == EFFECT_TYPE.DIRECT then if hp > 0 and self.unitEntity:getShieldRebound() then -- 伤害反弹 atker:takeDamageOrCure(self, num*self.unitEntity:getShieldRebound() // DEFAULT_FACTOR, EFFECT_TYPE.REBOUND, 0, BattleConst.BUFF_NAME.SHIELD_REBOUND_200) @@ -1522,13 +1533,6 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d if self.unitEntity:getThorns() > 0 then -- 反伤 atker:takeDamageOrCure(self, num*self.unitEntity:getThorns() // DEFAULT_FACTOR, EFFECT_TYPE.REBOUND, 0, BattleConst.BUFF_NAME.THORNS) end - if self.unitEntity:getCounterAttack() > 0 then -- 触发反击 - local counterattack = self.unitEntity:getCounterAttack() - if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率 - self.unitEntity:addCounterAttackCount(1) - self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side) - end - end end elseif num > 0 then -- 治疗 self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, 0) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index ebd07266..9db26a45 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -556,7 +556,7 @@ function BattleController:enterBattleStep() local defAction = function() self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_DEF_STEP - self.defTeam:mainUnitUseAllSkills(function() + self.defTeam:mainUnitUseAllSkills(BattleConst.ATTACK_ACTION_STATE.NORMAL, function() self:enterNextTeamAction() end) end @@ -1206,9 +1206,6 @@ function BattleController:generateInstructions(skillEntity, elementType, lineCou end function BattleController:exeInstructions(callback) - if EDITOR_MODE then - Logger.logHighlight("--------exeInstructions----------") - end if not self.instructions or #self.instructions <= 0 then callback() return @@ -2520,11 +2517,11 @@ local function _assisting(self, instruction, callback) end local function _generalAttack(self, instruction, callback) - self.atkTeam:useNormalSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, callback) + self.atkTeam:useNormalSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.NORMAL, callback) end local function _playSkill(self, instruction, callback) - self.atkTeam:useSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, callback) + self.atkTeam:useSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.NORMAL, callback) end BattleController._doInstruction = { diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 8128adfe..41ed3e56 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -58,7 +58,7 @@ function BattleTeam:removeAllUnits() self.mainUnit = nil end -function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType, callback) +function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType, actionState, callback) self.isFinalAction = isFinalAction local unit = nil if matchType == nil then @@ -73,12 +73,12 @@ function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType, return callback() end self.mainUnit = unit - unit:beforeAttack(effectType) + unit:beforeAttack(actionState) unit:resetBeforeAttack() unit:useNormalSkill(count, effectType, callback) end -function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, callback) +function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, actionState, callback) self.isFinalAction = isFinalAction local unit = nil if matchType == nil then @@ -94,7 +94,7 @@ function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, callba end local lastMainUnit = self.mainUnit self.mainUnit = unit - unit:beforeAttack(effectType) + unit:beforeAttack(actionState) unit:resetBeforeAttack() if unit:useSkill(1, count, callback) then if lastMainUnit and lastMainUnit ~= unit then @@ -140,7 +140,7 @@ function BattleTeam:useAssistingSkill(assistingList, isFinalAction, callback) end end -function BattleTeam:mainUnitUseAllSkills(callback) +function BattleTeam:mainUnitUseAllSkills(actionState, callback) self.isFinalAction = true if self.mainUnit == nil then return callback() @@ -148,7 +148,7 @@ function BattleTeam:mainUnitUseAllSkills(callback) if self.mainUnit:getIsLimit() then return callback() end - self.mainUnit:beforeAttack() + self.mainUnit:beforeAttack(actionState) self.mainUnit:resetBeforeAttack() self.mainUnit:useAllSkills(callback) end @@ -565,7 +565,7 @@ function BattleTeam:onActionOver() self.battleController.curTeam = self.battleController.defTeam end - self:useNormalSkill(skillMatch, counterAttackCount, true, BattleConst.EFFECT_TYPE.COUNTERATTACK, function() + self:useNormalSkill(skillMatch, counterAttackCount, true, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.COUNTERATTACK, function() self.battleController:enterNextTeamAction() end) end From ca51dddab2d17f192190c01e1df82d75e9a420c1 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Wed, 24 May 2023 11:33:54 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E7=AB=A0=E8=8A=82=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/bi_report.lua | 2 + lua/app/common/pay_manager.lua | 7 ++- lua/app/module/shop/shop_manager.lua | 15 ------ lua/app/ui/main_city/main_city_ui.lua | 16 ++++-- lua/app/ui/shop/cell/chapter_cell.lua | 14 ++--- lua/app/ui/shop/cell/chapter_sell_cell.lua | 21 +++----- lua/app/ui/shop/cell/gem_cell.lua | 4 +- lua/app/userdata/shop/shop_data.lua | 59 ++++++++++++++++------ 8 files changed, 81 insertions(+), 57 deletions(-) diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index f77dccef..c5a5f06f 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -75,6 +75,7 @@ BIReport.ITEM_GET_TYPE = { MALL_TREASURE = "MallTreasure", -- 常驻钻石礼包 MALL_DAILY = "MallDaily", -- 每日特惠 MALL_DAILY_RESET = "MallDailyReset", + ACT_CHAPTER_STORE = "ActChapterStore", -- 章节礼包 SUMMON = "Summon", PLAYER_LV_UP = "PlayerLvUp", GOLD_PIG = "GoldPig", @@ -123,6 +124,7 @@ BIReport.GIFT_TYPE = { BOUNTY = "Bounty", GOLD_PIG = "GoldPig", MALL_TREASURE = "MallTreasure", + ACT_CHAPTER_STORE = "ActChapterStore", } BIReport.COIN_TYPE = { diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index c5b5580b..461744c7 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -18,6 +18,7 @@ PayManager.PURCHARSE_TYPE_CONFIG = { [PayManager.PURCHARSE_TYPE.ACT_GIFT] = "act_gift", [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = "act_gold_pig", [PayManager.PURCHARSE_TYPE.MALL_TREASURE] = "mall_treasure", + [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = "act_chapter_store", } PayManager.BI_ITEM_GET_TYPE = { @@ -26,6 +27,7 @@ PayManager.BI_ITEM_GET_TYPE = { }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.ITEM_GET_TYPE.GOLD_PIG, [PayManager.PURCHARSE_TYPE.MALL_TREASURE] = BIReport.ITEM_GET_TYPE.MALL_TREASURE, + [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = BIReport.ITEM_GET_TYPE.ACT_CHAPTER_STORE, } PayManager.BI_GIFT_TYPE = { @@ -34,6 +36,7 @@ PayManager.BI_GIFT_TYPE = { }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.GIFT_TYPE.GOLD_PIG, [PayManager.PURCHARSE_TYPE.MALL_TREASURE] = BIReport.GIFT_TYPE.MALL_TREASURE, + [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = BIReport.GIFT_TYPE.ACT_CHAPTER_STORE, } function PayManager:getItemGetType(purchaseType, id) @@ -113,7 +116,9 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, giftTy end table.foreach(msgData.gift, function(i, gift) - local rechargeId = DataManager.ShopData:getShopItemCfg(gift).recharge_id + local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[gift.act_type] + local cfgInfo = ConfigManager:getConfig(cfgName)[gift.id] + local rechargeId = cfgInfo.recharge_id DataManager.PlayerData:addPayment(rechargeId) DataManager.ShopData:updateGiftInfo(gift) end) diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index 1e978d93..7641a4c6 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -95,9 +95,6 @@ function ShopManager:mallDailyGiftOverDay() end function ShopManager:mallDailyGiftOverDayFinish(result) - -- if result.err_code == GConst.ERROR_STR.SUCCESS then - -- DataManager.ShopData:initMallDaily(result.mall_daily_info) - -- end -- 消息无用 仅为了触发推送 end @@ -107,18 +104,6 @@ function ShopManager:onMallDailyReset(result) end end --- 常规钻石 -function ShopManager:buyMallTreasure(id, isAd) - PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.MALL_TREASURE) -end - -function ShopManager:buyMallTreasureFinish(result) - if result.err_code == GConst.ERROR_STR.SUCCESS then - GFunc.showRewardBox(result.rewards) - -- TODOJ - end -end - -- 常规金币 function ShopManager:buyMallIdleCoin(id, isAd) local params = {id = id, ad = isAd} diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 51d1a191..18d769ae 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -744,27 +744,37 @@ function MainCityUI:checkMainPop() if self:checkTutorial() then return end + + -- 礼包 + if self:checkGift() then + return + end end -- 检查引导 function MainCityUI:checkTutorial() if DataManager.ChapterData:getMaxChapterId() == 1 then if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_ONE_CHAPTER) then - return + return true end end if DataManager.ChapterData:boxCanGet(2, 1) then if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.TWO_CHAPTER_BOX_CAN_GOT) then - return + return true end end if DataManager.ChapterData:getMaxChapterId() == 2 then if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_THREE_CHAPTER) then - return + return true end end end +-- 检查礼包 +function MainCityUI:checkGift() + -- TODOJ +end + return MainCityUI \ No newline at end of file diff --git a/lua/app/ui/shop/cell/chapter_cell.lua b/lua/app/ui/shop/cell/chapter_cell.lua index ff3f46e8..fb9ca3b9 100644 --- a/lua/app/ui/shop/cell/chapter_cell.lua +++ b/lua/app/ui/shop/cell/chapter_cell.lua @@ -39,7 +39,7 @@ function ChapterCell:init() self.timeText = uiMap["gift_cell.bg.time_img.text"] end -function ChapterCell:refresh(idx, cfgInfo, totalCount, arrowCallback, clickCallback) +function ChapterCell:refresh(idx, cfgInfo, totalCount, arrowCallback) -- 箭头 local showLeftArrow = true local showRightArrow = true @@ -90,15 +90,17 @@ function ChapterCell:refresh(idx, cfgInfo, totalCount, arrowCallback, clickCallb -- 限时(隐藏) self.timeImg:setVisible(false) - if clickCallback then - self:addClickListener(function() - clickCallback(idx) - end) - end + self:addClickListener(function() + self:onClickGift(cfgInfo.id) + end) end function ChapterCell:setVisible(visible) self.baseObject:setVisible(visible) end +function ChapterCell:onClickGift(id) + PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.CHAPTER_GIFT) +end + return ChapterCell \ No newline at end of file diff --git a/lua/app/ui/shop/cell/chapter_sell_cell.lua b/lua/app/ui/shop/cell/chapter_sell_cell.lua index 309b7064..6c1bdc7b 100644 --- a/lua/app/ui/shop/cell/chapter_sell_cell.lua +++ b/lua/app/ui/shop/cell/chapter_sell_cell.lua @@ -15,9 +15,6 @@ function ChapterSellCell:init() cell:refresh(idx, self.actChapterCfg[idx], #self.actChapterCfg, function (add) self.contentObj:addAnchoredPosition(add*720) - end, - function(idx) - self:onClickGift(self.actChapterCfg[idx].id) end) end end) @@ -27,13 +24,12 @@ function ChapterSellCell:init() end function ChapterSellCell:refresh() - -- 暂无数据部分 测试用 TODOJ - local tmpIds = {303, 203, 103} -- {103, 203, 303} + local actIdList = DataManager.ShopData:getActChapterStoreCanBuyActIds() self.actChapterCfg = {} - local actChapterCfg = ConfigManager:getConfig("act_chapter_store") - for i = 1, #tmpIds do - local cfgInfo = clone(actChapterCfg[tmpIds[i]]) - cfgInfo.id = tmpIds[i] + local actChapterCfg = DataManager.ShopData:getActChapterStoreConfig() + for i = 1, #actIdList do + local cfgInfo = clone(actChapterCfg[actIdList[i]]) + cfgInfo.id = actIdList[i] table.insert(self.actChapterCfg, cfgInfo) end self.scrollRect:refillCells(#self.actChapterCfg) @@ -45,15 +41,12 @@ function ChapterSellCell:getCellHeight() end function ChapterSellCell:getIsOpen() - return true -- TOODJ + -- 有可购买的礼包 才打开 + return #DataManager.ShopData:getActChapterStoreCanBuyActIds() > 0 end function ChapterSellCell:setVisible(visible) self.baseObject:setVisible(visible) end -function ChapterSellCell:onClickGift(id) - Logger.logHighlight("Click id:%s", id) -- TODOJ -end - return ChapterSellCell \ No newline at end of file diff --git a/lua/app/ui/shop/cell/gem_cell.lua b/lua/app/ui/shop/cell/gem_cell.lua index 4b9b146e..beaa9ac4 100644 --- a/lua/app/ui/shop/cell/gem_cell.lua +++ b/lua/app/ui/shop/cell/gem_cell.lua @@ -83,11 +83,11 @@ function GemCell:onClickGift(id, isAd) local adLeftCount = adMaxTimes - bought if adLeftCount > 0 then SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.MALL_TREASURE, function () - ModuleManager.ShopManager:buyMallTreasure(id, isAd) + PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.MALL_TREASURE) end) end else - ModuleManager.ShopManager:buyMallTreasure(id, isAd) + PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.MALL_TREASURE) end end diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index a9c81647..ccffb4a9 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -93,15 +93,6 @@ function ShopData:updateGiftInfo(gift) self:setDirty() end -function ShopData:getShopItemCfg(giftData) - if giftData.act_type == 1 then -- mall_act - return ConfigManager:getConfig("mall_act")[giftData.id] - end - if giftData.act_type == 5 then -- mall_treasure - return ConfigManager:getConfig("mall_treasure")[giftData.id] - end -end - -- 通用礼包结束 ---------------------------------------------------------------------------------------------- -- 每日特惠部分 ********************************************************************************************** @@ -226,7 +217,6 @@ function ShopData:getMallGoldConfig() end function ShopData:initCommonDailyGoldGift(ad_count) - if EDITOR_MODE then Logger.logHighlight("初始化 initCommonDailyGoldGift") Logger.printTable(ad_count) @@ -246,11 +236,6 @@ end function ShopData:getCommonDailyCoinNum(time) local coinPerHour = DataManager.IdleData:getGoldPerHour() -- TODOJ return coinPerHour * time // 3600 - - -- local goldDrop = DataManager.ChapterData:getGoldDrop() - -- local idleGoldDropTime = DataManager.IdleData:getIdleGoldDropTime() - -- Logger.logHighlight("getCommonDailyCoinNum -- time:%s gold:%s idle:%s", time, goldDrop, idleGoldDropTime) - -- return goldDrop * time // idleGoldDropTime end function ShopData:getCommonDailyCoinDataById(id) @@ -262,11 +247,53 @@ end -- 常驻金币礼包结束 ---------------------------------------------------------------------------------------------- --- 常驻钻石礼包 +-- 常驻钻石礼包 ********************************************************************************************** function ShopData:getMallTreasureConfig() return ConfigManager:getConfig("mall_treasure") end +-- 常驻钻石礼包结束 ---------------------------------------------------------------------------------------------- + +-- 章节礼包 act_chapter_store ********************************************************************************************** +function ShopData:getActChapterStoreConfig() + return ConfigManager:getConfig("act_chapter_store") +end + +-- 特定章节礼包是否已购买 +function ShopData:getActChapterStoreHasBuy(chapterId) + -- 章节礼包的id-chapterId相互对应map + if not self.actChapterStoreMap then + self.actChapterStoreId2ChapterIdMap = {} + self.actChapterStoreChapterId2IdMap = {} + local cfg = self:getActChapterStoreConfig() + for id, cfgInfo in pairs(cfg) do + self.actChapterStoreId2ChapterIdMap[id] = cfgInfo.chapter + self.actChapterStoreChapterId2IdMap[cfgInfo.chapter] = id + end + end + + local actId = self.actChapterStoreChapterId2IdMap[chapterId] + if self:getGiftBoughtNum(GConst.ShopConst.GIFT_TYPE.CHAPTER_GIFT, actId) == 0 then + return false + else + return true + end +end + +-- 根据当前章节,获取可购买的id数组 +function ShopData:getActChapterStoreCanBuyActIds() + local list = {} + local curChapterId = DataManager.ChapterData:getChapterId() + for id = curChapterId, 1, -1 do + if not self:getActChapterStoreHasBuy(id) then + table.insert(list, self.actChapterStoreChapterId2IdMap[id]) + end + end + return list +end + +-- 章节礼包结束 ---------------------------------------------------------------------------------------------- + -- 初始化成长礼包 function ShopData:initGrowUpGift(growUpGift) end From f7a4a0fe31238e12e5ad2b270e4eb58880cca5c9 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 24 May 2023 12:07:20 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E8=A1=A8=E7=8E=B0bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/component/battle_unit_comp.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index eb346460..9174348f 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -230,7 +230,7 @@ function BattleUnitComp:stopRunAction() end function BattleUnitComp:playAnimation(name, loop, forceRefresh) - if name == SPINE_ANIMATION_NAME.HIT or name == SPINE_ANIMATION_NAME.BLOCK then + if name == self.curHurtName or name == SPINE_ANIMATION_NAME.BLOCK then self.isPlayingSubAni = true end self.currAnimationName = name @@ -294,6 +294,9 @@ function BattleUnitComp:beforeAttack(actionState) self.team:setCentralizedAttack(true) self.battleController:setIsPauseHpProgress(true) self.curAttackActionState = actionState + if actionState == BattleConst.ATTACK_ACTION_STATE.NORMAL then + self:checkPassiveEvent(PASSIVE_EVENT.ON_UNI_ATTACK_START, self) + end end function BattleUnitComp:useAssistingSkill(count, delay, callback) @@ -679,7 +682,7 @@ function BattleUnitComp:updateIdleSubAni(...) if not self.currAnimationName or not self.isPlayingSubAni then return end - if self.currAnimationName == SPINE_ANIMATION_NAME.HIT then + if self.currAnimationName == self.curHurtName then self:updateHurt(...) elseif self.currAnimationName == SPINE_ANIMATION_NAME.BLOCK then self:updateBlock(...) @@ -1535,7 +1538,15 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d end end elseif num > 0 then -- 治疗 - self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, 0) + local time = Time:getServerTime() + if self.lastHealTime == time then + self.lastSameTimeHealCount = self.lastSameTimeHealCount + 1 + else + self.lastHealTime = time + self.lastSameTimeHealCount = 0 + end + local delayTime = self.lastSameTimeHealCount * 0.1 + self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, delayTime) end local hpPercent = self.unitEntity:getHpPercent() self.battleController:refreshHp(self.side, hp, hpPercent) From eb531423dd0e424cab1ad7b2aadc27de295767e0 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Wed, 24 May 2023 16:00:43 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E7=AB=A0=E8=8A=82=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E4=B8=8E=E6=96=B0=E6=89=8B=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/bi_report.lua | 4 + lua/app/common/data_manager.lua | 2 +- lua/app/common/pay_manager.lua | 19 +++ lua/app/game.lua | 9 ++ lua/app/module/chapter/chapter_manager.lua | 7 + lua/app/module/shop/shop_const.lua | 13 +- lua/app/module/shop/shop_manager.lua | 6 + lua/app/ui/main_city/main_city_ui.lua | 9 +- lua/app/ui/shop/cell/beginner_sell_cell.lua | 6 +- lua/app/ui/shop/cell/gem_cell.lua | 4 +- lua/app/ui/shop/gift_pop_ui.lua | 166 ++++++++++++++++++++ lua/app/ui/shop/gift_pop_ui.lua.meta | 10 ++ lua/app/userdata/shop/shop_data.lua | 90 +++++++++-- 13 files changed, 314 insertions(+), 31 deletions(-) create mode 100644 lua/app/ui/shop/gift_pop_ui.lua create mode 100644 lua/app/ui/shop/gift_pop_ui.lua.meta diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index c5a5f06f..f0f9011b 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -75,6 +75,8 @@ BIReport.ITEM_GET_TYPE = { MALL_TREASURE = "MallTreasure", -- 常驻钻石礼包 MALL_DAILY = "MallDaily", -- 每日特惠 MALL_DAILY_RESET = "MallDailyReset", + FIRST_RECHARGE = "FirstRecharge", + BEGINNER_GIFT = "BeginnerGift", ACT_CHAPTER_STORE = "ActChapterStore", -- 章节礼包 SUMMON = "Summon", PLAYER_LV_UP = "PlayerLvUp", @@ -121,6 +123,8 @@ BIReport.BATTLE_TYPE = { } BIReport.GIFT_TYPE = { + FIRST_RECHARGE = "FirstRecharge", + BEGINNER_GIFT = "BeginnerGift", BOUNTY = "Bounty", GOLD_PIG = "GoldPig", MALL_TREASURE = "MallTreasure", diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 86659c6f..274b66b0 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -126,7 +126,7 @@ function DataManager:initWithServerData(data) self.DailyTaskData:init(data.task_daily) self.IdleData:init(data.idle) -- self.SevenDayData:init(data.SevenDayData) - self.ShopData:initCrossDay() + self.ShopData:initBase() self.ShopData:initActGift(data.act) -- 礼包购买信息 self.ShopData:initMallDaily(data.mall_daily) -- 每日特惠 self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包 diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 461744c7..45a7d674 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -11,6 +11,8 @@ PayManager.PURCHARSE_TYPE = { } PayManager.PURCHARSE_ACT_TYPE = { + FIRST_RECHARGE = 1, + BEGINNER_GIFT = 4, BOUNTY = 7, } @@ -23,6 +25,8 @@ PayManager.PURCHARSE_TYPE_CONFIG = { PayManager.BI_ITEM_GET_TYPE = { [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { + [PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.ITEM_GET_TYPE.FIRST_RECHARGE, + [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.ITEM_GET_TYPE.BEGINNER_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.ITEM_GET_TYPE.BOUNTY, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.ITEM_GET_TYPE.GOLD_PIG, @@ -32,6 +36,8 @@ PayManager.BI_ITEM_GET_TYPE = { PayManager.BI_GIFT_TYPE = { [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { + [PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE] = BIReport.GIFT_TYPE.FIRST_RECHARGE, + [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.GIFT_TYPE.BEGINNER_GIFT, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.GIFT_TYPE.BOUNTY, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.GIFT_TYPE.GOLD_PIG, @@ -79,6 +85,19 @@ function PayManager:getGiftType(purchaseType, id) end end +function PayManager:getGiftConfigInfo(purchaseType, id) + local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[purchaseType] + if not cfgName then + return + end + local cfg = ConfigManager:getConfig(cfgName) + local cfg = ConfigManager:getConfig(cfgName) + if not cfg or not cfg[id] then + return + end + return cfg[id] +end + function PayManager:purchasePackage(id, purchaseType) local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[purchaseType] if not cfgName then diff --git a/lua/app/game.lua b/lua/app/game.lua index 1a5838ad..b6d2daa8 100644 --- a/lua/app/game.lua +++ b/lua/app/game.lua @@ -399,6 +399,15 @@ if NOT_PUBLISH then Logger.printTable(map) end end + + if Input.GetKeyDown(KeyCode.Q) then + -- 标记可弹出新手礼包 + DataManager.ShopData:markPopUpGiftForBeginnerGift() + end + if Input.GetKeyDown(KeyCode.W) then + -- 章节通关 标记可弹出章节礼包 + DataManager.ShopData:markPopUpGiftForActChapterStore(4) + end end Game._releaseOnApplicationFocus = Game.onApplicationFocus diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 108a7d54..5f7f5b6c 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -98,6 +98,13 @@ function ChapterManager:endFightFinish(result) local data = {} data.max_chapter = newMaxChapter CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) + + -- 标记可弹出新手礼包 + if newMaxChapter == 1 then + DataManager.ShopData:markPopUpGiftForBeginnerGift() + end + -- 章节通关 标记可弹出章节礼包 + DataManager.ShopData:markPopUpGiftForActChapterStore(newMaxChapter) end ModuleManager.TaskManager:addFightTaskProgress(reqData) diff --git a/lua/app/module/shop/shop_const.lua b/lua/app/module/shop/shop_const.lua index f356b48b..b761b9ef 100644 --- a/lua/app/module/shop/shop_const.lua +++ b/lua/app/module/shop/shop_const.lua @@ -1,16 +1,5 @@ local ShopConst = class("ShopConst", BaseModule) --- 服务器pb对应的类型 -ShopConst.GIFT_TYPE = { - ACT_GIFT = 1, - GOLD_PIG = 2, - CHAPTER_GIFT = 3, - GROW_UP_GIFT = 4, - MALL_TREASURE = 5, -} - -ShopConst.ACT_GIFT_ID = { - BEGINNER_GIFT = 40102 -- 新手礼包ID -} +ShopConst.BEGINNER_GIFT_ID = 40102 -- 新手礼包ID return ShopConst \ No newline at end of file diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index 7641a4c6..ee6cf98c 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -21,6 +21,12 @@ function ShopManager:showBoxLevelUpUI(params) UIManager:showUI("app/ui/shop/box_level_up_ui", params) end +-- 弹窗礼包 +function ShopManager:showGiftPopUI(params) + UIManager:showUI("app/ui/shop/gift_pop_ui", params) +end + + -- 购买每日特惠商品 function ShopManager:buyMallDailyGift(id, isAd) if not DataManager.ShopData:getMallDailyIsOpen() then diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 18d769ae..c02fdf22 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -774,7 +774,14 @@ end -- 检查礼包 function MainCityUI:checkGift() - -- TODOJ + local actType, actId = DataManager.ShopData:getNextPopGiftData() + if actType and actId then + -- 触发弹窗 + ModuleManager.ShopManager:showGiftPopUI({type = actType, id = actId}) + -- 移除 + DataManager.ShopData:removePopUpGift(actType, actId) + return true + end end return MainCityUI \ No newline at end of file diff --git a/lua/app/ui/shop/cell/beginner_sell_cell.lua b/lua/app/ui/shop/cell/beginner_sell_cell.lua index 93f77aee..de630864 100644 --- a/lua/app/ui/shop/cell/beginner_sell_cell.lua +++ b/lua/app/ui/shop/cell/beginner_sell_cell.lua @@ -39,7 +39,7 @@ function BeginnerSellCell:init() end function BeginnerSellCell:refresh() - local actGiftId = GConst.ShopConst.ACT_GIFT_ID.BEGINNER_GIFT + local actGiftId = GConst.ShopConst.BEGINNER_GIFT_ID local cfgInfo = ConfigManager:getConfig("act_gift")[actGiftId] -- 超值 if cfgInfo.value then @@ -87,7 +87,7 @@ function BeginnerSellCell:getCellHeight() end function BeginnerSellCell:getIsOpen() - return true -- TOODJ + return not DataManager.ShopData:getBeginnerGiftHasBuy() end function BeginnerSellCell:setVisible(visible) @@ -95,7 +95,7 @@ function BeginnerSellCell:setVisible(visible) end function BeginnerSellCell:onClickGift(id) - Logger.logHighlight("Click id:%s", id) -- TODOJ + PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT) end return BeginnerSellCell \ No newline at end of file diff --git a/lua/app/ui/shop/cell/gem_cell.lua b/lua/app/ui/shop/cell/gem_cell.lua index beaa9ac4..721e4cd2 100644 --- a/lua/app/ui/shop/cell/gem_cell.lua +++ b/lua/app/ui/shop/cell/gem_cell.lua @@ -25,7 +25,7 @@ function GemCell:refresh(id, cfgInfo) local reward = cfgInfo.reward[1] local limit = cfgInfo.limit or 0 local adMaxTimes = cfgInfo.daily or 0 - local bought = DataManager.ShopData:getGiftBoughtNum(GConst.ShopConst.GIFT_TYPE.MALL_TREASURE, id) + local bought = DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.MALL_TREASURE, id) local isFree = rechargeId == nil local hasDoubleTimes = bought < limit @@ -79,7 +79,7 @@ function GemCell:onClickGift(id, isAd) if isAd then local cfgInfo = DataManager.ShopData:getMallTreasureConfig()[id] local adMaxTimes = cfgInfo.daily or 0 - local bought = DataManager.ShopData:getGiftBoughtNum(GConst.ShopConst.GIFT_TYPE.MALL_TREASURE, id) + local bought = DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.MALL_TREASURE, id) local adLeftCount = adMaxTimes - bought if adLeftCount > 0 then SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.MALL_TREASURE, function () diff --git a/lua/app/ui/shop/gift_pop_ui.lua b/lua/app/ui/shop/gift_pop_ui.lua new file mode 100644 index 00000000..b7a86a7e --- /dev/null +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -0,0 +1,166 @@ +local GiftPopUI = class("GiftPopUI", BaseUI) + +local GIFT_BG_NAME = { + [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { + [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_2_1.png", -- TODOJ + }, + [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_1_1.png", -- TODOJ +} +local GIFT_TITLE_TEXT = { + [PayManager.PURCHARSE_TYPE.ACT_GIFT] = { + [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = "新手礼包TD", -- TODOJ + }, + [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = "章节礼包TD", -- TODOJ +} + +local MAX_ITEM_NUM = 4 + +function GiftPopUI:ctor(params) + params = params or {} + + self.actType = params.type + self.actId = params.id +end + +function GiftPopUI:isFullScreen() + return false +end + +function GiftPopUI:getPrefabPath() + return "assets/prefabs/ui/shop/gift_pop_ui.prefab" +end + +function GiftPopUI:onLoadRootComplete() + if not self.actType or not self.actId then + self:closeUI() + end + + self.uiMap = self.root:genAllChildren() + self.uiMap["gift_pop_ui.close_btn"]:addClickListener(function() + self:checkNextPopGiftOrClose() + end) + + self.titleTx = self.uiMap["gift_pop_ui.bg.title"] + self.banner = self.uiMap["gift_pop_ui.bg.banner"] + + self.offNode = self.uiMap["gift_pop_ui.bg.off_img"] + self.offText = self.uiMap["gift_pop_ui.bg.off_img.text"] + + self.itemNodeLayout = self.uiMap["gift_pop_ui.bg.item_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) + self.itemNodeList = {} + self.itemCellList = {} + self.itemTextList = {} + self.itemHelpList = {} + for i = 1, MAX_ITEM_NUM do + table.insert(self.itemNodeList, self.uiMap["gift_pop_ui.bg.item_" .. i]) + table.insert(self.itemCellList, CellManager:addCellComp(self.uiMap["gift_pop_ui.bg.item_".. i .. ".item_cell"], GConst.TYPEOF_LUA_CLASS.ITEM_CELL)) + table.insert(self.itemTextList, self.uiMap["gift_pop_ui.bg.item_".. i .. ".num"]) + table.insert(self.itemHelpList, self.uiMap["gift_pop_ui.bg.item_" .. i .. ".help"]) + end + + self.timeNode = self.uiMap["gift_pop_ui.bg.time_node"] + self.timeText = self.uiMap["gift_pop_ui.bg.time_node.text"] + + self.buyBtn = self.uiMap["gift_pop_ui.bg.buy_btn"] + self.buyBtnTx = self.uiMap["gift_pop_ui.bg.buy_btn.text"] + self.buyBtnIcon = self.uiMap["gift_pop_ui.bg.buy_btn.icon"] + + self.buyBtn:addClickListener(function() + self:onClickGift() + end) + + self:_bind() + self:scheduleGlobal(function() + self:updateTime() + end, 1) + self:refresh() +end + +function GiftPopUI:_bind() + self:bind(DataManager.ShopData, "isDirty", function() + self:refresh(true) + end) +end + +function GiftPopUI:refresh(needCheck) + if needCheck then + -- 如果已经购买过了 则切为下一个或关闭UI 目前都是唯一礼包 + local bought = DataManager.ShopData:getGiftBoughtNum(self.actType, self.actId) + if bought > 0 then + self:checkNextPopGiftOrClose() + return + end + end + + if self.actType == PayManager.PURCHARSE_TYPE.ACT_GIFT then + local type = PayManager:getGiftConfigInfo(self.actType, self.actId).type + self.titleTx:setText(GIFT_TITLE_TEXT[self.actType][type]) + self.banner:setTexture(GIFT_BG_NAME[self.actType][type]) + else + self.titleTx:setText(GIFT_TITLE_TEXT[self.actType]) + self.banner:setTexture(GIFT_BG_NAME[self.actType]) + end + + local cfgInfo = PayManager:getGiftConfigInfo(self.actType, self.actId) + if cfgInfo then + local off = cfgInfo.value or 0 + if off < 10 then -- 统一为百分比格式 + off = off * 100 + end + if off > 0 then + self.offNode:setVisible(true) + self.offText:setText(tostring(off) .. "%") + else + self.offNode:setVisible(false) + end + end + + local rewards = cfgInfo.reward or {} + for i = 1, MAX_ITEM_NUM do + if i <= #rewards then + self.itemNodeList[i]:setVisible(true) + self.itemCellList[i]:refreshByCfg(rewards[i].id, 0) + self.itemCellList[i]:setNum("") + self.itemTextList[i]:setText(rewards[i].num) + self.itemCellList[i]:addClickListener(function() + ModuleManager.TipsManager:showItemTips(rewards[i].id, self.itemCellList[i]:getBaseObject()) + end) + self.itemHelpList[i]:setVisible(false) + else + self.itemNodeList[i]:setVisible(false) + end + end + self.itemNodeLayout:RefreshLayout() + + local rechargeId = cfgInfo.recharge_id + if rechargeId then + self.buyBtnTx:setText(GFunc.getFormatPrice(rechargeId)) + end + + self:updateTime() +end + +function GiftPopUI:updateTime() + -- TODOJ +end + +function GiftPopUI:onClickGift() + PayManager:purchasePackage(self.actId, self.actType) +end + +function GiftPopUI:checkNextPopGiftOrClose() + local actType, actId = DataManager.ShopData:getNextPopGiftData() + if actType and actId then + -- 更新数据 + self.actType = actType + self.actId = actId + + self:refresh() + -- 移除弹窗列表 + DataManager.ShopData:removePopUpGift(actType, actId) + else + self:closeUI() + end +end + +return GiftPopUI \ No newline at end of file diff --git a/lua/app/ui/shop/gift_pop_ui.lua.meta b/lua/app/ui/shop/gift_pop_ui.lua.meta new file mode 100644 index 00000000..9b687bd7 --- /dev/null +++ b/lua/app/ui/shop/gift_pop_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 61eca75f20973c44cb9ede981da0583b +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index ccffb4a9..bb109f3c 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -4,8 +4,12 @@ function ShopData:ctor() self.data.isDirty = false end -function ShopData:clear() +function ShopData:initBase() + self:initActChapterStoreData() + self:initCrossDay() +end +function ShopData:clear() DataManager:unregisterCrossDayFunc("ShopData") end @@ -24,12 +28,10 @@ end -- 初始化购买的礼包 function ShopData:initActGift(act) - if EDITOR_MODE then Logger.logHighlight("初始化 initActGift") Logger.printTable(act) end - act = act or {} local gifts = act.gifts or {} -- 转为map结构 @@ -93,6 +95,35 @@ function ShopData:updateGiftInfo(gift) self:setDirty() end +-- 标记一个礼包需要弹出 在条件允许时会弹出 +function ShopData:markPopUpGift(actType, actId) + if not self.needPopUpGift then + self.needPopUpGift = {} + end + if not self.needPopUpGift[actType] then + self.needPopUpGift[actType] = {} + end + table.insert(self.needPopUpGift[actType], actId) +end + +function ShopData:removePopUpGift(actType, actId) + if self.needPopUpGift then + if self.needPopUpGift[actType] then + for index, id in ipairs(self.needPopUpGift[actType]) do + if id == actId then + table.remove(self.needPopUpGift[actType], index) + break + end + end + end + end +end + +-- 获取待处理弹出礼包结构 {type:[id1,id2,...]} +function ShopData:getPopUpGift() + return self.needPopUpGift +end + -- 通用礼包结束 ---------------------------------------------------------------------------------------------- -- 每日特惠部分 ********************************************************************************************** @@ -255,13 +286,7 @@ end -- 常驻钻石礼包结束 ---------------------------------------------------------------------------------------------- -- 章节礼包 act_chapter_store ********************************************************************************************** -function ShopData:getActChapterStoreConfig() - return ConfigManager:getConfig("act_chapter_store") -end - --- 特定章节礼包是否已购买 -function ShopData:getActChapterStoreHasBuy(chapterId) - -- 章节礼包的id-chapterId相互对应map +function ShopData:initActChapterStoreData() if not self.actChapterStoreMap then self.actChapterStoreId2ChapterIdMap = {} self.actChapterStoreChapterId2IdMap = {} @@ -271,9 +296,17 @@ function ShopData:getActChapterStoreHasBuy(chapterId) self.actChapterStoreChapterId2IdMap[cfgInfo.chapter] = id end end +end +function ShopData:getActChapterStoreConfig() + return ConfigManager:getConfig("act_chapter_store") +end + +-- 特定章节礼包是否已购买 +function ShopData:getActChapterStoreHasBuy(chapterId) + -- 章节礼包的id-chapterId相互对应map local actId = self.actChapterStoreChapterId2IdMap[chapterId] - if self:getGiftBoughtNum(GConst.ShopConst.GIFT_TYPE.CHAPTER_GIFT, actId) == 0 then + if self:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, actId) == 0 then return false else return true @@ -283,7 +316,7 @@ end -- 根据当前章节,获取可购买的id数组 function ShopData:getActChapterStoreCanBuyActIds() local list = {} - local curChapterId = DataManager.ChapterData:getChapterId() + local curChapterId = DataManager.ChapterData:getMaxChapterId() for id = curChapterId, 1, -1 do if not self:getActChapterStoreHasBuy(id) then table.insert(list, self.actChapterStoreChapterId2IdMap[id]) @@ -292,8 +325,41 @@ function ShopData:getActChapterStoreCanBuyActIds() return list end +function ShopData:markPopUpGiftForActChapterStore(chapterId) + local actId = self.actChapterStoreChapterId2IdMap[chapterId] + self:markPopUpGift(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, actId) +end + +-- 获取下一个需要弹出的礼包数据 +function ShopData:getNextPopGiftData() + local popUpGift = self:getPopUpGift() + if popUpGift then + for actType, actIdList in pairs(popUpGift) do + -- 弹窗顺序待处理 TODOJ + for _, actId in ipairs(actIdList) do + return actType, actId + end + end + end +end + -- 章节礼包结束 ---------------------------------------------------------------------------------------------- +-- 新手礼包 ********************************************************************************************** +function ShopData:markPopUpGiftForBeginnerGift() + self:markPopUpGift(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID) +end + +function ShopData:getBeginnerGiftHasBuy() + if self:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID) == 0 then + return false + else + return true + end +end + +-- 新手礼包结束 ---------------------------------------------------------------------------------------------- + -- 初始化成长礼包 function ShopData:initGrowUpGift(growUpGift) end