-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFCannonUnlockUI.lua
More file actions
71 lines (57 loc) · 1.83 KB
/
FCannonUnlockUI.lua
File metadata and controls
71 lines (57 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--[[
炮台解锁升级(钻石)
]]
local UIBase = require_ex("ui.base.UIBase")
local M = class("FCannonUnlockUI", UIBase)
function M:ctor(cannonLv)
self._cannonLv = cannonLv
self.effDark = true
UIBase.ctor(self)
self:init()
end
function M:init()
self._BindWidget = {
["panel_touch"] = {handle = handler(self, self.onClose)},
["panel_clear"] = {},
["panel_clear/img_icon"] = {key = "img_icon"},
["panel_clear/txt_power"] = {key = "txt_power"},
["panel_clear/txt_num"] = {key = "txt_num"},
["panel_clear/btn_confirm"] = {key = "btn_confirm",handle = handler(self, self.onUnlock)},
}
self:initViews()
end
function M:initViews()
local uiNode = createCsbNode("subgame/catchFish/unlockCannon.csb")
self:addChild(uiNode, 1)
self._rootNode = uiNode
bindWidgetList(uiNode, self._BindWidget, self._widgets)
local cfg = BYCannonLevelConfig[self._cannonLv]
local nextLv = cfg.next_level
local nextInfo = BYCannonLevelConfig[nextLv]
self._widgets.txt_power:setString(nextInfo.cannon_multiple)
local coin = 0
for _, award in ipairs(cfg.level_reward) do
if award[1] == ENUM.ITEM_ID.COIN then
coin = coin + award[2]
end
end
local text = ""
if coin > 0 then
text = coin..Config.localize("magic_icon_desc")
end
self._widgets.txt_num:setString(text)
local _, needDiamond = Game.fishDB:cannonUpgEnable(self._cannonLv)
self._widgets.btn_confirm:setTitleString(tostring(needDiamond))
end
----------------------------------
-- 交互及回调
function M:onUnlock()
local canUp = Game.fishDB:cannonUpgEnable(self._cannonLv)
if canUp then
Game.fishCom:reqUpgradeCannon()
else
Game:doPluginAPI("enter", "shop", ShopType.diamond)
end
self:onClose()
end
return M