|
|
- GuideStartView = GuideStartView or BaseClass(BaseView)
- local GuideStartView = GuideStartView
-
- GuideStartView.StartTime = 0.2 --点击指纹后,进度延时多久才开始加
- GuideStartView.UpdateSpeed = 5 --进度增加的速率
- GuideStartView.CloseViewTime = 200 --界面关闭的时间(其实是进度增加到当前进度才关闭)
-
- function GuideStartView:__init()
- self.base_file = "guide"
- self.layout_file = "GuideStartView"
- self.layer_name = "Top"
- self.destroy_imm = true
- self.use_background = true
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
- self.hide_maincancas = true
- -- self.hide_maincancas = true
- self.click_bg_toClose = false
-
- self.cur_progress = 0
- self.is_auto = false
- self.is_start = false
-
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self:OpenSuccess()
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function GuideStartView:Open(chapter_id)
- self.chapter_id = chapter_id or 1
- BaseView.Open(self)
- end
-
- function GuideStartView:Close( )
- --超过这个等级就不自动做任务
- if RoleManager.Instance.mainRoleInfo.level <= 2 then
- GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
- end
- local function func( )
- lua_viewM:SetUICameraBloomEnable(true)
- end
- setTimeout(func,1)
- BaseView.Close(self)
- end
-
- function GuideStartView:LoadSuccess()
- if RoleManager.Instance.mainRoleInfo.level > 1 then
- self:Close()
- return
- end
-
- local nodes = {
- "content:tmp",
- "time_left:tmp",
- "progress_txt:tmp",
- "complete:obj",
- "girl_icon:raw",
- "bg:img",
- "name:tmp",
- "click_btn:obj",
- "content_line_complete_1:tmp",
- "content_line_complete_2:tmp",
- "content_line_complete_3:tmp",
- "content_line_1:tmp:obj",
- "content_line_2:tmp:obj",
- "content_line_3:tmp:obj",
- "content_line_4:tmp:obj",
- "content_line_5:tmp:obj",
- "content_line_6:tmp:obj",
- "effect_con_1:obj",
- "effect_con_2:obj",
- "effect_con_3:obj",
- "zhiwen:obj:img",
- "role:raw",
- }
- self:GetChildren(nodes)
- --elf:AddUIEffect("ui_feiye", self.effect_con_1, self.layer_name, nil, 1, true, nil, nil, nil)
- self:AddUIEffect("ui_zhiwen2", self.effect_con_3, self.layer_name, nil, 1, true, nil, nil, nil)
- self.effect_con_2_obj:SetActive(true)
- self.effect_con_3_obj:SetActive(false)
- self.zhiwen_obj:SetActive(true)
- SetImageGray(self.zhiwen_img, true)
-
-
- local function bg_back_func( ... )
- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
- end
- end
- if self.background_wnd then
- bg_back_func()
- else
- self.bg_back_func = bg_back_func
- end
- self:MoveUIToBack(self.bg_img)
-
- self:UpdateVeiw()
- end
-
- function GuideStartView:AddEvent()
- local function on_btn_click(target)
- if target == self.click_btn_obj then
- self:DoAutoCheck()
- end
- end
- AddClickEvent(self.click_btn_obj, on_btn_click)
-
- local onExitGame = function()
- self:Close()
- end
- self:BindEvent(GlobalEventSystem, EventName.CHANGE_ACCOUNT, onExitGame)
- self:BindEvent(GlobalEventSystem, EventName.CHANGE_ROLE, onExitGame)
- self:BindEvent(GlobalEventSystem, EventName.GAME_DISCONNECT, onExitGame)
- end
-
- function GuideStartView:OpenSuccess()
- GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
- GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
- self:UpdateTimer()
- end
-
- function GuideStartView:UpdateTimer( )
- local left_time = 0 --倒计时时间
- local left_tiem_max = 6 --倒计时最大时间
- local auto_time = 6 --自动验证时间
- local left_time_step = 0 --进度增加速率
- local point_step = 0.2 -- ... 动画频率
- self.cur_progress = 0
-
- local function on_timer( )
- left_time = left_time + 0.05
- self.cur_progress = self.cur_progress + left_time_step
- if not self.is_start then
- local str = string.format("自动验证 . . . (%ds)", math.floor(left_tiem_max - left_time))
- self.time_left_tmp.text = str
- if left_time >= auto_time then
- self:DoAutoCheck()
- end
- else
- if self.is_auto then
- left_time_step = GuideStartView.UpdateSpeed
- end
- end
-
- if self.content_line_flag_1 then
- if self.cur_progress <= 30 then
- self.content_line_flag_1 = self:GetCnt(self.content_line_flag_1, point_step)
-
- self.content_line_1_tmp.text = self.line_text[1] .. self:GetPointStrings(self.content_line_flag_1)
- else
- self.content_line_flag_1 = false
- self.content_line_1_tmp.text = self.line_text[1] .. " . . . "
- self.content_line_complete_1_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
- end
- end
-
-
- if self.content_line_flag_2 then
- if self.cur_progress <= 50 then
- self.content_line_flag_2 = self:GetCnt(self.content_line_flag_2, point_step)
- self.content_line_2_tmp.text = self.line_text[2] .. self:GetPointStrings(self.content_line_flag_2)
- else
- self.content_line_flag_2 = false
- self.content_line_2_tmp.text = self.line_text[2] .. " . . . "
- self.content_line_complete_2_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
- end
- end
-
- if self.content_line_flag_3 then
- if self.cur_progress <= 70 then
- self.content_line_flag_3 = self:GetCnt(self.content_line_flag_3, point_step)
- self.content_line_3_tmp.text = self.line_text[3] .. self:GetPointStrings(self.content_line_flag_3)
- else
- self.content_line_flag_3 = false
- self.content_line_3_tmp.text = self.line_text[3] .. " . . . "
- self.content_line_complete_3_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
- end
- end
-
- if self.content_line_flag_4 and self.cur_progress >= 80 then
- self.content_line_flag_4 = false
- self.content_line_4_obj:SetActive(true)
- end
-
- if self.content_line_flag_5 and self.cur_progress >= 90 then
- self.content_line_flag_5 = false
- self.content_line_5_obj:SetActive(true)
- end
-
- if self.content_line_flag_6 and self.cur_progress >= 95 then
- self.content_line_flag_6 = false
- self.content_line_6_obj:SetActive(true)
- end
-
- if self.cur_progress < 100 then
- self.progress_txt_tmp.text = math.floor(self.cur_progress) .. "%"
- else
-
- if self.content_line_flag_7 then
- self.content_line_flag_7 = false
- self.progress_txt_tmp.text = "100%"
- self.complete_obj:SetActive(true)
- end
-
- if self.cur_progress >= GuideStartView.CloseViewTime then
- self:CancelCountDownTimer()
- self:Close()
- end
- end
- end
- on_timer()
- if not self.count_down_timer then
- self.count_down_timer = GlobalTimerQuest:AddPeriodQuest(on_timer, 0.05, -1)
- end
- end
-
- function GuideStartView:DoAutoCheck()
- if self.is_start then
- return
- end
- self.is_start = true
- if self.delay_start_id then
- GlobalTimerQuest:CancelQuest(self.delay_start_id)
- self.delay_start_id = false
- end
- self:AddUIEffect("ui_zhiwen1", self.effect_con_2, self.layer_name, nil, 1, false, nil, nil, nil)
- lua_soundM:PlayEffect(self, "zhiwen", false, LuaSoundManager.SOUND_TYPE.UI)
- self.time_left_tmp.text = ""
- local function DelayStart( ... )
- self.is_auto = true
- self.effect_con_3_obj:SetActive(true)
- SetImageGray(self.zhiwen_img, false)
- end
-
- self.delay_start_id = GlobalTimerQuest:AddDelayQuest(DelayStart,GuideStartView.StartTime)
- end
-
- function GuideStartView:GetCnt(crrent, step)
- local t = crrent + step
- t = t > 4 and 0 or t
- return t
- end
-
-
- function GuideStartView:GetPointStrings(cnt)
- local t = math.floor(cnt)
- return t == 0 and "" or (t == 1 and " . " or (t == 2 and " . . " or " . . . "))
- end
-
- function GuideStartView:CancelCountDownTimer( )
- if self.count_down_timer then
- GlobalTimerQuest:CancelQuest(self.count_down_timer)
- self.count_down_timer = nil
- end
- end
-
- function GuideStartView:UpdateVeiw( )
- local chapter_id = self.chapter_id or 1
- self.line_text =
- {
- [1] = "指纹信息",
- [2] = "DNA序列",
- [3] = "虹膜信息",
- }
- --lua_resM:setOutsideRawImage(self, self.role_raw, GameResPath.GetGuideImage("guide_start_role_".. RoleManager.Instance.mainRoleInfo.career), false)
- lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetViewBigBg("guide_start_view_bg_".. chapter_id), false)
-
-
- --lua_resM:setOutsideImageSprite(self, self.girl_icon_raw, GameResPath.GetRoleBg("guide_girl_399_603"), true)
- -- local res_data = {
- -- father_node = self,
- -- transform = self.girl_icon,
- -- fashion_type = FuncOpenModel.TypeId.FJarvis,
- -- figure_id = 1001,
- -- action_name_list = {"show"},
- -- size = Vector2(720,720),
- -- scale = 450,
- -- position = {x = 60, y = -247},
- -- show_shadow = true,
- -- can_rotate = false,
- -- ui_model_type = UIModelCommon.ModelType.BackModel,
- -- }
- -- FuncOpenModel:getInstance():SetModelRes(res_data)
-
- local icon_id = 100301
- local weapon_id = 0
- local texture_id = 0
- local data = {
- clothe_res_id = icon_id,
- weapon_res_id = weapon_id,
- role_type = SceneBaseType.Npc,
- texture_id = texture_id,
- image_id = texture_id,
- size = Vector2(720,720),
- scale = 380,
- position = Vector3(0, -100, 0),
- action_name_list = {"show"},
- show_shadow = false,
- raycastParent = false,
- can_rotate = false,
- }
- lua_resM:SetBackRoleModel(self,self.girl_icon,data)
-
-
- local role_con_pos =
- {
- [1] = {x = 150, y = -231,},
- [2] = {x = 115, y = -182,},
- [3] = {x = 129, y = -226,},
- [4] = {x = 154, y = -185,},
- }
-
- local my_career = RoleManager.Instance.mainRoleInfo.career
- local my_icon_id = my_career
- local res_data = {
- clothe_res_id = my_icon_id,
- weapon_res_id = weapon_id,
- role_type = SceneBaseType.Role,
- texture_id = texture_id,
- image_id = texture_id,
- size = Vector2(720,720),
- scale = 380,
- position = Vector3(0, -100, 0),
- action_name_list = {"show"},
- show_shadow = false,
- raycastParent = false,
- can_rotate = false,
- }
- lua_resM:SetBackRoleModel(self,self.role,res_data)
-
- lua_viewM:SetUICameraBloomEnable(false)
-
- SetAnchoredPosition(self.role, role_con_pos[my_career].x, role_con_pos[my_career].y)
-
- self.name_tmp.text = "指挥官"
- self.content_tmp.text = "任务编号S-301,追捕秘密实验室的逃窜生物,所有单位立即行动!"
- self.content_line_complete_1_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
- self.content_line_complete_2_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
- self.content_line_complete_3_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
- self.content_line_1_tmp.text = self.line_text[1]
- self.content_line_2_tmp.text = self.line_text[2]
- self.content_line_3_tmp.text = self.line_text[3]
- self.content_line_4_obj:SetActive(false)
- self.content_line_5_obj:SetActive(false)
- self.content_line_6_obj:SetActive(false)
- self.complete_obj:SetActive(false)
- self.content_line_flag_1 = 0
- self.content_line_flag_2 = 0
- self.content_line_flag_3 = 0
- self.content_line_flag_4 = 0
- self.content_line_flag_5 = 0
- self.content_line_flag_6 = 0
- self.content_line_flag_7 = 0
-
- end
-
- function GuideStartView:DestroySuccess( )
- if self.delay_close_id then
- GlobalTimerQuest:CancelQuest(self.delay_close_id)
- self.delay_close_id = false
- end
- self:CancelCountDownTimer()
- --self:ClearUIEffect(self.effect_con_1)
- self:ClearUIEffect(self.effect_con_2)
- self:ClearUIEffect(self.effect_con_3)
- end
|