|
|
StrengthMainItem = StrengthMainItem or BaseClass(BaseItem)
|
|
|
|
function StrengthMainItem:__init()
|
|
self.base_file = "strength"
|
|
self.layout_file = "StrengthMainItem"
|
|
self.layer_name = "UI"
|
|
-- self.use_local_view = true
|
|
|
|
self.model = StrengthModel:getInstance()
|
|
self.mainRoleVo = RoleManager.Instance.mainRoleInfo
|
|
self.star = {}
|
|
self.tween_list = {}
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function StrengthMainItem:Load_callback()
|
|
self.goBtn,
|
|
self.bar,
|
|
self.star_obj,
|
|
self.star[1],
|
|
self.star[2],
|
|
self.star[3],
|
|
self.star[4],
|
|
self.star[5],
|
|
self.complete
|
|
= GetChildGameObjects(self.transform,
|
|
{
|
|
"goBtn",
|
|
"bar",
|
|
"star",
|
|
"star/1/image",
|
|
"star/2/image",
|
|
"star/3/image",
|
|
"star/4/image",
|
|
"star/5/image",
|
|
"complete",
|
|
})
|
|
|
|
self.title,
|
|
self.desc,
|
|
self.prise,
|
|
self.condition,
|
|
self.num
|
|
= GetChildTexts(self.transform,
|
|
{
|
|
"msg",
|
|
"tips1",
|
|
"tips2",
|
|
"label1",
|
|
"bar/num",
|
|
})
|
|
|
|
self.progress,
|
|
self.textImg,
|
|
self.iconImg
|
|
= GetChildImages(self.transform,
|
|
{
|
|
"bar/value",
|
|
"complete/textImg",
|
|
"icon/iconImg",
|
|
})
|
|
self.complete:SetActive(false)
|
|
|
|
if self.need_refreshData then
|
|
self:SetData()
|
|
end
|
|
self:InitEvent()
|
|
end
|
|
|
|
function StrengthMainItem:InitEvent()
|
|
local function onClickHandler(target)
|
|
if target == self.goBtn then
|
|
-- GlobalEventSystem:Fire(EventName.CLOSE_STRENGTH_MAIN_VIEW)
|
|
if self.data then
|
|
OpenFun.Open(self.data.tagplace,self.data.sub_tag)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.goBtn, onClickHandler, 2)
|
|
end
|
|
|
|
function StrengthMainItem:SetData(type_id, data, index)
|
|
self.type_id = type_id or self.type_id
|
|
self.data = data or self.data
|
|
self.index = index or self.index
|
|
|
|
if self.is_loaded then
|
|
self.title.text = self.data.task_name
|
|
self.prise.text = self.data.task_des
|
|
|
|
if self.data.icon and self.data.icon ~= "" and self.data.icon ~= "0" and self.data.icon ~= 0 then
|
|
lua_resM:setImageSprite(self, self.iconImg, "activityIcon_asset", Trim(self.data.icon))
|
|
end
|
|
local is_unlock = false
|
|
if self.data.open_flag == 1 then
|
|
is_unlock = true
|
|
else
|
|
is_unlock = false
|
|
end
|
|
|
|
self:SetBasicShow(self.type_id, is_unlock, self.data.per, self.data.cur_num, self.data.max_num)
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function StrengthMainItem:SetBasicShow(id, is_unlock, progress, cur_num, max_num)
|
|
if id == 1 then
|
|
self.star_obj:SetActive(false)
|
|
self.bar:SetActive(true)
|
|
self.desc.gameObject:SetActive(true)
|
|
if cur_num and max_num then
|
|
self.num.transform.sizeDelta = co.TableXY(250,27)
|
|
self.num.transform.anchoredPosition = co.TableXYZ(0,0,0)
|
|
-- self.num.text = cur_num.."/"..max_num
|
|
if cur_num == "" then
|
|
self.num.text = Trim(self.data.process_des)
|
|
else
|
|
self.num.text = cur_num.."/"..Trim(self.data.process_des)
|
|
end
|
|
end
|
|
|
|
local color,str = "#ffffff", ""
|
|
if progress then
|
|
local progress_num = progress >= 100 and 100 or progress
|
|
-- 50%以下显示 急需提升,红色ff381e
|
|
-- 80以下显示 仍需努力,黄色e2d94a
|
|
-- 90以下显示 独立风骚,绿色93e725
|
|
-- 90以上一代宗师 橙色 df7904
|
|
local cfg = Config.Improveconstant
|
|
if cfg and cfg[1] and cfg[1].value then
|
|
local grade_list = ErlangParser:GetInstance():Parse(cfg[1].value)
|
|
table.sort(grade_list, function(a, b)
|
|
return tonumber(a[1]) < tonumber(b[1])
|
|
end)
|
|
for k,v in pairs(grade_list) do
|
|
if progress_num <= tonumber(v[2]) then
|
|
color = Config.ConfigStrength.StrongGradeWord[k].color
|
|
str = Config.ConfigStrength.StrongGradeWord[k].desc
|
|
break
|
|
end
|
|
end
|
|
end
|
|
-- if progress < 50 then
|
|
-- color = "#ff381e"
|
|
-- str = "继续提升"
|
|
-- elseif progress < 80 then
|
|
-- color = "#e2d94a"
|
|
-- str = "仍需努力"
|
|
-- elseif progress < 90 then
|
|
-- color = "#93e725"
|
|
-- str = "独领风骚"
|
|
-- else
|
|
-- color = "#df7904"
|
|
-- str = "一代宗师"
|
|
-- end
|
|
end
|
|
self.desc.text = HtmlColorTxt(str, color)
|
|
-- self.progress.fillAmount = progress/100
|
|
self.progress.fillAmount = 0
|
|
self.tween_list[1] = TweenLite.to(self, self.progress,TweenLite.UiAnimationType.FILLAMOUNT,progress/100,0.2)
|
|
else
|
|
self.bar:SetActive(false)
|
|
self.star_obj:SetActive(true)
|
|
self.desc.gameObject:SetActive(false)
|
|
self:SetStarsNum(self.data.task_lv)
|
|
end
|
|
|
|
if progress >= 100 or (not is_unlock) then
|
|
self.goBtn:SetActive(false)
|
|
self.condition.gameObject:SetActive(true)
|
|
if not is_unlock then
|
|
local is_huodong = false
|
|
local str = ErlangParser:GetInstance():Parse(self.data.condition)[1]
|
|
str = Trim(str)
|
|
for i,v in pairs(StrengthModel.Strengthen.IconNoticeList) do
|
|
if str == v then
|
|
is_huodong = true
|
|
end
|
|
end
|
|
|
|
if is_huodong and not self.data.IsNull then
|
|
if self.data.huodong_des then
|
|
if self.data.huodong_des == "over" then
|
|
-- self.condition.text = "<color=#f14041>已结束</color>"
|
|
self.complete:SetActive(true)
|
|
self.condition.gameObject:SetActive(false)
|
|
lua_resM:setImageSprite(self, self.textImg, "strength_asset", "bq_over_text", true)
|
|
else
|
|
self.complete:SetActive(false)
|
|
self.condition.text = "<color=#4eae1a>"..self.data.huodong_des.."</color>"
|
|
end
|
|
end
|
|
else
|
|
self.complete:SetActive(false)
|
|
self.condition.text = "<color=#f14041>"..self.data.task_nonopen.."</color>"
|
|
end
|
|
end
|
|
|
|
local str = Trim(self.data.task_nonopen)
|
|
local list = Split(str, "_")
|
|
if is_unlock and progress >= 100 then
|
|
-- self.condition.text = "<color=#4eae1a>已完成</color>"
|
|
self.complete:SetActive(true)
|
|
self.condition.gameObject:SetActive(false)
|
|
lua_resM:setImageSprite(self, self.textImg, "strength_asset", "bq_complete_text", true)
|
|
end
|
|
if list[1] == "level" then
|
|
local _str = string.format("%s%s%s", list[2], RoleManager.Instance.mainRoleInfo.level+1, list[4])
|
|
self.complete:SetActive(false)
|
|
self.condition.text = "<color=#f14041>".._str.."</color>"
|
|
end
|
|
else
|
|
self.goBtn:SetActive(true)
|
|
self.condition.gameObject:SetActive(false)
|
|
self.complete:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function StrengthMainItem:SetStarsNum(num)
|
|
for i= 1 , 5 do
|
|
if i<num+1 then
|
|
self.star[i]:SetActive(true)
|
|
else
|
|
self.star[i]:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function StrengthMainItem:__delete()
|
|
if #self.tween_list > 0 then
|
|
for i,v in ipairs(self.tween_list) do
|
|
TweenLite.Stop(v)
|
|
v = nil
|
|
end
|
|
end
|
|
self.tween_list = {}
|
|
end
|