源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

487 lines
20 KiB

EquipTipView = EquipTipView or BaseClass(BaseView)
function EquipTipView:__init()
self.base_file = "common"
self.layout_file = "EquipTipView"
self.layer_name = "Top"
self.close_mode = CloseMode.CloseDestroy
self.change_scene_close = true
self.use_background = true
self.click_bg_toClose = true
self.destroy_imm = true --是否一关闭就销毁
self:AddPreLoadList("common",{"EquipStoneItem", "EquipFuMoItem"})
self.model = EquipModel:getInstance()
self.fumo_item_list = {}
self.stone_item_list = {}
self.shenwen_label_list = {}
self.shenwen_value_list = {}
self.load_callback = function ( )
self:LoadSuccess()
self:AddEvents()
end
self.open_callback = function ( )
self:OpenCallBack()
end
self.destroy_callback = function ( )
self:DestroyCallback()
end
end
function EquipTipView:CenterView()
-- local width,height = self.container:GetVectorValue(WidgetProperty.Size)
-- self.is_show_soul = self.soul_con:GetBool(WidgetProperty.Visible)
-- if not is_show_soul then
-- width, _ = self.bg:GetVectorValue(WidgetProperty.Size)
-- end
-- local screen_view = Game.UI:GetScreenView()
-- self.container:SetVectorValue(WidgetProperty.Position, screen_view.x/2 - width/2, screen_view.y/2 - height/2)
-- self.mask:SetVectorValue(WidgetProperty.Size, screen_view.x, screen_view.y)
-- self.mask:SetVectorValue(WidgetProperty.Position, 0, 0)
end
function EquipTipView:LoadSuccess()
self.bg = self:GetChild("bg")
self.icon_con = self:GetChild("icon_con")
self.nameText = self:GetChild("nameText"):GetComponent("Text")
self.step_num = self:GetChild("step_num"):GetComponent("Text")
self.level = self:GetChild("level"):GetComponent("Text")
self.equip_pos = self:GetChild("equip_pos"):GetComponent("Text")
self.fight = self:GetChild("fight"):GetComponent("Text")
self.star_conta = self:GetChild("star_conta")
self.ScrollView = self:GetChild("ScrollView")
self.ScrollViewContent = self:GetChild("ScrollView/Viewport/Content")
self.ScrollViewViewport = self:GetChild("ScrollView/Viewport")
self.line1 = self:GetChild("ScrollView/Viewport/Content/line1")
self.line2 = self:GetChild("ScrollView/Viewport/Content/line2")
self.line3 = self:GetChild("ScrollView/Viewport/Content/line3")
self.line4 = self:GetChild("ScrollView/Viewport/Content/line4")
self.line5 = self:GetChild("ScrollView/Viewport/Content/line5")
self.basePro = self:GetChild("ScrollView/Viewport/Content/basePro"):GetComponent("Text")
self.basePro_trams = self:GetChild("ScrollView/Viewport/Content/basePro")
self.addPro = self:GetChild("ScrollView/Viewport/Content/addPro"):GetComponent("Text")
self.addPro_trams = self:GetChild("ScrollView/Viewport/Content/addPro")
self.stone_conta = self:GetChild("ScrollView/Viewport/Content/stone_conta")
self.fumo_conta = self:GetChild("ScrollView/Viewport/Content/fumo_conta")
self.shenwen_conta = self:GetChild("ScrollView/Viewport/Content/shenwen_conta").gameObject
self.shenwen_fight = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/shenwen_fight")
self.btn_conta = self:GetChild("btn_conta")
self.strengthBtn = self:GetChild("btn_conta/strengthBtn").gameObject
self.strengthBtn_dot = self:GetChild("btn_conta/strengthBtn/dot").gameObject
self.insertBtn = self:GetChild("btn_conta/insertBtn").gameObject
self.insertBtn_dot = self:GetChild("btn_conta/insertBtn/dot").gameObject
self.sell_conta = self:GetChild("sell_conta")
self.sell_icon = self:GetChild("sell_conta/icon"):GetComponent("Image")
self.price_label = self:GetChild("sell_conta/price_label"):GetComponent("Text")
for i = 1, 3 do
self.shenwen_label_list[i] = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/txt_soul_attr_" .. i):GetComponent("Text")
self.shenwen_value_list[i] = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/txt_soul_lv_" .. i):GetComponent("Text")
end
self.txt_soul_suit_attr = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/txt_soul_suit_attr"):GetComponent("Text")
self.txt_soul_suit_lv = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/txt_soul_suit_lv"):GetComponent("Text")
self.shenwen_fight = self:GetChild("ScrollView/Viewport/Content/shenwen_conta/shenwen_fight"):GetComponent("Text")
self.icon_item = AwardItem.New(self.icon_con, false)
self.icon_item:ChangeCountVisible(false)
-- self.nodes = {
-- "txt_name","txt_type","txt_lv","txt_power","txt_base_attr","txt_strong_attr","spr_item","spr_chuang","container","mask","bg","txt_sten","soul_con","txt_soul_attr_1","txt_soul_attr_2","txt_soul_attr_3","txt_soul_suit_attr","soul_power_con","txt_soul_lv_1","txt_soul_lv_2","txt_soul_lv_3","txt_soul_suit_lv"
-- }
-- for k,v in pairs(self.nodes) do
-- if v ~= "" then
-- self[v] = assert(self:GetChild(v), v)
-- end
-- end
-- self.spr_item = AwardItem.New(self.spr_item, false)
-- self.spr_item:SetMinEffectColor(BuildModel.MinShowEffectColor)
-- self.spr_item:setItemSize(90, 90)
-- self.txt_sten = UINumber.New(self.txt_sten, UINumber.Style[4])
-- self.txt_sten:setNumber("+0")
-- self:CenterView()
-- self.mask:SetBool(WidgetProperty.NeedMouse, true)
-- self.bg:SetBool(WidgetProperty.NeedMouse, true)
-- self.spr_star = {}
-- for i=1,5 do
-- self.spr_star[i] = self:GetChild("spr_star_"..i)
-- end
-- self.soul_power_con = PowerSubView.New(self.soul_power_con, PowerSubView.Type.Static)
-- self.txt_gem_name = {}
-- self.ep_lock_spr = {}
-- self.txt_gem_attr = {}
-- self.txt_refine = {}
-- self.txt_refine_num = {}
-- self.spr_refine = {}
-- for i=1,3 do
-- self.ep_lock_spr[i] = self:GetChild("ep_lock_spr"..i)
-- self.txt_gem_name[i] = self:GetChild("txt_gem_name"..i)
-- self.txt_gem_attr[i] = self:GetChild("txt_gem_attr"..i)
-- self.txt_refine[i] = self:GetChild("txt_refine"..i)
-- self.txt_refine_num[i] = self:GetChild("txt_refine_num"..i)
-- self.spr_refine[i] = self:GetChild("spr_refine"..i)
-- self.spr_refine[i]:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconGoodsPic(103000+i-1))
-- end
end
function EquipTipView:AddEvents()
local function onClickBtnHandler(target)
if target == self.strengthBtn then
GlobalEventSystem:Fire(EventName.OPEN_BUILD_VIEW, 1)
elseif target == self.insertBtn then
GlobalEventSystem:Fire(EventName.OPEN_BUILD_VIEW, 2)
end
self:Close()
end
AddClickEvent(self.strengthBtn, onClickBtnHandler)
AddClickEvent(self.insertBtn, onClickBtnHandler)
end
function EquipTipView:OpenCallBack()
self.isLoaded = true
self:UpdateView()
end
function EquipTipView:UpdateView( )
if not self.data then return end
local gvo=GoodsModel.Instance:GetGoodsBasicByTypeId(self.data.type_id)
local name = EquipModel:getInstance():GetEquipName(self.data.type_id)
-- self.txt_name:SetString(TextBoxProperty.Label, name)
self.nameText.text = name .. " " .. HtmlColorTxt("+" .. self.data.stren, ColorUtil:GetColor(gvo.color))
self.icon_item:SetData(self.data.type_id)
local lv
if self.is_other then
lv = self.data.level
else
lv = RoleManager.Instance.mainRoleInfo.level
end
self.level.text = lv
-- self.txt_lv:SetString(TextBoxProperty.Label, lv.." (随等级自动提升)")
-- self.txt_type:SetString(TextBoxProperty.Label, EquipModel.Name[self.data.cell])
self.equip_pos.text = EquipModel.Name[self.data.cell]
-- self:UpdateStar(self.data.stren)
local attr_info = Config.Equipconfig[self.data.type_id]
local base_attr_info = ErlangParser:GetInstance():Parse(attr_info.attr)
local attr_str = WordManager:GetAttributeStr(base_attr_info[1][1])
local addition_info = ErlangParser:GetInstance():Parse(attr_info.lev_attr)
local addition_value = addition_info[1][2]
base_attr_info[1][2] = base_attr_info[1][2]+addition_value*(lv-1)
local base_power_value = base_attr_info[1][2]
local base_power = HtmlColorTxt("+"..base_power_value, ColorUtil:GetColor(ColorUtil.GREEN))
-- self.txt_base_attr:SetString(TextBoxProperty.Label, attr_str..":"..base_power)
self.basePro.text = attr_str..""..base_power
local all_power = self.model:GetEquipPower(self.data.cell,self.is_other)
self.fight.text = all_power
-- self.txt_power:SetString(TextBoxProperty.Label, all_power)
-- self.txt_power:SetString(TextBoxProperty.Label, self.data.fight)
-- Config.Equipstrenconfig
local attr_str2, attr_value, attr_power = BuildModel:getInstance():GetStrengthAttrPower(self.data.type_id, self.data.stren)
attr_value = HtmlColorTxt("+"..attr_value, ColorUtil:GetColor(ColorUtil.GREEN))
self.addPro.text = attr_str2..""..attr_value
-- self.txt_strong_attr:SetString(TextBoxProperty.Label, attr_str2..":"..attr_value)
-- self.txt_sten:setNumber("+"..self.data.stren)
-- self.txt_strong_attr:SetString(TextBoxProperty.Label, "攻击:+0")
self:UpdateGemstones(self.data)
self:UpdateRefine(self.data)
self:UpdateShenWen(self.data)
self:CenterView()
self:HideOpenrateBtn(self.hide_btn)
end
--神纹
function EquipTipView:UpdateShenWen( data )
local info = data.soul_info
local is_zeror = true
local min_lv = 999
for k,v in pairs(info or {}) do
if v > 0 then
is_zeror = false
end
if v < min_lv then
min_lv = v
end
end
if info and not is_zeror then
-- self.soul_con:SetBool(WidgetProperty.Visible, true)
self.line5.gameObject:SetActive(true)
self.shenwen_conta:SetActive(true)
local attr_name_str_1 = HtmlColorTxt("攻击:", "#BDAA8E")
local attr_name_str_2 = HtmlColorTxt("生命:", "#BDAA8E")
local attr_name_str_3 = HtmlColorTxt("防御:", "#BDAA8E")
local soul_suit_lv_str = ""
local soul_attr_str_1 = ""
local soul_attr_str_2 = ""
local soul_attr_str_3 = ""
local sum_power = 0
local max_width = 0
local attr_lv = info[BuildModel.GemstoneType.Attack]
local attr_str, attr_value, power = BuildModel:getInstance():GetCastSoulAttrPower(self.data.cell, BuildModel.GemstoneType.Attack, attr_lv)
sum_power = sum_power + power
attr_value = HtmlColorTxt("+"..attr_value, ColorUtil.GREEN)
attr_lv = HtmlColorTxt(attr_lv, ColorUtil.GREEN)
soul_attr_str_1 = " (攻击神纹:"..attr_lv.."级)"
local attr_str = attr_name_str_1..attr_value
-- self.txt_soul_attr_1:SetString(TextBoxProperty.Label, attr_str)
self.shenwen_label_list[1].text = attr_str
-- local txt_width, _ = self.txt_soul_attr_1:GetVectorValue(TextBoxProperty.TextSize)
-- if txt_width > max_width then
-- max_width = txt_width
-- end
local attr_lv = info[BuildModel.GemstoneType.Life]
local attr_str, attr_value, power = BuildModel:getInstance():GetCastSoulAttrPower(self.data.cell, BuildModel.GemstoneType.Life, attr_lv)
sum_power = sum_power + power
attr_value = HtmlColorTxt("+"..attr_value, ColorUtil.GREEN)
attr_lv = HtmlColorTxt(attr_lv, ColorUtil.GREEN)
soul_attr_str_2 = " (生命神纹:"..attr_lv.."级)"
local attr_str = attr_name_str_2..attr_value
-- self.txt_soul_attr_2:SetString(TextBoxProperty.Label, attr_str)
self.shenwen_label_list[2].text = attr_str
-- local txt_width, _ = self.txt_soul_attr_2:GetVectorValue(TextBoxProperty.TextSize)
-- if txt_width > max_width then
-- max_width = txt_width
-- end
local attr_lv = info[BuildModel.GemstoneType.Defend]
local attr_str, attr_value, power = BuildModel:getInstance():GetCastSoulAttrPower(self.data.cell, BuildModel.GemstoneType.Defend, attr_lv)
sum_power = sum_power + power
attr_value = HtmlColorTxt("+"..attr_value, ColorUtil.GREEN)
attr_lv = HtmlColorTxt(attr_lv, ColorUtil.GREEN)
soul_attr_str_3 = " (防御神纹:"..attr_lv.."级)"
local attr_str = attr_name_str_3..attr_value
-- self.txt_soul_attr_3:SetString(TextBoxProperty.Label, attr_str)
self.shenwen_label_list[3].text = attr_str
-- local txt_width, _ = self.txt_soul_attr_3:GetVectorValue(TextBoxProperty.TextSize)
-- if txt_width > max_width then
-- max_width = txt_width
-- end
local cur_soul_suit_cfg = BuildModel:getInstance():GetCurSoulSuitCFG(self.data.type_id)
if cur_soul_suit_cfg then
local cur_attr_info = ErlangParser:GetInstance():Parse(cur_soul_suit_cfg.attr)
if cur_attr_info and cur_attr_info[1] then
cur_attr_info[1][2] = cur_attr_info[1][2]*min_lv
end
local cur_power = CalAttrPowerByBaseAttr(cur_attr_info)
sum_power = sum_power + cur_power
-- local attr_list = GetAttributeList(cur_attr_info)
if cur_attr_info and #cur_attr_info > 0 then
local attr_name_str_4 = HtmlColorTxt(WordManager:GetAttributeStr(tonumber(cur_attr_info[1][1])).."", "#BDAA8E")
attr_value = HtmlColorTxt("+"..cur_attr_info[1][2], ColorUtil.GREEN)
attr_lv = HtmlColorTxt(min_lv, ColorUtil.GREEN)
soul_suit_lv_str = " (神纹等级:"..attr_lv.."级)"
local attr_str = attr_name_str_4..attr_value
-- self.txt_soul_suit_attr:SetString(TextBoxProperty.Label, attr_str)
self.txt_soul_suit_attr.text = attr_str
-- local txt_width, _ = self.txt_soul_suit_attr:GetVectorValue(TextBoxProperty.TextSize)
-- if txt_width > max_width then
-- max_width = txt_width
-- end
end
end
-- self.soul_power_con:SetPowerValue(sum_power)
self.shenwen_fight.text = sum_power
self.shenwen_value_list[1].text = soul_attr_str_1
self.shenwen_value_list[2].text = soul_attr_str_2
self.shenwen_value_list[3].text = soul_attr_str_3
self.txt_soul_suit_lv.text = soul_suit_lv_str
-- self.txt_soul_lv_1:SetVectorL(WidgetProperty.Position, 10+max_width)
-- self.txt_soul_lv_1:SetString(TextBoxProperty.Label, soul_attr_str_1)
-- self.txt_soul_lv_2:SetVectorL(WidgetProperty.Position, 10+max_width)
-- self.txt_soul_lv_2:SetString(TextBoxProperty.Label, soul_attr_str_2)
-- self.txt_soul_lv_3:SetVectorL(WidgetProperty.Position, 10+max_width)
-- self.txt_soul_lv_3:SetString(TextBoxProperty.Label, soul_attr_str_3)
-- self.txt_soul_suit_lv:SetVectorL(WidgetProperty.Position, 10+max_width)
-- self.txt_soul_suit_lv:SetString(TextBoxProperty.Label, soul_suit_lv_str)
else
-- self.soul_con:SetBool(WidgetProperty.Visible, false)
self.line5.gameObject:SetActive(false)
self.shenwen_conta:SetActive(false)
end
end
function EquipTipView:UpdateGemstones( data )
-- local gem_info = data.gem_info
-- print("++++++++++EquipTipView=--------------:", TableSize(gem_info))
-- if not gem_info then return end
-- for i=1,3 do
-- local item = self.stone_item_list[i]
-- if item == nil then
-- item = EquipStoneItem.New(self.stone_conta)
-- self.stone_item_list[i] = item
-- end
-- print("-----------------stone-------:", gem_info[i])
-- item:SetData(gem_info[i], self.data.cell, i)
-- item:SetPosition(0, -38 * (i - 1))
-- local gem_type = Config.Equipgemconfig[self.data.cell.."@"..i].gem_type
-- local gem_type_str = "气血宝石"
-- if BuildModel.GemstoneTypeName[gem_type] then
-- gem_type_str = BuildModel.GemstoneTypeName[gem_type]
-- end
-- if gem_info[i] == 1 then
-- self.ep_lock_spr[i]:SetString(ImageBoxProperty.Source, "equip:ep_lock_spr")
-- self.txt_gem_name[i]:SetString(TextBoxProperty.Label, gem_type_str)
-- local need_strength = Config.Equipgemconfig[self.data.cell.."@"..i].need_stren
-- local condition_str = HtmlColorTxt("强化"..need_strength.."级开启", ColorUtil:getColorByName(ColorUtil.RED))
-- self.txt_gem_attr[i]:SetString(TextBoxProperty.Label, condition_str)
-- elseif gem_info[i] == 2 then
-- -- self.ep_lock_spr[i]:SetString(ImageBoxProperty.Source, "")
-- self.ep_lock_spr[i]:SetString(ImageBoxProperty.Source, "build:bd_diamod_"..i)
-- self.txt_gem_name[i]:SetString(TextBoxProperty.Label, gem_type_str)
-- self.txt_gem_attr[i]:SetString(TextBoxProperty.Label, "未镶嵌")
-- else
-- local gvo=GoodsModel.Instance:GetGoodsBasicByTypeId(gem_info[i])
-- local colorStr = ColorUtil:getGoodColor(gvo.color)
-- local name = HtmlColorTxt(gvo.goods_name, colorStr)
-- self.txt_gem_name[i]:SetString(TextBoxProperty.Label, name)
-- self.ep_lock_spr[i]:SetString(ImageBoxProperty.Source, "build:bd_diamod_"..i)
-- local attr_info = ErlangParser:GetInstance():Parse(Config.Gemcombineconfig[gem_info[i]].attr)
-- local attr_name = WordManager:GetAttributeStr(attr_info[1][1])
-- self.txt_gem_attr[i]:SetString(TextBoxProperty.Label, attr_name.."+"..attr_info[1][2])
-- self.txt_gem_attr[i]:SetString(TextBoxProperty.ColorStr, colorStr)
-- end
-- end
end
function EquipTipView:UpdateRefine( data )
local cost_info = Config.Equiprefineconfig[data.type_id]
if cost_info then
local cur_refine_info = data.refine_info
cost_info = ErlangParser:GetInstance():Parse(cost_info.cost_config)
for i=1,#cost_info do
-- local goods_id = BuildModel.Instance.RefineGoodsID[cost_info[i][1]]
-- -- print("EquipTipView 296 cost_info")
-- -- PrintTable(cost_info)
-- local cost_limit = cost_info[i][2]
local item = self.fumo_item_list[i]
if item == nil then
item = EquipFuMoItem.New(self.fumo_conta)
self.fumo_item_list[i] = item
end
item:SetData(cost_info[i], cur_refine_info, i)
item:SetPosition(0, -36 * (i - 1))
-- if cur_refine_info and cur_refine_info[i] then
-- --显示当前已经加了的属性值
-- local cur_cost_num = cur_refine_info[i].refine_num or 0
-- local attr_str = Config.Equiprefinematerialconfig[goods_id].attr
-- local attr_info = ErlangParser:GetInstance():Parse(attr_str)
-- -- print("Cat:BuildRefineView.lua [173][start] attr_info", attr_info,attr_str)
-- -- PrintTable(attr_info)
-- -- print("Cat:BuildRefineView.lua [173][end]")
-- -- self.txt_refine[i]:SetString(TextBoxProperty.Label, cur_cost_num)
-- self.txt_refine_num[i]:SetString(TextBoxProperty.Label, cur_cost_num.."/"..cost_limit)
-- else
-- -- self.txt_refine[i]:SetString(TextBoxProperty.Label, "0")
-- self.txt_refine_num[i]:SetString(TextBoxProperty.Label, "0/"..cost_limit)
-- end
end
else
-- print("Cat:EquipTipView.lua Error[UpdateRefine] equip_type,equip_type,:", equip_type,equip_type,cost_info,cur_refine_info)
end
-- local refine_info = data.refine_info
-- if not refine_info then return end
-- for i=1,3 do
-- local cost_info = Config.Equiprefinematerialconfig[refine_info[i].cost_id]
-- cost_info = ErlangParser:GetInstance():Parse(cost_info.attr)
-- self.txt_refine[i]:SetString(TextBoxProperty.Label, cost_info[1][2]*refine_info[i].costed_num)
-- cost_info = Config.Equiprefineconfig[data.type_id]
-- cost_info = ErlangParser:GetInstance():Parse(cost_info.cost_config)
-- local limit_num = cost_info[i][2]
-- self.txt_refine_num[i]:SetString(TextBoxProperty.Label, "("..refine_info[i].costed_num.."/"..limit_num..")")
-- end
end
function EquipTipView:UpdateStar( star_num )
if star_num > 15 then
star_num = 15
end
for i=1,5 do
if star_num >= 10+i then
self.spr_star[i]:SetString(ImageBoxProperty.Source, "equip:ep_star3")
elseif star_num >= 5+i then
self.spr_star[i]:SetString(ImageBoxProperty.Source, "equip:ep_star2")
elseif star_num >= i then
self.spr_star[i]:SetString(ImageBoxProperty.Source, "equip:ep_star1")
else
self.spr_star[i]:SetString(ImageBoxProperty.Source, "equip:ep_star_gray")
-- self.spr_star[i]:SetBool(WidgetProperty.Gray, true)
end
end
end
-- function EquipTipView:SetData( data )
-- self.data = data
-- if self.isLoaded then
-- self:UpdateView()
-- end
-- end
function EquipTipView:Open(data,is_other,hide_btn)
self.data = data
self.is_other = is_other or false
self.hide_btn = hide_btn or false
BaseView.Open(self)
end
function EquipTipView:DestroyCallback( )
if self.spr_item ~= nil then
self.spr_item:DeleteMe()
self.spr_item = nil
end
if self.icon_item ~= nil then
self.icon_item:DeleteMe()
self.icon_item = nil
end
if self.txt_sten ~= nil then
self.txt_sten:DeleteMe()
self.txt_sten = nil
end
if self.soul_power_con ~= nil then
self.soul_power_con:DeleteMe()
self.soul_power_con = nil
end
for i,v in ipairs(self.fumo_item_list) do
v:DeleteMe()
v = nil
end
self.fumo_item_list = {}
for i,v in ipairs(self.stone_item_list) do
v:DeleteMe()
v = nil
end
self.stone_item_list = {}
end
function EquipTipView:HideOpenrateBtn(bool)
self.btn_conta.gameObject:SetActive(not bool)
end