|
|
- AllAdditionView = AllAdditionView or BaseClass(BaseView)
-
- function AllAdditionView:__init()
- self.base_file = "bag"
- self.layout_file = "AllAdditionView"
- self.layer_name = "Activity"
-
- self.close_mode = CloseMode.CloseDestroy
- self.destroy_imm = true
- self.use_background = true
- self.click_bg_toClose = true
- self.is_set_zdepth = true
- -- self.use_local_view = true
- self.type = 0 --加成类型
- self.strength_count = nil --次数
- self.title_list = {
- [1] = "全身精炼加成", [2] = "全身星级加成", [3] = "全身宝石加成", [4] = "圣印精炼加成"
- }
- self.step_list = {
- [1] = "全身装备精炼累积达:+", [2] = "全身装备星级累积达:", [3] = "全身宝石等级累积达:", [4] = "全身圣印精炼累积达:+"
- }
- self.cur_list = {
- [1] = "当前全身装备精炼:+", [2] = "当前全身装备星级:", [3] = "当前全身宝石等级:", [4] = "当前全身圣印精炼:+"
- }
- self.model = BagModel:getInstance()
-
- self.load_callback = function()
- self:LoadSuccess()
- self:InitEvent()
-
- end
-
- self.open_callback = function()
- self:SetData()
- end
-
- self.destroy_callback = function()
- if self.equip_event_id then
- GoodsModel:getInstance():UnBind(self.equip_event_id)
- self.equip_event_id = nil
- end
- end
- end
-
- function AllAdditionView:Open(type,strength_count)
- self.type = type
- self.strength_count = strength_count
- BaseView.Open(self)
- end
-
- function AllAdditionView:LoadSuccess()
- self.win_title,self.title,self.pro,self.next_pro,
- self.next_title,self.now_target = GetChildTexts(self.transform,
- {
- "Bg/Title","Bg/title","Bg/pro","Bg/next_pro",
- "Bg/next_title","Bg/now_target"
- })
- self.default_now,self.default_next = GetChildGameObjects (self.transform,
- {
- "Bg/default_now","Bg/default_next"
- })
- end
-
- function AllAdditionView:InitEvent()
- local function onBtnClickHandler(target)
- if target == self.close_btn then
- self:Close()
- end
- end
- AddClickEvent(self.close_btn,onBtnClickHandler)
-
- local update_equip = function ()
- self:SetData()
- end
- self.equip_event_id = GoodsModel:getInstance():Bind(GoodsModel.CHANGE_EQUIPLIST, update_equip)
- end
-
- function AllAdditionView:SetData()
- if self.type == nil then return end
-
- local num_list = {}
- if not self.strength_count then
- num_list[1], num_list[2], num_list[3], num_list[4] = self.model:GetAllAddition()
- end
-
- self.win_title.text = self.title_list[self.type]
- self.now_target.text = self.cur_list[self.type] .. (self.strength_count or num_list[self.type])
-
- local now_cfg, next_cfg = self.model:GetBodyPlusConfig(self.type,self.strength_count)
-
- if now_cfg then
- self.default_now:SetActive(false)
- self.title.text = self.step_list[self.type] .. now_cfg.need_lv
- local pro_list = ErlangParser:GetInstance():Parse(now_cfg.attr_list)
- local str = self:GetProperty(pro_list,ColorUtil.GREEN)
- self.pro.text = str
- else
- self.default_now:SetActive(true)
- self.title.text = ""
- self.pro.text = ""
- end
-
- if next_cfg then
- self.default_next:SetActive(false)
- self.next_title.text = self.step_list[self.type] .. next_cfg.need_lv
- local pro_list = ErlangParser:GetInstance():Parse(next_cfg.attr_list)
- local str = self:GetProperty(pro_list,"#979696")
- self.next_pro.text = str
- else
- self.default_next:SetActive(true)
- self.next_title.text = ""
- self.next_pro.text = ""
- end
- end
-
- function AllAdditionView:GetProperty(pro_list,color)
- local pro = ""
- for i, v in ipairs(pro_list) do
- pro = pro .. WordManager:GetProperties(tonumber(v[1])) .. ":<color="..color..">+" .. WordManager:GetPropertyValue(tonumber(v[1]), tonumber(v[2])) .. "</color>"
- if i < #pro_list then
- pro = pro .. "\n"
- end
- end
- return pro
- end
|