-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 圣物系统主界面
|
|
-- *>
|
|
PsionicMainView = PsionicMainView or BaseClass(BaseView)
|
|
local PsionicMainView = PsionicMainView
|
|
local cos = math.cos
|
|
local sin = math.sin
|
|
local rad = math.rad
|
|
local clamp = Mathf.Clamp
|
|
|
|
function PsionicMainView:__init()
|
|
self.base_file = "psionic"
|
|
self.layout_file = "PsionicMainView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = G_USING_BG --全屏界面默认使用这个参数
|
|
self.hide_maincancas = true --全屏界面需要隐藏主UI
|
|
self.append_to_ctl_queue = true --是否要添加进界面堆栈
|
|
|
|
self.ignore_use_anim = true
|
|
self.use_show_anim = false
|
|
self.use_hide_anim = false
|
|
self.close_fog = true
|
|
self.change_scene_close = true
|
|
|
|
self.tab_index = PsionicConst.TabId.PArmor -- 页签索引
|
|
self.open_switch_index = PsionicConst.TabId.PArmor -- 跳转index
|
|
self.main_vo = RoleManager.Instance.mainRoleInfo
|
|
-- 界面列表
|
|
self.view_list = {}
|
|
-- 装备栏位置列表
|
|
self.equip_con_list = {}
|
|
self.main_equip_item_list = {} -- 圣物主页的圆盘上的装备节点
|
|
self.tab_equip_item_list = {} -- 圣物升级,洗练,觉醒等页签的左侧当tab节点用的装备节点
|
|
self.skill_con_list = {}
|
|
self.skill_item_list = {}
|
|
self.break_tab_list = {}
|
|
self.break_tab_index = 1
|
|
-- 装备临时数据相关
|
|
self.equip_last_select_slot = nil -- 上次选中的装备slot
|
|
self.skill_last_select_slot = nil -- 上次选中的技能slot
|
|
self.ps_target_wash_uid = nil -- 目标选中的洗练装备uid
|
|
self.cur_show_equip_goods_id = nil -- 当前查看的模型的装备id
|
|
self.armor_item_list = {}
|
|
self.equip_circle_radius = 0
|
|
self.advance_drag_y = 0
|
|
|
|
-- 模型信息数据相关
|
|
self.psionic_effect_res = nil -- 当前的圣环特效名
|
|
self.star_list = {}
|
|
|
|
self.model = PsionicModel:getInstance()
|
|
self.goods_model = GoodsModel:getInstance()
|
|
|
|
self.is_in_guide = false
|
|
|
|
self.load_callback = function ()
|
|
-- 保险起见,每次打开界面都要请求一次最新数据
|
|
self.model:Fire(PsionicConst.REQUEST_CCMD_EVENT, 13900)
|
|
self.model:Fire(PsionicConst.REQUEST_CCMD_EVENT, 13910)
|
|
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
self:UpdateTabRed()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.switch_callback = function(index)
|
|
self:SwitchTab(index)
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function PsionicMainView:Open(index, other_args)
|
|
self.open_switch_index = index
|
|
-- self.tab_index = index
|
|
if index == PsionicConst.TabId.PSkill then
|
|
self.skill_last_select_slot = other_args and other_args.slot or self.skill_last_select_slot
|
|
elseif index == PsionicConst.TabId.PWash then
|
|
self.ps_target_wash_uid = other_args and other_args.target_uid or self.ps_target_wash_uid
|
|
-- 如果存在需要选中的装备id,那要把洗练左侧页签定到第一个页签上
|
|
self.break_tab_index = self.ps_target_wash_uid and 1 or self.break_tab_index
|
|
else
|
|
self.equip_last_select_slot = other_args and other_args.slot or self.equip_last_select_slot
|
|
end
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function PsionicMainView:LoadSuccess()
|
|
local nodes = {
|
|
-- 右侧界面容器
|
|
"container",
|
|
"right",
|
|
-- 装备突破tab节点
|
|
"left/break_tab_con:obj",
|
|
"left/equip_tab_con:obj",
|
|
-- 左侧装备节点
|
|
"main/equip_con:obj", "main/equip_con/activate_effect_btn:obj", "main/equip_con/activate_effect_btn/activate_effect_btn_red:obj",
|
|
-- 装备模型信息节点
|
|
"main/equip_info_con:obj",
|
|
"main/equip_info_con/break_select_scroll:obj", "main/equip_info_con/break_select_scroll/Viewport/break_select_con",
|
|
"main/equip_info_con/break_select_bg:obj", -- 装备突破背包容器
|
|
"main/equip_info_con/equip_name:tmp", "main/equip_info_con/equip_name_bg", -- 装备名称及背景板
|
|
"main/equip_info_con/equip_star_con", "main/equip_info_con/equip_model_con", -- 装备星数容器和模型容器
|
|
"main/equip_info_con/equip_effect_con",
|
|
}
|
|
self:GetChildren(nodes)
|
|
-- 装备界面相关
|
|
-- 主页的圆盘上的装备和技能节点位置
|
|
for k = 1, 4 do
|
|
self.equip_con_list[k] = self:GetChild("main/equip_con/left_equip_con" .. k)
|
|
end
|
|
for k = 1, 4 do
|
|
self.skill_con_list[k] = self:GetChild("main/equip_con/right_equip_con" .. k)
|
|
end
|
|
|
|
local function select_callback(index)
|
|
self:SwitchTab(index)
|
|
end
|
|
local function close_callback()
|
|
self:Close()
|
|
end
|
|
self.tabWindowComponent = UITabWindow.New(self.transform, PsionicConst.TabData, select_callback, close_callback, self.background_wnd, nil, UITabWindow.SizeSmallHall, nil, nil, true)
|
|
self.tabWindowComponent:SetTitleText("圣物")
|
|
self.tabWindowComponent:ChangeShowFlag("Psionic")
|
|
self:AddToStageHandler()
|
|
end
|
|
|
|
function PsionicMainView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.activate_effect_btn_obj then
|
|
self.model:Fire(PsionicConst.OPEN_PSIONIC_EFFECT_EQUIP_VIEW, true)
|
|
end
|
|
end
|
|
AddClickEvent(self.activate_effect_btn_obj, click_event)
|
|
-- 圣物装备突破成功后,要重新更新圣物装备进阶界面信息
|
|
local function update_advance_view(slot)
|
|
self:SelectMainRoleArmorItem(slot, true)
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.UPDATE_ACVANCE_VIEW, update_advance_view)
|
|
|
|
local function update_psionic_tab_red(tab_id)
|
|
self:UpdateTabRed(tab_id)
|
|
if tab_id and tab_id == PsionicConst.TabId.PArmor then
|
|
self:UpdateEffectBtnRed()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.UPDATE_RED_BY_TABID, update_psionic_tab_red)
|
|
|
|
-- 特殊事件:在洗练界面中显示出所有的item节点,并取消对左侧装备的选中
|
|
local function on_show_all_item_in_refact_view()
|
|
self:OnClickEquipItemCallback(nil)
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.SHOW_ALL_ITEMS_IN_REFACTVIEW, on_show_all_item_in_refact_view)
|
|
|
|
local function update_break_succeed(uid, slot) -- 圣物装备升星成功后,刷新当前选中的装备数据 uid:装备唯一id
|
|
self.ps_target_wash_uid = uid
|
|
self:UpdateBreakEquipItem(self.break_tab_index, true, true)
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.UPDATE_EQUIP_BREAK_SUCCEED, update_break_succeed)
|
|
|
|
local function play_effect(type)
|
|
if type then
|
|
local function call_back( )
|
|
self.showing_break_level_effect = false
|
|
self.showing_break_equip_effect = false
|
|
self.showing_skill_effect = false
|
|
end
|
|
if type == PsionicConst.EffectType.BreakLevel then -- 槽位等级突破成功
|
|
if not self.showing_break_level_effect then
|
|
self:ClearUIEffect(self.equip_effect_con)
|
|
self:AddUIEffect("ui_jinjie", self.equip_effect_con, self.layer_name, Vector3(25, -200, 0), 1, false, 1.5, nil, call_back)
|
|
self.showing_break_level_effect = true
|
|
end
|
|
elseif type == PsionicConst.EffectType.BreakEquip then -- 装备升星成功
|
|
if not self.showing_break_equip_effect then
|
|
self:ClearUIEffect(self.equip_effect_con)
|
|
self:AddUIEffect("ui_jinjie", self.equip_effect_con, self.layer_name, Vector3(25, -78, 0), 1, false, 1.5, nil, call_back)
|
|
self.showing_break_equip_effect = true
|
|
end
|
|
elseif type == PsionicConst.EffectType.Skill then -- 技能升级成功
|
|
if not self.showing_skill_effect then
|
|
self:ClearUIEffect(self.equip_effect_con)
|
|
self:AddUIEffect("ui_jinjie", self.equip_effect_con, self.layer_name, Vector3(25, -200, 0), 1, false, 1.5, nil, call_back)
|
|
self.showing_skill_effect = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.PLAY_EFFECT, play_effect)
|
|
|
|
local function update_equip_data() -- 当玩家当前的圣魂装备发生变动,则需要检测圣魂特效是否要变动
|
|
self.model:CheckPsionicEffectStage() -- goodsmodel的检测搬过来这边
|
|
end
|
|
self:BindEvent(self.model, PsionicConst.UPDATE_PISIONIC_EQUIP_ARMOR, update_equip_data)
|
|
|
|
local function onGuideTrigger()
|
|
self:AddToStageHandler()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
|
|
end
|
|
|
|
function PsionicMainView:OpenSuccess()
|
|
-- 更新主角模型信息
|
|
-- self:UpdateRoleData()
|
|
self:UpdateBreakTabItem()
|
|
self:UpdateEffectBtnRed()
|
|
self:SwitchTab(self.open_switch_index)
|
|
end
|
|
|
|
-- 针对界面隐藏时的回调处理
|
|
function PsionicMainView:HideChangeCall(show)
|
|
if show then
|
|
-- 修复从其他界面切换回圣物抽奖界面时模型动画的错误
|
|
if self.tab_index == PsionicConst.TabId.PDataDig and self.view_list[self.tab_index].is_loaded then -- 圣物寻宝
|
|
self.view_list[self.tab_index]:StartTransCGAlphaAnim(true)
|
|
end
|
|
end
|
|
end
|
|
|
|
function PsionicMainView:UpdateView()
|
|
local bg_res = "default_bg_6"
|
|
if self.tab_index == PsionicConst.TabId.PArmor then -- 数码装甲
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicArmorView.New(self.right)
|
|
self.view_list[self.tab_index]:SetAnchoredPosition(-371, 0)
|
|
-- 更新左侧装备和技能节点数据
|
|
self:UpdatePsionicEquipAndSkillData()
|
|
end
|
|
bg_res = "ps_lv_bg"
|
|
-- self:CheckPsionicEquipArmorItem(PsionicConst.TabId.PArmor)
|
|
elseif self.tab_index == PsionicConst.TabId.PAdvance then -- 圣物进阶
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicAdvanceView.New(self.right)
|
|
self.view_list[self.tab_index]:SetAnchoredPosition(-348.5, 0)
|
|
end
|
|
bg_res = "ps_advance_bg"
|
|
-- 每次切换都要选中一件装备
|
|
self:SelectMainRoleArmorItem()
|
|
-- 创建道具节点
|
|
self:CheckPsionicEquipArmorItem(PsionicConst.TabId.PAdvance)
|
|
elseif self.tab_index == PsionicConst.TabId.PBreak then -- 圣物突破
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicAdvanceBreakView.New(self.right)
|
|
self.view_list[self.tab_index]:SetAnchoredPosition(-348, 0)
|
|
end
|
|
bg_res = "ps_adv_break_bg"
|
|
self.cur_selected_break_goodsVo = nil
|
|
self:UpdateBreakEquipItem(self.break_tab_index, true)
|
|
elseif self.tab_index == PsionicConst.TabId.PWash then -- 圣物洗练
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicWashView.New(self.right)
|
|
self.view_list[self.tab_index]:SetAnchoredPosition(-348, 0)
|
|
end
|
|
bg_res = "ps_advance_bg"
|
|
-- 每次切换都要选中一件装备
|
|
self:SelectMainRoleArmorItem()
|
|
-- 创建道具节点
|
|
self:CheckPsionicEquipArmorItem(PsionicConst.TabId.PWash)
|
|
elseif self.tab_index == PsionicConst.TabId.PSkill then -- 圣物觉醒
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicSkillView.New(self.right)
|
|
self.view_list[self.tab_index]:SetAnchoredPosition(-348, 0)
|
|
end
|
|
bg_res = "ps_advance_bg"
|
|
-- 每次切换都要选中一个技能
|
|
self:SelectCircleItemSkill()
|
|
-- 创建道具节点
|
|
self:CheckPsionicEquipArmorItem(PsionicConst.TabId.PSkill)
|
|
elseif self.tab_index == PsionicConst.TabId.PDataDig then -- 圣物寻宝
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicDrawView.New(self.container)
|
|
end
|
|
bg_res = "ps_draw_bg"
|
|
elseif self.tab_index == PsionicConst.TabId.PExchange then -- 圣物兑换
|
|
if not self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index] = PsionicExchangeView.New(self.container)
|
|
end
|
|
end
|
|
self:PopUpChild(self.view_list[self.tab_index])
|
|
-- 寻宝界面不要打开物品飞入的表现
|
|
self.model:SetPsionicShowFlyGoods(self.tab_index ~= PsionicConst.TabId.PDataDig)
|
|
self.tabWindowComponent:SetUIBack(
|
|
{
|
|
target = self,
|
|
bg1 = GameResPath.GetViewBigBg(bg_res)
|
|
})
|
|
-- 控制界面节点的开关
|
|
self:ShowPsionicInfoNodeCon()
|
|
end
|
|
|
|
function PsionicMainView:SwitchTab( index, other_args )
|
|
if index == PsionicConst.TabId.PAdvance
|
|
or index == PsionicConst.TabId.PWash
|
|
or index == PsionicConst.TabId.PSkill then -- 装甲进阶和重构
|
|
-- 如果当前一件圣物装备都没有穿戴则屏蔽该界面
|
|
local equip_list = self.goods_model:GetPsionicEquipList()
|
|
if IsTableEmpty(equip_list) then
|
|
Message.show("未穿戴圣物", "fault")
|
|
self:SwitchTab(self.tab_index)
|
|
return
|
|
end
|
|
-- 获取目标装备品质
|
|
local require_cfg = PsionicConst.RequireEquipColor[index] -- 切换需求前端配置
|
|
local has_advancable_equipment
|
|
for k, v in pairs(equip_list) do
|
|
-- 如果存在目标品质以上的圣物装备,则可以进入相关界面
|
|
if v.color >= require_cfg.color then
|
|
has_advancable_equipment = true
|
|
break
|
|
end
|
|
end
|
|
if not has_advancable_equipment then
|
|
local str = string.format("穿戴%s品质以上圣物才可进阶!", require_cfg.str)
|
|
Message.show(str, "fault")
|
|
self:SwitchTab(self.tab_index)
|
|
return
|
|
end
|
|
elseif index == PsionicConst.TabId.PBreak then -- 圣物突破
|
|
local equip_list = self.goods_model:GetPsionicEquipList()
|
|
local bag_list = self.model:GetPsionicBagData()
|
|
local has_can_break_equip = false
|
|
for k, v in ipairs(equip_list) do
|
|
if v.next ~= 0 then -- 检查穿戴装备突破后的装备id不是0,下为背包装备的判断
|
|
has_can_break_equip = true
|
|
break
|
|
end
|
|
end
|
|
if not has_can_break_equip then
|
|
for k, v in pairs(bag_list) do
|
|
if v.next ~= 0 then
|
|
has_can_break_equip = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
if IsTableEmpty(equip_list) and IsTableEmpty(bag_list) or not has_can_break_equip then
|
|
Message.show("未持有可进化的圣物", "fault")
|
|
self:SwitchTab(self.tab_index)
|
|
return
|
|
end
|
|
end
|
|
if index == PsionicConst.TabId.PSkill then
|
|
self.skill_last_select_slot = other_args and other_args.slot or self.skill_last_select_slot
|
|
elseif index == PsionicConst.TabId.PWash then
|
|
self.ps_target_wash_uid = other_args and other_args.target_uid or self.ps_target_wash_uid
|
|
-- 如果存在需要选中的装备id,那要把洗练左侧页签定到第一个页签上
|
|
self.break_tab_index = self.ps_target_wash_uid and 1 or self.break_tab_index
|
|
else
|
|
self.equip_last_select_slot = other_args and other_args.slot or self.equip_last_select_slot
|
|
end
|
|
self.tab_index = index
|
|
self:DoOpenAni(self.tab_index)
|
|
--设置页签索引值切换主页面
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:SetTabBarIndex(self.tab_index)
|
|
end
|
|
self:UpdateView()
|
|
end
|
|
|
|
-- 创建装备升星页签节点
|
|
function PsionicMainView:UpdateBreakTabItem( )
|
|
local function break_tab_clickCallback(index)
|
|
for k, v in ipairs(self.break_tab_list) do
|
|
v:SetSelected(k == index)
|
|
end
|
|
self.break_tab_index = index
|
|
self:UpdateBreakEquipItem(self.break_tab_index)
|
|
end
|
|
for i = 1, 5 do
|
|
self.break_tab_list[i] = self.break_tab_list[i] or PsionicAdvanceBreakTabItem.New(self.break_tab_con)
|
|
self.break_tab_list[i]:SetAnchoredPosition(0, - (i-1) * 55)
|
|
self.break_tab_list[i]:SetData(i, break_tab_clickCallback)
|
|
end
|
|
break_tab_clickCallback(self.break_tab_index or 1)
|
|
end
|
|
|
|
-- 更新选中的圣物装备信息
|
|
function PsionicMainView:UpdateSelectedArmorInfo(goods_vo, star_effect)
|
|
if goods_vo and not goods_vo.is_empty and (not self.cur_show_equip_goods_id or self.cur_show_equip_goods_id ~= goods_vo.goods_id)then
|
|
-- 加载名称
|
|
self.equip_name_tmp.text = GoodsModel:getInstance():getGoodsName(goods_vo.type_id)
|
|
local star_num = goods_vo.star
|
|
-- 加载星数
|
|
for k, v in pairs(self.star_list) do
|
|
v.gameObject:SetActive(false)
|
|
end
|
|
local offset_x = (self.equip_star_con.sizeDelta.x - star_num * 27) / 2 + 2
|
|
for i = 1, star_num do
|
|
self.star_list[i] = self.star_list[i] or UiFactory.createChild(self.equip_star_con, UIType.Image2, "star" .. i)
|
|
self.star_list[i].gameObject:SetActive(true)
|
|
SetAnchoredPosition(self.star_list[i].transform, (i-1) * 27 + offset_x, 0)
|
|
lua_resM:setImageSprite(self, self.star_list[i]:GetComponent("Image"), "psionic_asset", "ps_star_1" , true)
|
|
self:ClearUIEffect(self.star_list[i].transform)
|
|
if star_effect and i == star_num then -- 需要星星动画时
|
|
self:AddUIEffect("ui_jinjiestar", self.star_list[i].transform, self.layer_name, Vector3(13, -12, 0), 1, false)
|
|
end
|
|
end
|
|
-- 加载圣物模型
|
|
local model_data = PsionicConst.SlotModel[goods_vo.subtype]
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.equip_model_con,
|
|
fashion_type = FuncOpenModel.TypeId.OtherGoods,
|
|
raycast_size = Vector2(0,0),
|
|
rotate = model_data.rotate,
|
|
scale = model_data.scale,
|
|
figure_id = model_data.model,
|
|
position = model_data.pos,
|
|
layer_name = self.layer_name,
|
|
ui_model_type = UIModelCommon.ModelType.Model,
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
self.cur_show_equip_goods_id = goods_vo.goods_id
|
|
end
|
|
end
|
|
-- 更新圣物进化的背包节点 index:对应breaktab的index 1表示全部 2~5代表槽位(slot)4~7的映射 not_scroll_back:是否刷新时容器滚回初始位置
|
|
function PsionicMainView:UpdateBreakEquipItem(index, reload_equip_item, not_scroll_back)
|
|
-- 加载背包道具数据
|
|
-- 是否需要定位到目标装备
|
|
local target_item_index = nil
|
|
not_scroll_back = not_scroll_back or false
|
|
if not self.break_equip_item or reload_equip_item then
|
|
self.break_equip_item = self.model:GetPsionicBagData(true) -- 该方法会抽出背包圣物装备数据创建新表返回,true为按品质降序排序
|
|
for k = #self.break_equip_item, 1, -1 do -- 移除无法突破的装备
|
|
if self.break_equip_item[k].next == 0
|
|
and self.break_equip_item[k].goods_id ~= self.ps_target_wash_uid then
|
|
table.remove(self.break_equip_item, k)
|
|
end
|
|
end
|
|
end
|
|
-- 预先加载穿戴装备(需置顶)
|
|
local data = {}
|
|
local equip_data = nil
|
|
if index == 1 then
|
|
for k, v in ipairs(self.break_equip_item) do
|
|
data[#data+1] = v
|
|
end
|
|
-- 倒序插入已穿戴的装备
|
|
for i = 7, 3, -1 do
|
|
equip_data = self.goods_model:GetPsionicEquipBySlot(i)
|
|
if equip_data and equip_data.next ~= 0 then
|
|
table.insert(data, 1, equip_data)
|
|
end
|
|
end
|
|
else
|
|
equip_data = self.goods_model:GetPsionicEquipBySlot(index + 2)
|
|
if equip_data and equip_data.next ~= 0 then
|
|
table.insert(data, equip_data)
|
|
end
|
|
-- 插入这个槽位的装备数据
|
|
for k, v in ipairs(self.break_equip_item) do
|
|
if v.subtype == index + 2 then
|
|
data[#data+1] = v
|
|
end
|
|
end
|
|
end
|
|
-- 获取目标装备index
|
|
-- 新增修改:新增红点规则 每个槽位按照【当前穿戴】-【装备品质】-【装备星级】的排序规则的可突破的第一件装备给突破红点
|
|
-- 当前的装备列表顺序就是以【当前穿戴】-【装备品质】-【装备星级】的规则了,所以遇到条件满足的装备数据就将id加入其中
|
|
local slot_break_red_equip_list = {}
|
|
-- 如果没有目标选中的index,则定位到数据列表最靠前的可以进化的装备上,下面这个列表缓存存在进化红点的装备index,视情况拿出第一个数据来定位
|
|
local temp_index_list = {}
|
|
for k, v in ipairs(data) do
|
|
if self.ps_target_wash_uid and v.goods_id == self.ps_target_wash_uid then
|
|
target_item_index = k
|
|
-- break
|
|
end
|
|
-- 获取缓存下来的突破红点
|
|
if not slot_break_red_equip_list[v.subtype] then
|
|
local break_bool = self.model:GetPsionicBreakEquipRed(v.goods_id)
|
|
if break_bool then
|
|
slot_break_red_equip_list[v.subtype] = v.goods_id
|
|
temp_index_list[#temp_index_list + 1] = k
|
|
end
|
|
end
|
|
end
|
|
-- 当前定位的节点是否是可突破的节点
|
|
local is_cur_target_index_in_index_list = false
|
|
for k, v in ipairs(temp_index_list) do
|
|
is_cur_target_index_in_index_list = is_cur_target_index_in_index_list or (target_item_index and target_item_index == v)
|
|
end
|
|
if not target_item_index or not is_cur_target_index_in_index_list then
|
|
target_item_index = temp_index_list[1] or nil
|
|
end
|
|
-- 补全格子
|
|
local empty_data = {is_empty = true}
|
|
local data_length = #data
|
|
local need_full_num
|
|
if data_length < 12 then
|
|
need_full_num = 12
|
|
elseif data_length % 6 ~= 0 then
|
|
-- 有空白格子,补全成无数据格子
|
|
need_full_num = math.ceil(data_length / 6) * 6
|
|
end
|
|
if need_full_num then
|
|
for i = data_length + 1, need_full_num do
|
|
data[i] = empty_data
|
|
end
|
|
end
|
|
local callback = function(data)
|
|
-- 更新展示的装备信息和模型
|
|
self:UpdateSelectedArmorInfo(data, self.ps_target_wash_uid and true or false)
|
|
-- 更新突破界面的材料需求
|
|
self:UpdateBreakViewData(data, self.ps_target_wash_uid and true or false, slot_break_red_equip_list)
|
|
-- 更新选中
|
|
self.break_item_creator:IterateItems(function( item, i )
|
|
item:SetSelected(item.data.goods_id == data.goods_id)
|
|
end)
|
|
self.cur_selected_break_goodsVo = data
|
|
end
|
|
self.break_item_creator = self.break_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = data,
|
|
item_con = self.break_select_con,
|
|
scroll_view = self.break_select_scroll,
|
|
item_class = PsionicArmorItem,
|
|
item_width = 62,
|
|
item_height = 62,
|
|
start_x = 15.5,
|
|
start_y = -13.5,
|
|
space_x = 19,
|
|
space_y = 15,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
is_scroll_back_on_update = not not_scroll_back,
|
|
on_update_item = function(item, i, v)
|
|
item:SetItemScale(0.795)
|
|
item:SetBreakSlotRedEquipList(slot_break_red_equip_list)
|
|
item:SetData(v, PsionicConst.ArmorItemFlag.Break, callback)
|
|
if self.cur_selected_break_goodsVo then
|
|
item:SetSelected(v.goods_id == self.cur_selected_break_goodsVo.goods_id)
|
|
end
|
|
end,
|
|
final_callback = function()
|
|
if not_scroll_back and target_item_index then
|
|
self.break_item_creator:ScrollToItem(target_item_index, -50)
|
|
end
|
|
end,
|
|
}
|
|
self.break_item_creator:UpdateItems(info)
|
|
callback(target_item_index and data[target_item_index] or (self.cur_selected_break_goodsVo or data[1]))
|
|
-- 清空目标选中的uid
|
|
self.ps_target_wash_uid = nil
|
|
end
|
|
-- 更新突破界面的信息
|
|
function PsionicMainView:UpdateBreakViewData(goods_vo, need_show_effect, slot_break_red_equip_list)
|
|
if self.tab_index == PsionicConst.TabId.PBreak
|
|
and self.view_list[self.tab_index] then
|
|
self.view_list[self.tab_index]:SetData(goods_vo, need_show_effect, slot_break_red_equip_list)
|
|
end
|
|
end
|
|
-- 加载玩家佩戴的圣物装备
|
|
function PsionicMainView:CheckPsionicEquipArmorItem(show_flag)
|
|
if IsTableEmpty(self.tab_equip_item_list) then
|
|
self:UpdatePsionicEquipArmorData(show_flag)
|
|
else
|
|
self:ChangePsionicEquipArmorShowFlag(show_flag)
|
|
end
|
|
end
|
|
-- show_flag : 根据打开的页签不同,调整节点的点击回调逻辑
|
|
function PsionicMainView:UpdatePsionicEquipArmorData(show_flag)
|
|
-- 加载4个位置的装备,
|
|
-- 以位置做key,后面更新装备内容的时候直接通过装备位置来获取节点
|
|
local item
|
|
local function equip_callback(slot)
|
|
-- 更新进阶界面中的装备信息
|
|
self:SelectMainRoleArmorItem(slot)
|
|
end
|
|
local function skill_callback(slot)
|
|
-- 更新进阶界面中的技能信息
|
|
self:SelectCircleItemSkill(slot)
|
|
end
|
|
for i = 1, 4 do
|
|
item = self.tab_equip_item_list[i]
|
|
if not item then
|
|
-- item = PsionicArmorEquipItem.New(self.equip_con_list[i], nil, self.layer_name)
|
|
item = PsionicArmorEquipItem.New(self.equip_tab_con, nil, self.layer_name)
|
|
self.tab_equip_item_list[i] = item
|
|
end
|
|
item:SetAnchoredPosition(0, 179 - (i - 1) * 122)
|
|
item:SetData(i, PsionicConst.ArmorItemFlag.Equiped, show_flag, equip_callback, skill_callback)
|
|
if show_flag == PsionicConst.TabId.PSkill then
|
|
if self.skill_last_select_slot then
|
|
item:SetSelected(i == (self.skill_last_select_slot - 3))
|
|
end
|
|
else
|
|
if self.equip_last_select_slot then
|
|
item:SetSelected(i == (self.equip_last_select_slot - 3))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
function PsionicMainView:ChangePsionicEquipArmorShowFlag(show_flag)
|
|
for k, v in ipairs(self.tab_equip_item_list) do
|
|
v:ChangeShowFlag(show_flag)
|
|
end
|
|
end
|
|
-- 对左侧装备节点的点击的回调
|
|
function PsionicMainView:OnClickEquipItemCallback(slot)
|
|
if IsTableEmpty(self.tab_equip_item_list) then
|
|
return
|
|
end
|
|
|
|
slot = slot and slot - 3 or nil -- 槽位即道具子id,从4开始,需要-3映射
|
|
for k, v in pairs(self.tab_equip_item_list) do
|
|
v:SetSelected(k == slot)
|
|
end
|
|
end
|
|
|
|
-- 切换到进阶或重构界面时,需要自动选中一件装备
|
|
function PsionicMainView:SelectMainRoleArmorItem(slot, dont_refresh)
|
|
local data
|
|
local require_cfg = PsionicConst.RequireEquipColor[self.tab_index]
|
|
local get_data = false
|
|
-- print("Saber:PsionicMainView [396] self.tab_index: ",self.tab_index)
|
|
local function check_color(data)
|
|
if data and require_cfg.color ~= 0 then
|
|
return data.color >= require_cfg.color
|
|
end
|
|
return data and true or false
|
|
end
|
|
if slot then -- 指定了槽位,就需要优先寻找槽位的装备
|
|
data = self.goods_model:GetPsionicEquipBySlot(slot)
|
|
get_data = check_color(data)
|
|
if get_data then
|
|
self.equip_last_select_slot = slot
|
|
end
|
|
end
|
|
if not get_data then
|
|
if self.equip_last_select_slot then -- 存在上次选中的装备
|
|
data = self.goods_model:GetPsionicEquipBySlot(self.equip_last_select_slot)
|
|
get_data = check_color(data)
|
|
end
|
|
if not get_data then -- 上次选中的装备不见了,则需要重新自动定位
|
|
for i = 1, 4 do
|
|
data = self.goods_model:GetPsionicEquipBySlot(i + 3) -- 槽位即道具子id,从4开始,需要+3映射
|
|
get_data = check_color(data)
|
|
if get_data then
|
|
self.equip_last_select_slot = i + 3
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if get_data and data then
|
|
if (self.tab_index == PsionicConst.TabId.PAdvance
|
|
or self.tab_index == PsionicConst.TabId.PWash)
|
|
and self.view_list[self.tab_index] then -- 装甲进阶
|
|
-- 重新设置装备进阶界面数据
|
|
self.view_list[self.tab_index]:SetData(data)
|
|
end
|
|
-- 触发一次对符合条件的节点的点击
|
|
if not dont_refresh or self.tab_index == PsionicConst.TabId.PWash then
|
|
self:OnClickEquipItemCallback(self.equip_last_select_slot)
|
|
end
|
|
self:UpdateSelectedArmorInfo(data)
|
|
end
|
|
return data, self.equip_last_select_slot
|
|
end
|
|
-- 修改左侧装备的展示类型
|
|
-- function PsionicMainView:ChangeEquipShowFlag(flag)
|
|
-- for k, v in pairs(self.armor_item_list) do
|
|
-- v:SetEquipShowFlag(flag)
|
|
-- end
|
|
-- end
|
|
|
|
-- 切换到技能界面时,需要自动选中一个已激活技能
|
|
function PsionicMainView:SelectCircleItemSkill(slot, dont_refresh)
|
|
local skill_data, get_data
|
|
if slot then -- 指定了槽位,就需要优先寻找槽位的装备的技能
|
|
skill_data = self.model:GetPsionicSlotData(slot) -- 存在技能数据,代表已经激活
|
|
if skill_data and skill_data.skill_lv > 0 then
|
|
self.skill_last_select_slot = slot
|
|
get_data = true
|
|
end
|
|
end
|
|
if not get_data then
|
|
if self.skill_last_select_slot then -- 存在上次选中的装备,查找这件装备上的技能
|
|
skill_data = self.model:GetPsionicSlotData(self.skill_last_select_slot)
|
|
get_data = skill_data and skill_data.skill_lv > 0
|
|
end
|
|
if not get_data then -- 上次选中的装备不见了,则需要重新自动定位,找到有技能的槽位
|
|
for i = 1, 4 do
|
|
skill_data = self.model:GetPsionicSlotData(i + 3)-- 槽位即道具子id,从4开始,需要+3映射
|
|
if skill_data and skill_data.skill_lv > 0 then
|
|
self.skill_last_select_slot = i + 3
|
|
get_data = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if get_data then
|
|
if self.tab_index == PsionicConst.TabId.PSkill and self.view_list[self.tab_index] then -- 技能觉醒界面
|
|
-- 重新设置技能觉醒界面需要展示的数据
|
|
self.view_list[self.tab_index]:SetData(skill_data)
|
|
end
|
|
if not dont_refresh then
|
|
self:OnClickEquipItemCallback(self.skill_last_select_slot)
|
|
end
|
|
self:UpdateSelectedArmorInfo(self.goods_model:GetPsionicEquipBySlot(self.skill_last_select_slot))
|
|
end
|
|
return skill_data, self.skill_last_select_slot
|
|
end
|
|
-- 调整主界面节点的显示情况
|
|
function PsionicMainView:ShowPsionicInfoNodeCon( )
|
|
local is_armor = self.tab_index == PsionicConst.TabId.PArmor
|
|
local is_advance = self.tab_index == PsionicConst.TabId.PAdvance
|
|
local is_wash = self.tab_index == PsionicConst.TabId.PWash
|
|
local is_break = self.tab_index == PsionicConst.TabId.PBreak
|
|
local is_skill = self.tab_index == PsionicConst.TabId.PSkill
|
|
-- 是否展示主角模型界面
|
|
-- self:ShowRoleModelCon(is_armor)
|
|
-- 是否展示穿戴装备节点
|
|
self:ShowEquipCon(is_armor, is_advance or is_wash or is_skill)
|
|
-- 是否展示装备模型节点
|
|
self:ShowEquipInfoCon(is_break, is_advance or is_break or is_wash or is_skill)
|
|
end
|
|
-- 是否展示模型界面
|
|
-- function PsionicMainView:ShowRoleModelCon(show)
|
|
-- if self.role_con_obj.activeSelf ~= show then
|
|
-- self.role_con_obj:SetActive(show)
|
|
-- end
|
|
-- end
|
|
-- 是否展示穿戴装备节点
|
|
function PsionicMainView:ShowEquipCon(is_armor, show_tab)
|
|
-- 背包页签只展示圆盘上的装备节点,其他页签展示左侧tab节点
|
|
if self.equip_con_obj.activeSelf ~= is_armor then
|
|
self.equip_con_obj:SetActive(is_armor)
|
|
end
|
|
if self.equip_tab_con_obj.activeSelf ~= show_tab then
|
|
self.equip_tab_con_obj:SetActive(show_tab)
|
|
end
|
|
-- if self.equip_right_obj.activeSelf ~= is_armor then
|
|
-- self.equip_right_obj:SetActive(is_armor)
|
|
-- self.equip_title2_tmp.text = is_armor and "圣物技能" or ""
|
|
-- end
|
|
end
|
|
-- 是否展示装备模型节点
|
|
function PsionicMainView:ShowEquipInfoCon(is_break, show)
|
|
if self.equip_info_con_obj.activeSelf ~= show then
|
|
self.equip_info_con_obj:SetActive(show)
|
|
if not show then -- 隐藏特效
|
|
self.showing_break_level_effect = false
|
|
self.showing_break_equip_effect = false
|
|
self.showing_skill_effect = false
|
|
self:ClearUIEffect(self.equip_effect_con)
|
|
end
|
|
end
|
|
-- 突破界面需要展示背包滚动容器和容器背景,并调整模型位置
|
|
if self.break_select_bg_obj.activeSelf ~= is_break then
|
|
self.break_select_bg_obj:SetActive(is_break)
|
|
self.break_select_scroll_obj:SetActive(is_break)
|
|
self.break_tab_con_obj:SetActive(is_break)
|
|
end
|
|
SetAnchoredPositionY(self.equip_model_con, is_break and -120 or -200)
|
|
SetAnchoredPositionY(self.equip_effect_con, is_break and 65 or 25)
|
|
end
|
|
-- 显示左侧进阶装备列表节点
|
|
function PsionicMainView:ShowPsionicArmorListCon( )
|
|
-- local bool = self.tab_index == PsionicConst.TabId.PAdvance or self.tab_index == PsionicConst.TabId.PWash or self.tab_index == PsionicConst.TabId.PSkill
|
|
-- if self.advance_con_obj.activeSelf ~= bool then -- 显示状态不同,则切换显示状态
|
|
-- if not self.adv_node_tween_id then
|
|
-- self.advance_con_obj:SetActive(bool)
|
|
-- end
|
|
-- end
|
|
end
|
|
|
|
-- 加载玩家佩戴的圣物技能
|
|
function PsionicMainView:UpdatePsionicEquipAndSkillData( )
|
|
-- 加载4个位置的技能,
|
|
local e_item, s_item
|
|
for i = 1, 4 do
|
|
-- 装备节点
|
|
e_item = self.main_equip_item_list[i]
|
|
if not e_item then
|
|
e_item = PsionicArmorEquipItem.New(self.equip_con_list[i])
|
|
self.main_equip_item_list[i] = e_item
|
|
end
|
|
e_item:SetData(i, PsionicConst.ArmorItemFlag.Equiped, PsionicConst.TabId.PArmor)
|
|
|
|
-- 技能节点
|
|
s_item = self.skill_item_list[i]
|
|
if not s_item then
|
|
s_item = PsionicSkillEquipItem.New(self.skill_con_list[i])
|
|
self.skill_item_list[i] = s_item
|
|
end
|
|
s_item:SetData(i)
|
|
end
|
|
end
|
|
|
|
-- 更新页签红点
|
|
function PsionicMainView:UpdateTabRed(tab_id)
|
|
if tab_id then
|
|
self.tabWindowComponent:ShowRedPoint(tab_id, self.model:GetPsionicRedDotCache(tab_id))
|
|
else
|
|
for k, v in pairs(PsionicConst.TabData) do
|
|
local bool = self.model:GetPsionicRedDotCache(v.id)
|
|
-- print("Saber:PsionicMainView [658] bool, v.id: ",bool, v.id)
|
|
self.tabWindowComponent:ShowRedPoint(v.id, bool)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 更新圣环按钮红点
|
|
function PsionicMainView:UpdateEffectBtnRed( )
|
|
self.activate_effect_btn_red_obj:SetActive(self.model:GetPsionicEffectBtnRed())
|
|
end
|
|
|
|
function PsionicMainView:DestroySuccess( )
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:DeleteMe()
|
|
self.tabWindowComponent = nil
|
|
end
|
|
|
|
for k, v in pairs(self.view_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.view_list = nil
|
|
|
|
for k, v in pairs(self.tab_equip_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.tab_equip_item_list = nil
|
|
|
|
for k, v in pairs(self.armor_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.armor_item_list = nil
|
|
|
|
for k, v in pairs(self.main_equip_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.main_equip_item_list = {}
|
|
|
|
for k, v in pairs(self.skill_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.skill_item_list = nil
|
|
|
|
for k, v in pairs(self.break_tab_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.break_tab_list = nil
|
|
self:ClearUIEffect(self.equip_effect_con)
|
|
self.model:SetPsionicShowFlyGoods(true)
|
|
Runner.Instance:RemoveRunObj(self)
|
|
end
|
|
|
|
|
|
function PsionicMainView:Close()
|
|
--完成引导
|
|
self:CloseGuide()
|
|
BaseView.Close(self)
|
|
end
|
|
|
|
--检测点击屏幕
|
|
function PsionicMainView:Update()
|
|
if self.is_in_guide then
|
|
local is_click = false
|
|
if Input.touchCount > 0 then
|
|
is_click = true
|
|
else
|
|
if Input.GetMouseButtonDown(0) then
|
|
is_click = true
|
|
end
|
|
end
|
|
if is_click then
|
|
self.is_in_guide = false
|
|
Runner.Instance:RemoveRunObj(self)
|
|
self:CloseGuide()
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
function PsionicMainView:AddToStageHandler()
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_PSIONIC,5)
|
|
if not helpVo then return end
|
|
local help_type = helpVo.help_type
|
|
if (help_type == HelpType.TYPE_PSIONIC) then
|
|
local step = helpVo.step
|
|
local button = false
|
|
if (help_type == HelpType.TYPE_PSIONIC) and step == 5 then
|
|
button = self.skill_con_list[1]
|
|
end
|
|
|
|
if button then
|
|
local function call_back()
|
|
|
|
end
|
|
GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
|
|
|
|
self.is_in_guide = true
|
|
Runner.Instance:AddRunObj(self, 1)
|
|
end
|
|
else
|
|
GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
|
|
end
|
|
end
|
|
|
|
function PsionicMainView:CloseGuide()
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_PSIONIC,5)
|
|
if helpVo then
|
|
GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
|
|
end
|
|
end
|