SoulPowerConditionItem = SoulPowerConditionItem or BaseClass(BaseItem) local SoulPowerConditionItem = SoulPowerConditionItem function SoulPowerConditionItem:__init() self.base_file = "soulPower" self.layout_file = "SoulPowerConditionItem" self.model = SoulPowerModel:getInstance() self:Load() end function SoulPowerConditionItem:Load_callback() self.nodes = { "state1:img", "conditionDes:tmp", "state2:obj", "goText:obj", } self:GetChildren(self.nodes) self:AddEvents() if self.need_refreshData then self:UpdateView() end end function SoulPowerConditionItem:AddEvents( ) local on_click = function ( click_obj ) if self.goText_obj == click_obj then if self.data[1] == SoulPowerConst.UpGradeConditionType.Lv then GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW) GlobalEventSystem:Fire(EventName.SHOW_MAIN_TASK_TIPS_VIEW, true) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunTower then GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW) OpenFun.Open(610,4) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.Power then GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW) OpenFun.Open(157,0) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunExp then GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW) -- ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_EXP_DUN_MAIN_VIEW, true) ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_EXP_HANGUP_MAIN_VIEW, true) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.WarSoulStar then GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW) OpenFun.Open(143,0) end end end AddClickEvent(self.goText_obj, on_click) local update_condition_item = function(red_type) if red_type ~= SoulPowerConst.RedType.UpGrade then return end if not self.is_loaded then return end self:UpdateView() end self:BindEvent(self.model, SoulPowerConst.UPDATE_RED_DOT, update_condition_item) end function SoulPowerConditionItem:UpdateView( ) local is_arrive = false if self.data[1] == SoulPowerConst.UpGradeConditionType.Lv then --玩家等级 is_arrive = RoleManager.Instance.mainRoleInfo.level >= self.data[2] local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK ------------------------------ self.conditionDes_tmp.text = string.format("角色等级达到 <%s>%s级", str_color, self.data[2]) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunTower then --爬塔层数 local easy_pass_num,diffcult_pass_num = BaseDungeonModel:getInstance():GetOneTowerPassRecord() is_arrive = easy_pass_num >= self.data[2] local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK ------------------------------ self.conditionDes_tmp.text = string.format("完成无尽回廊 <%s>第%s层", str_color, self.data[2]) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.Power then --玩家战力 is_arrive = RoleManager.Instance.mainRoleInfo.fighting >= self.data[2] local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK ------------------------------ self.conditionDes_tmp.text = string.format("角色战力达到 <%s>%s", str_color, self.data[2]) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunExp then --经验副本波数 local cur_assult_wave = ExpDunModel:getInstance():GetCurrentWave() is_arrive = cur_assult_wave >= self.data[2] local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK ------------------------------ self.conditionDes_tmp.text = string.format("完成放置冒险 <%s>第%s波", str_color, self.data[2]) elseif self.data[1] == SoulPowerConst.UpGradeConditionType.WarSoulStar then --战魂星数 local star_sum_num = WarSoulModel:getInstance():GetAllWarSoulSumStar() is_arrive = star_sum_num >= self.data[2] local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK ------------------------------ self.conditionDes_tmp.text = string.format("上阵战魂达到 <%s>%s星", str_color, self.data[2]) end lua_resM:setImageSprite(self, self.state1_img, "soulPower_asset", is_arrive and "soul_power_img_4" or "soul_power_img_3") self.state2_obj:SetActive(is_arrive) self.goText_obj:SetActive(not is_arrive) end function SoulPowerConditionItem:SetData( data ) self.data = data if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function SoulPowerConditionItem:__delete( ) end