|
-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 转职系统 转职弹出任务界面 (与角色-转职界面区分,这个界面仅当转职进行中可以弹出)
|
|
-- *>
|
|
ReinMainTaskView = ReinMainTaskView or BaseClass(BaseView)
|
|
local ReinMainTaskView = ReinMainTaskView
|
|
local SetAnchoredPositionX = SetAnchoredPositionX
|
|
--[[
|
|
ReinMainTaskView.TabData = {
|
|
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
|
|
}
|
|
--]]
|
|
|
|
function ReinMainTaskView:__init()
|
|
self.base_file = "reincarnation"
|
|
self.layout_file = "ReinMainTaskView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.use_show_anim = false
|
|
self.use_hide_anim = true
|
|
self.model = ReincarnationModel:getInstance()
|
|
self.task_model = TaskModel:getInstance()
|
|
self.role_img_pos = {
|
|
[1] = Vector2(-315.5, -6),
|
|
[2] = Vector2(-313.5, -25),
|
|
[3] = Vector2(-168.5, 9.5),
|
|
[4] = Vector2(-318, -0.5),
|
|
}
|
|
self.main_vo = RoleManager.Instance.mainRoleInfo
|
|
self.cur_task_stage = self.main_vo.turn_stage -- 当前转职任务阶段index
|
|
self.rein_lv = 1
|
|
self.rein_stage_cfg = {} -- 当前转生等级的阶段任务属性配置
|
|
self.skill_item = {} -- 界面中的技能图标
|
|
self.equip_item = {} -- 界面中的技能图标
|
|
self.task_reward = {} -- 界面中的任务奖励
|
|
self.task_btn_flag_content = {
|
|
[0] = "已完成",
|
|
[1] = "接取任务",
|
|
[2] = "前往",
|
|
[3] = "完成任务",
|
|
[4] = "完成转职",
|
|
[5] = "前往",
|
|
}
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function ReinMainTaskView:Open(rein_lv)
|
|
self.rein_lv = rein_lv
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function ReinMainTaskView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:raw",
|
|
"role_rp:rawex",
|
|
"close_btn:obj",
|
|
"main_title:imgex",
|
|
-- 右侧信息部分,分为动画父节点和内部的信息节点
|
|
-- 转职头像和名称
|
|
"head_anim_con:cg",
|
|
"head_anim_con/head_before_bg/head_before:raw",
|
|
"head_anim_con/head_new_bg/head_new:raw",
|
|
"head_anim_con/pname_before:tmp", "head_anim_con/pname_new:tmp",
|
|
-- 属性节点和技能解锁容器
|
|
"attr_skill_anim_con:cg",
|
|
"attr_skill_anim_con/attr_scroll", "attr_skill_anim_con/attr_scroll/Viewport/attr_con",
|
|
"attr_skill_anim_con/skill_con",
|
|
-- 装备代数解锁容器
|
|
"equip_anim_con:cg",
|
|
"equip_anim_con/equip_con", "equip_anim_con/title3:tmp",
|
|
-- 任务内容容器
|
|
"task_anim_con:cg",
|
|
"task_anim_con/task_proceed_btn:obj:imgex",
|
|
"task_anim_con/task_proceed_btn/task_proceed_red:img",
|
|
"task_anim_con/task_proceed_btn/task_proceed_btn_lb:tmp",
|
|
"task_anim_con/task_title",
|
|
"task_anim_con/task_award_con",
|
|
"task_anim_con/task_progress:tmp",
|
|
"task_anim_con/title4:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("re_main_bg"))
|
|
end
|
|
|
|
function ReinMainTaskView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.close_btn_obj then
|
|
self:Close()
|
|
elseif target == self.task_proceed_btn_obj then
|
|
self:OnTaskProceedBtnClick()
|
|
end
|
|
end
|
|
AddClickEvent(self.close_btn_obj, click_event)
|
|
AddClickEvent(self.task_proceed_btn_obj, click_event)
|
|
|
|
local function updateReinStage()
|
|
self.cur_task_stage = self.main_vo.turn_stage
|
|
end
|
|
self.update_rein_stage_id = self.main_vo:BindOne("turn_stage", updateReinStage)
|
|
|
|
local function updateReinTask()
|
|
self:UpdateCurrentTask() -- 更新任务按钮
|
|
end
|
|
self:BindEvent(self.model, ReincarnationModel.REFRESH_REIN_TASK, updateReinTask)
|
|
end
|
|
|
|
function ReinMainTaskView:UpdateView()
|
|
self:InitReinData(self.rein_lv)
|
|
self:UpdateRoleRP() -- 更新立绘
|
|
self:UpdateRoleHead() -- 更新转职系统头像
|
|
self:UpdateAttrData() -- 更新战斗力和属性
|
|
self:UpdateUnlockItems() -- 更新新增技能
|
|
self:UpdateCurrentTask() -- 更新任务相关
|
|
self:StartReinMainTaskAnim()
|
|
end
|
|
|
|
function ReinMainTaskView:InitReinData(rein_lv)
|
|
self.rein_lv = rein_lv or self.model:GetCurTurn()
|
|
self.rein_stage_cfg = self.model:GetReinLvStageData(self.rein_lv)
|
|
self.total_stage = #self.rein_stage_cfg
|
|
end
|
|
|
|
-- 更新立绘
|
|
function ReinMainTaskView:UpdateRoleRP( )
|
|
-- 加载立绘
|
|
self.role_rp_rawex.alpha = 0
|
|
lua_resM:setOutsideRawImage(self, self.role_rp_rawex, GameResPath.GetRoleBg("rein_success_role" .. self.main_vo.career), true)
|
|
end
|
|
|
|
-- 更新转职系统头像
|
|
function ReinMainTaskView:UpdateRoleHead( )
|
|
-- 先获取上个转职阶段的默认头像
|
|
local career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv - 1)
|
|
lua_resM:setOutsideRawImage(self, self.head_before_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001))
|
|
self.pname_before_tmp.text = career_cfg and Trim(career_cfg.name) or ""
|
|
-- 获取当前转职的头像
|
|
career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv)
|
|
lua_resM:setOutsideRawImage(self, self.head_new_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001))
|
|
self.pname_new_tmp.text = career_cfg and Trim(career_cfg.name) or ""
|
|
end
|
|
|
|
-- 更新转职属性提升数据
|
|
function ReinMainTaskView:UpdateAttrData( )
|
|
-- 获取配置
|
|
local attr_list = stringtotable(self.rein_stage_cfg[#self.rein_stage_cfg].attr_list)
|
|
attr_list = SortAttrList(attr_list)
|
|
|
|
self.attr_item_creator = self.attr_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = attr_list,
|
|
scroll_view = self.attr_scroll,
|
|
item_con = self.attr_con,
|
|
prefab_ab_name = "reincarnation",
|
|
prefab_res_name = "ReinMainTaskAttrItem",
|
|
item_height = 30,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
child_names = {"attr_name:tmp", "attr_val:tmp"},
|
|
on_update_item = function(item, i, v)
|
|
item.attr_name_tmp.text = WordManager:GetProperties(v[1])
|
|
item.attr_val_tmp.text = WordManager:GetPropertyValue(v[1], v[2])
|
|
end,
|
|
}
|
|
self.attr_item_creator:UpdateItems(info)
|
|
end
|
|
|
|
|
|
-- 更新转职解锁内容
|
|
function ReinMainTaskView:UpdateUnlockItems( )
|
|
local unlock_data = self.model:GetReinSucceedUnlockData(self.rein_lv)
|
|
-- 解锁的技能
|
|
for k, v in ipairs(unlock_data.skill_list) do
|
|
self.skill_item[k] = self.skill_item[k] or ReinTaskSkillItem.New(self.skill_con)
|
|
self.skill_item[k]:SetTransformSize(62)
|
|
local row, col = (k - 1) % 4, math.floor((k - 1) / 4)
|
|
self.skill_item[k]:SetAnchoredPosition(81.5 * row + 1, -68 * col)
|
|
self.skill_item[k]:SetData(v.skill_data)
|
|
end
|
|
-- 解锁的装备
|
|
for k, v in ipairs(unlock_data.equip_list) do
|
|
self.equip_item[k] = self.equip_item[k] or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.equip_con)
|
|
self.equip_item[k]:SetAnchoredPosition((k - 1) * 78 + 9, -5)
|
|
self.equip_item[k]:SetItemSize(62, 62)
|
|
self.equip_item[k]:SetVisible(true)
|
|
self.equip_item[k]:SetData(v.equip_data)
|
|
end
|
|
-- 装备栏标题
|
|
self.title3_tmp.text = string.format("解锁 %s代装备", ChineseNumber(unlock_data.equip_series))
|
|
end
|
|
|
|
-- 更新当前的转职任务信息
|
|
function ReinMainTaskView:UpdateCurrentTask( )
|
|
-- 如果查看的是当前正在进行的转生阶段,则自动定位任务,否则定位到最后一个
|
|
if self.rein_lv == self.main_vo.turn + 1 then
|
|
-- 自动定位到当前正在进行的任务
|
|
local cur_task_vo = self.model:GetCurTaskVo()
|
|
local auto_index = self.cur_task_stage + 1
|
|
if cur_task_vo then
|
|
-- 当前已接任务则当前阶段等于跳转阶段,否则为下一阶段
|
|
local task_received = cur_task_vo.acceptType == 0
|
|
auto_index = task_received and self.cur_task_stage or self.cur_task_stage + 1
|
|
end
|
|
self:UpdateTaskData(auto_index > self.total_stage and self.total_stage or auto_index)
|
|
else
|
|
self:UpdateTaskData(self.rein_lv > self.main_vo.turn + 1 and 1 or self.total_stage)
|
|
end
|
|
end
|
|
|
|
function ReinMainTaskView:UpdateTaskData(stage)
|
|
if not stage then return end
|
|
-- 当前转职进度
|
|
local turn, turn_stage = self.main_vo.turn, self.main_vo.turn_stage
|
|
-- 创建展示内容
|
|
-- local task_data_list = {}
|
|
self.task_btn_flag = 0 -- 任务功能按钮状态 0已完成的任务 1接任务 2前往任务 3完成任务 4完成转职 5任务不可接
|
|
local progress_lb = nil
|
|
local task_award = nil
|
|
if self.rein_lv < turn then -- 查看往期转职任务
|
|
-- 提示任务内容已经完成
|
|
self.title4_tmp.text = string.format("<color=%s>已完成</color>全部转职任务", ColorUtil.GREEN_DARK)
|
|
else
|
|
local cur_task_vo, auto_index = nil, self.cur_task_stage + 1
|
|
if self.rein_lv == turn + 1 then -- 查看当前转职任务
|
|
-- 先尝试获取进行中的任务
|
|
cur_task_vo = self.model:GetCurTaskVo()
|
|
if cur_task_vo then
|
|
-- 记录奖励列表
|
|
task_award = cur_task_vo.award_list
|
|
-- 当前已接任务则当前阶段等于跳转阶段,否则为下一阶段
|
|
local task_received = cur_task_vo.acceptType == 0
|
|
auto_index = task_received and self.cur_task_stage or self.cur_task_stage + 1
|
|
self.task_btn_flag = task_received and 2 or 1
|
|
if task_received then
|
|
-- 如果任务已经完成了,则要进一步确认状态
|
|
local is_task_finished = cur_task_vo.taskTips[1] and cur_task_vo.taskTips[1].isFinish == 1
|
|
if is_task_finished then
|
|
self.task_btn_flag = self.total_stage == stage and 4 or 3
|
|
end
|
|
end
|
|
end
|
|
progress_lb = string.format("(<color=%s>%s</color>/%s)", ColorUtil.GREEN_DARK, stage, self.total_stage)
|
|
else
|
|
progress_lb = nil
|
|
end
|
|
local stage_data = self.rein_stage_cfg[stage]
|
|
local task_id = stage_data and stage_data.task_id
|
|
if progress_lb then
|
|
self.task_progress_tmp.text = progress_lb
|
|
SetAnchoredPositionX(self.task_title, -15.5)
|
|
else
|
|
self.task_progress_tmp.text = ""
|
|
SetAnchoredPositionX(self.task_title, 15.5)
|
|
end
|
|
-- 用于获取展示数据的task_vo
|
|
local task_vo = nil
|
|
|
|
if stage == auto_index then -- 当查看的阶段数相同时,才获取正在进行中的转生任务
|
|
task_vo = cur_task_vo
|
|
end
|
|
print("Saber:ReinMainTaskView [279] task_id: ",task_id)
|
|
-- 如果当前有进行中或可接的转职任务,则直接使用任务结构体
|
|
if task_vo then
|
|
self.title4_tmp.text = task_vo.tipContent
|
|
else -- 当前进行中的任务不存在,则获取任务配置
|
|
if task_id and not self.task_model:IsTaskFinished(task_id) then
|
|
task_vo = ConfigItemMgr.Instance:GetTaskData(task_id)
|
|
task_award = self:GetTaskRewardList(task_vo)
|
|
self.title4_tmp.text = string.format("%s任务 (<color=%s>%s</color>/%s) 级可接取",
|
|
(self.rein_lv == turn + 1 and turn_stage ~= 0) and "下一阶段" or "转职",
|
|
self.main_vo.level < task_vo.level and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK,
|
|
self.main_vo.level, task_vo.level)
|
|
|
|
self.task_btn_flag = 5
|
|
self.click_tips_level = task_vo.level
|
|
else -- 对于已完成的任务或者不存在的任务,提示任务内容已经完成
|
|
self.title4_tmp.text = string.format("<color=%s>已完成</color>全部转职任务", ColorUtil.GREEN_DARK)
|
|
self.task_btn_flag = 0
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 更新任务按钮样式
|
|
local is_gray = self.task_btn_flag == 0 or self.task_btn_flag == 5
|
|
self.task_proceed_btn_imgex.gray = is_gray
|
|
SetTMPSharedMaterial(self.task_proceed_btn_lb_tmp, is_gray
|
|
and ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkGrayBtn
|
|
or ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn
|
|
)
|
|
self.task_proceed_btn_lb_tmp.text = self.task_btn_flag_content[self.task_btn_flag]
|
|
-- 加载任务奖励
|
|
for k, v in pairs(self.task_reward) do
|
|
v:SetVisible(false)
|
|
end
|
|
if task_award then
|
|
for k, v in ipairs(task_award) do
|
|
self.task_reward[k] = self.task_reward[k] or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.task_award_con)
|
|
self.task_reward[k]:SetAnchoredPosition((k - 1) * 78 + 9, -5)
|
|
self.task_reward[k]:SetItemSize(62, 62)
|
|
self.task_reward[k]:SetVisible(true)
|
|
self.task_reward[k]:SetDataWithMapId(v[2], v[3], v[1])
|
|
end
|
|
end
|
|
end
|
|
|
|
function ReinMainTaskView:GetTaskRewardList(task_vo)
|
|
local normal_list = stringtotable(task_vo.award_list)
|
|
local career_list = stringtotable(task_vo.special_goods_list)
|
|
local award_list = {}
|
|
for i,v in ipairs(career_list) do
|
|
if (self.main_vo.career == tonumber(v[1]) or tonumber(v[1])==0)
|
|
and (self.main_vo.sex==tonumber(v[2]) or tonumber(v[2])==0) then
|
|
local obj = {}
|
|
obj[1] = 0
|
|
obj[2] = tonumber(v[3])
|
|
obj[3] = tonumber(v[4])
|
|
table.insert(award_list, obj)
|
|
end
|
|
end
|
|
for i,v in ipairs(normal_list) do
|
|
table.insert(award_list, v)
|
|
end
|
|
return award_list
|
|
end
|
|
---------- 动画相关 --------------
|
|
function ReinMainTaskView:StartReinMainTaskAnim( )
|
|
local title_action_time = 0.2
|
|
local role_rp_action_time = 0.5
|
|
local right_info_delay = 0.1
|
|
local head_action_time = 0.3
|
|
local a_s_action_time = 0.3
|
|
local equip_action_time = 0.3
|
|
local task_action_time = 0.3
|
|
local function east_func(percent)
|
|
percent = percent - 1.0
|
|
local real_pec = percent * percent * percent * percent * percent + 1
|
|
return real_pec
|
|
end
|
|
-- 标题小位移效果和淡出效果
|
|
local target_main_title_posx = -77
|
|
SetAnchoredPositionX(self.main_title, target_main_title_posx - 100)
|
|
local function title_size_x_func(percent)
|
|
percent = east_func(percent)
|
|
self.main_title_imgex.alpha = percent
|
|
SetAnchoredPositionX(self.main_title, target_main_title_posx - 100 * (1 - percent))
|
|
end
|
|
local main_title_action = cc.CustomUpdate.New(title_action_time, title_size_x_func)
|
|
cc.ActionManager:getInstance():addAction(main_title_action, self.main_title)
|
|
|
|
-- 左侧立绘淡入和位移
|
|
local pos = self.role_img_pos[self.main_vo.career]
|
|
SetAnchoredPosition(self.role_rp, pos.x - 300, pos.y)
|
|
local function role_rp_action_func(percent)
|
|
percent = east_func(percent)
|
|
self.role_rp_rawex.alpha = percent
|
|
SetAnchoredPositionX(self.role_rp, pos.x - 300 * (1 - percent))
|
|
end
|
|
local role_rp_action = cc.Sequence.New(
|
|
cc.DelayTime.New(title_action_time),
|
|
cc.CustomUpdate.New(role_rp_action_time, role_rp_action_func)
|
|
)
|
|
cc.ActionManager:getInstance():addAction(role_rp_action, self.role_rp)
|
|
|
|
-- 右侧信息淡入和位移
|
|
-- (自上而下)头像框
|
|
local head_pos_x = 260
|
|
SetAnchoredPositionX(self.head_anim_con, head_pos_x - 50)
|
|
local function head_action_func(percent)
|
|
percent = east_func(percent)
|
|
self.head_anim_con_cg.alpha = percent
|
|
SetAnchoredPositionX(self.head_anim_con, head_pos_x - 50 * (1 - percent))
|
|
end
|
|
local head_action = cc.Sequence.New(
|
|
cc.DelayTime.New(title_action_time),
|
|
cc.CustomUpdate.New(head_action_time, head_action_func)
|
|
)
|
|
cc.ActionManager:getInstance():addAction(head_action, self.head_anim_con)
|
|
-- 属性和技能解锁
|
|
local a_s_pos_x = 240
|
|
SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x - 50)
|
|
local function attr_skill_action_func(percent)
|
|
percent = east_func(percent)
|
|
self.attr_skill_anim_con_cg.alpha = percent
|
|
SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x - 50 * (1 - percent))
|
|
end
|
|
local a_s_action = cc.Sequence.New(
|
|
cc.DelayTime.New(title_action_time + right_info_delay),
|
|
cc.CustomUpdate.New(a_s_action_time, attr_skill_action_func)
|
|
)
|
|
cc.ActionManager:getInstance():addAction(a_s_action, self.attr_skill_anim_con)
|
|
-- 装备代数
|
|
local equip_pos_x = 240
|
|
SetAnchoredPositionX(self.equip_anim_con, equip_pos_x - 50)
|
|
local function equip_action_func(percent)
|
|
percent = east_func(percent)
|
|
self.equip_anim_con_cg.alpha = percent
|
|
SetAnchoredPositionX(self.equip_anim_con, equip_pos_x - 50 * (1 - percent))
|
|
end
|
|
local equip_action = cc.Sequence.New(
|
|
cc.DelayTime.New(title_action_time + right_info_delay * 2),
|
|
cc.CustomUpdate.New(equip_action_time, equip_action_func)
|
|
)
|
|
cc.ActionManager:getInstance():addAction(equip_action, self.equip_anim_con)
|
|
-- 任务内容
|
|
local task_pos_x = 240
|
|
SetAnchoredPositionX(self.task_anim_con, task_pos_x - 50)
|
|
local function task_action_func(percent)
|
|
percent = east_func(percent)
|
|
self.task_anim_con_cg.alpha = percent
|
|
SetAnchoredPositionX(self.task_anim_con, task_pos_x - 50 * (1 - percent))
|
|
end
|
|
local task_action = cc.Sequence.New(
|
|
cc.DelayTime.New(title_action_time + right_info_delay * 3),
|
|
cc.CustomUpdate.New(task_action_time, task_action_func)
|
|
)
|
|
cc.ActionManager:getInstance():addAction(task_action, self.task_anim_con)
|
|
end
|
|
---------- 动画相关 --------------
|
|
|
|
-- 点击任务前往按钮回调
|
|
function ReinMainTaskView:OnTaskProceedBtnClick( )
|
|
if self.task_btn_flag ~= 0 and self.task_btn_flag ~= 5 then
|
|
local cur_rein_task = self.model:GetCurTaskVo()
|
|
TaskModel:getInstance():TaskClickFun(cur_rein_task)
|
|
-- 关闭界面
|
|
self:Close()
|
|
elseif self.task_btn_flag == 5 then
|
|
Message.show(string.format("任务%s级开放", self.click_tips_level), "fault")
|
|
end
|
|
end
|
|
|
|
function ReinMainTaskView:DestroySuccess( )
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.main_title)
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.head_anim_con)
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.role_rp)
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.attr_skill_anim_con)
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.equip_anim_con)
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.task_anim_con)
|
|
for k, v in pairs(self.skill_item) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
for k, v in pairs(self.equip_item) do
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
|
|
end
|
|
self.equip_item = {}
|
|
for k, v in pairs(self.task_reward) do
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
|
|
end
|
|
self.task_reward = {}
|
|
|
|
if self.update_rein_stage_id then
|
|
self.main_vo:UnBind(self.update_rein_stage_id)
|
|
self.update_rein_stage_id = nil
|
|
end
|
|
end
|