|
StarMapView = StarMapView or BaseClass(BaseView)
|
|
|
|
function StarMapView:__init()
|
|
self.base_file = "starMap"
|
|
self.layout_file = "StarMapView"
|
|
self.layer_name = "UI"
|
|
self.close_mode = CloseMode.CloseDestroy
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.append_to_ctl_queue = true
|
|
self.starMap_data = nil
|
|
self.star_point_list = {}
|
|
self.star_line_list = {}
|
|
self.prop_item_list = {}
|
|
self.select_index = 0
|
|
self.is_max = false
|
|
self.model = StarMapModel:getInstance()
|
|
|
|
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
|
|
self.open_callback = function()
|
|
self.model:Fire(StarMapModel.REQUEST_STAR_MAP_DATA)
|
|
|
|
local function load_end_func( )
|
|
self:SetGameObjectDepth(self.fight_con)
|
|
end
|
|
self:AddUIEffect("effect_tubiao_005", self.fight_effect, self.layer_name, Vector3(0,4,0),0.8, true,nil,nil,nil,load_end_func)
|
|
end
|
|
|
|
self.close_callback = function( )
|
|
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
|
|
GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
|
|
end
|
|
|
|
self.destroy_callback = function()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
function StarMapView:Remove()
|
|
if self.update_starmap_data_event_id then
|
|
self.model:UnBind(self.update_starmap_data_event_id)
|
|
self.update_starmap_data_event_id = nil
|
|
end
|
|
|
|
if self.click_point_item_event_id then
|
|
self.model:UnBind(self.click_point_item_event_id)
|
|
self.click_point_item_event_id = nil
|
|
end
|
|
|
|
if self.update_star_power_event_id then
|
|
self.model:UnBind(self.update_star_power_event_id)
|
|
self.update_star_power_event_id = nil
|
|
end
|
|
|
|
for k,v in pairs(self.star_point_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.star_point_list = {}
|
|
|
|
for k,v in pairs(self.star_line_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.star_line_list = {}
|
|
|
|
for k,v in pairs(self.prop_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.prop_item_list = {}
|
|
end
|
|
|
|
function StarMapView:LoadSuccess()
|
|
self.close_btn = self:GetChild("windowCloseBtn").gameObject
|
|
self.level_btn = self:GetChild("item_con/levelBtn").gameObject
|
|
self.point_con = self:GetChild("item_con/point_con")
|
|
self.line_con = self:GetChild("item_con/line_con")
|
|
self.bg = self:GetChild("item_con/bg"):GetComponent("Image")
|
|
self.star_bg = self:GetChild("item_con/star_bg"):GetComponent("Image")
|
|
self.combat = self:GetChild("fight_con/value"):GetComponent("Text")
|
|
self.fight_effect = self:GetChild("fight_effect")
|
|
self.fight_con = self:GetChild("fight_con").gameObject
|
|
self.name = self:GetChild("item_con/name_bg/name"):GetComponent("Text")
|
|
self.prop_con = self:GetChild("prop/Group")
|
|
self.need_num = self:GetChild("upgrate/need/num/value"):GetComponent("Text")
|
|
self.have_num = self:GetChild("upgrate/have/num/value"):GetComponent("Text")
|
|
self.help_btn = self:GetChild("help_btn").gameObject
|
|
self.upgrate_btn = self:GetChild("upgrateBtn").gameObject
|
|
self.upgrate_img = self:GetChild("upgrateBtn"):GetComponent("ImageExtend")
|
|
self.upgrate_label = self:GetChild("upgrateBtn/Text"):GetComponent("Text")
|
|
self.red_point = self:GetChild("upgrateBtn/redpoint").gameObject
|
|
self.tip = self:GetChild("tip").gameObject
|
|
self.tip_bg = self:GetChild("tip/ac_bg").gameObject
|
|
self.effect = self:GetChild("effect")
|
|
|
|
self.point_tip = self:GetChild("item_con/tip").gameObject
|
|
self.point_tip_bg = self:GetChild("item_con/tip/bg")
|
|
self.point_tip_value = self:GetChild("item_con/tip/value"):GetComponent("Text")
|
|
|
|
lua_resM:setOutsideImageSprite(self,self.bg,GameResPath.GetJpgImage("bg_starMap.jpg"),false)
|
|
|
|
self.touch = self:GetChild("touch").gameObject
|
|
end
|
|
|
|
|
|
function StarMapView:InitEvent()
|
|
local function onClickHandler(target,x,y)
|
|
if target == help_btn or target == self.tip_bg or target == self.upgrate_btn or self.level_btn or self.touch then
|
|
if self.select_index > 0 then
|
|
self.star_point_list[self.select_index]:SetSelect(false)
|
|
self.select_index = 0
|
|
self:SetPointTip(false)
|
|
end
|
|
end
|
|
|
|
if target == self.close_btn then
|
|
self:Close()
|
|
elseif target == self.help_btn then
|
|
self.tip:SetActive(true)
|
|
elseif target == self.tip_bg then
|
|
self.tip:SetActive(false)
|
|
elseif target == self.upgrate_btn then
|
|
self:ToUpgrate()
|
|
elseif target == self.level_btn then
|
|
local id = self.starMap_data.star_map_id
|
|
self.model:Fire(StarMapModel.OPEN_STAGE_VIEW,id,x,y)
|
|
end
|
|
|
|
end
|
|
AddClickEvent(self.close_btn,onClickHandler)
|
|
AddClickEvent(self.help_btn,onClickHandler)
|
|
AddClickEvent(self.tip_bg,onClickHandler)
|
|
AddClickEvent(self.upgrate_btn,onClickHandler)
|
|
AddClickEvent(self.level_btn,onClickHandler)
|
|
AddClickEvent(self.touch,onClickHandler)
|
|
|
|
local function onUpdateData(data)
|
|
if data == nil then return end
|
|
self:UpdateJinjie(self.starMap_data,data)
|
|
self.starMap_data = data
|
|
self:UpdateView()
|
|
self:UpdateStarLine()
|
|
self:UpdateStarPoint()
|
|
self:UpdatePropData()
|
|
self:UpdateRedPoint()
|
|
end
|
|
self.update_starmap_data_event_id = self.model:Bind(StarMapModel.UPDATE_STAR_MAP_DATA,onUpdateData)
|
|
|
|
local function onClickPoint(index,id)
|
|
if index == self.select_index then
|
|
self.star_point_list[index]:SetSelect(false)
|
|
self.select_index = 0
|
|
self:SetPointTip(false)
|
|
else
|
|
if self.select_index > 0 then
|
|
self.star_point_list[self.select_index]:SetSelect(false)
|
|
end
|
|
self.select_index = index
|
|
self.star_point_list[self.select_index]:SetSelect(true)
|
|
self:SetPointTip(true,index,id)
|
|
end
|
|
end
|
|
self.click_point_item_event_id = self.model:Bind(StarMapModel.CLICK_POINT_ITEM,onClickPoint)
|
|
|
|
local function onUpdateStarPower()
|
|
self:SetStarPower()
|
|
self:UpdateRedPoint()
|
|
end
|
|
self.update_star_power_event_id = self.model:Bind(StarMapModel.UPDATE_RED_POINT,onUpdateStarPower)
|
|
end
|
|
|
|
-- 是否进阶,进阶则播放特效
|
|
function StarMapView:UpdateJinjie(old_data,new_data)
|
|
if old_data == nil or new_data == nil then return end
|
|
local old_cfg = Config.Starmap[old_data.star_map_id+1]
|
|
local new_cfg = Config.Starmap[new_data.star_map_id+1]
|
|
if old_cfg == nil or new_cfg == nil then return end
|
|
if new_cfg.class_id > old_cfg.class_id or new_cfg.cons_id > old_cfg.cons_id then
|
|
self:AddUIEffect("UI_jinjiechenggong", self.effect,self.layer_name, nil, nil, false)
|
|
end
|
|
end
|
|
|
|
-- 更新界面信息
|
|
function StarMapView:UpdateView()
|
|
local data = self.model:GetStarMapData(self.starMap_data.star_map_id)
|
|
if data == nil then return end
|
|
lua_resM:setOutsideImageSprite(self,self.star_bg,GameResPath.GetStarMapImage("starMap_"..data.cons_id),false)
|
|
self:SetStarPower()
|
|
end
|
|
|
|
-- 星力信息
|
|
function StarMapView:SetStarPower()
|
|
local data = self.model:GetStarMapData(self.starMap_data.star_map_id)
|
|
if data == nil then return end
|
|
local next_cosume = self.model:GetStarPointCosume(self.starMap_data.star_map_id + 1)
|
|
local colorStr = ColorUtil.WHITE
|
|
if next_cosume == nil then
|
|
self.need_num.text = "已满级"
|
|
self.upgrate_img.gray = true
|
|
self.upgrate_label.text = "已满级"
|
|
self.is_max = true
|
|
else
|
|
self.need_num.text = next_cosume
|
|
colorStr = self.starMap_data.star_power >= next_cosume and ColorUtil.WHITE or ColorUtil.RED
|
|
end
|
|
self.have_num.text = string.format("<color=%s>%s</color>",colorStr,self.starMap_data.star_power)
|
|
self.name.text = Trim(data.cons_name).."·"..Language.getChineseTxt(data.class_id).."阶"
|
|
end
|
|
|
|
-- 更新星点连线信息
|
|
function StarMapView:UpdateStarLine()
|
|
local point_list = self.model:GetStarPointList(self.starMap_data.star_map_id)
|
|
if point_list == nil then return end
|
|
local len = #point_list -1 -- 线比点数量少1
|
|
local item
|
|
if #self.star_line_list < len then
|
|
local add_mount = len - #self.star_line_list
|
|
for i = 1,add_mount do
|
|
item = StarLineItem.New(self.line_con)
|
|
table.insert(self.star_line_list,item)
|
|
end
|
|
elseif #self.star_line_list > len then
|
|
local reduce_mount = #self.star_line_list - len
|
|
for i = #self.star_line_list - reduce_mount + 1,#self.star_line_list do
|
|
item = self.star_line_list[i]
|
|
item:SetVisible(false)
|
|
end
|
|
end
|
|
|
|
if len > 0 then
|
|
for i = 1,len do
|
|
item = self.star_line_list[i]
|
|
item:SetData(point_list[i])
|
|
if point_list[i].star_map_id < self.starMap_data.star_map_id then
|
|
item:SetLight(true)
|
|
else
|
|
item:SetLight(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
end
|
|
|
|
-- 更新星点信息
|
|
function StarMapView:UpdateStarPoint()
|
|
local point_list = self.model:GetStarPointList(self.starMap_data.star_map_id)
|
|
if point_list == nil then return end
|
|
local len = #point_list
|
|
local item
|
|
if #self.star_point_list < len then
|
|
local add_mount = len - #self.star_point_list
|
|
for i = 1,add_mount do
|
|
item = StarPointItem.New(self.point_con)
|
|
item:SetVisible(false)
|
|
table.insert(self.star_point_list,item)
|
|
end
|
|
elseif #self.star_point_list > len then
|
|
local reduce_mount = #self.star_point_list - len
|
|
for i = #self.star_point_list - reduce_mount + 1,#self.star_point_list do
|
|
item = self.star_point_list[i]
|
|
item:SetVisible(false)
|
|
end
|
|
end
|
|
|
|
if len > 0 then
|
|
for i = 1,len do
|
|
item = self.star_point_list[i]
|
|
item:SetData(point_list[i])
|
|
item:SetVisible(true)
|
|
if point_list[i].star_map_id <= self.starMap_data.star_map_id then
|
|
item:SetLight(true)
|
|
item:SetIsNext(false)
|
|
elseif point_list[i].star_map_id == self.starMap_data.star_map_id + 1 then
|
|
item:SetLight(false)
|
|
item:SetIsNext(true)
|
|
else
|
|
item:SetLight(false)
|
|
item:SetIsNext(false)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 更新属性信息
|
|
function StarMapView:UpdatePropData()
|
|
local prop_list = self.starMap_data.attr
|
|
table.sort(prop_list,function(a,b) return a.attr_type < b.attr_type end)
|
|
local next_list = self.model:GetStarPointProp(self.starMap_data.star_map_id + 1)
|
|
local len = #prop_list
|
|
if #self.prop_item_list < len then
|
|
local item = nil
|
|
local add_mount = len - #self.prop_item_list
|
|
for i = 1,add_mount do
|
|
item = StarMapPropItem.New(self.prop_con)
|
|
table.insert(self.prop_item_list,item)
|
|
end
|
|
elseif #self.prop_item_list > len then
|
|
local reduce_mount = #self.prop_item_list - len
|
|
for i = #self.prop_item_list - reduce_mount + 1,#self.prop_item_list do
|
|
item = self.prop_item_list[i]
|
|
item:SetVisible(false)
|
|
end
|
|
end
|
|
|
|
if len > 0 then
|
|
for i = 1,len do
|
|
local next_val = 0
|
|
item = self.prop_item_list[i]
|
|
-- 检查是否有需要显示增加值
|
|
if next_list ~= nil then
|
|
next_val = 0
|
|
for j = 1,#next_list do
|
|
if tonumber(next_list[j][1]) == prop_list[i].attr_type then
|
|
next_val = tonumber(next_list[j][2])
|
|
end
|
|
end
|
|
end
|
|
item:SetData(prop_list[i],next_val,i)
|
|
end
|
|
end
|
|
|
|
self.combat.text = self.model:GetCombat(prop_list)
|
|
end
|
|
|
|
-- 星点的属性tip
|
|
function StarMapView:SetPointTip(bool,index,id)
|
|
if bool == true then
|
|
local attr_list = self.model:GetStarPointProp(id)
|
|
local str = ""
|
|
local width = self.point_tip_bg.sizeDelta.x
|
|
if #attr_list >0 then
|
|
local endStr = ""
|
|
local attr_name = ""
|
|
local attr_value = ""
|
|
for i = 1,#attr_list do
|
|
if i == #attr_list then
|
|
endStr = ""
|
|
else
|
|
endStr = "\n"
|
|
end
|
|
attr_name = WordManager:GetProperties(tonumber(attr_list[i][1]))
|
|
attr_value = string.format("<color=%s> + %s</color>",ColorUtil.GREEN,WordManager:GetPropertyValue(tonumber(attr_list[i][1]),tonumber(attr_list[i][2])))
|
|
str = str .. attr_name..attr_value..endStr
|
|
end
|
|
end
|
|
self.point_tip_value.text = str
|
|
self.point_tip_bg.sizeDelta = Vector2(width,self.point_tip_value.preferredHeight + 30)
|
|
self.point_tip:SetActive(true)
|
|
|
|
local pos = self.star_point_list[index].transform.localPosition
|
|
self.point_tip.transform.localPosition = Vector3(pos.x+175,pos.y)
|
|
self.point_tip.transform:SetAsLastSibling()
|
|
else
|
|
self.point_tip:SetActive(false)
|
|
end
|
|
end
|
|
|
|
-- 星图升阶
|
|
function StarMapView:ToUpgrate()
|
|
if self.is_max == false then
|
|
local light_id = self.starMap_data.star_map_id + 1
|
|
self.model:Fire(StarMapModel.LIGHT_STAR_POINT,light_id)
|
|
self.point_tip:SetActive(false)
|
|
else
|
|
Message.show("星图已升阶到最高级!")
|
|
end
|
|
end
|
|
|
|
function StarMapView:UpdateRedPoint()
|
|
self.red_point:SetActive(self.model:HaveRedPoint())
|
|
end
|