|
ChildGetView = ChildGetView or BaseClass(BaseView)
|
|
local ChildGetView = ChildGetView
|
|
|
|
function ChildGetView:__init()
|
|
self.base_file = "child"
|
|
self.layout_file = "ChildGetView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.hide_maincancas = true
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
|
|
self.model = ChildModel:GetInstance()
|
|
self.selectSex = false
|
|
|
|
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 ChildNiceRecordView:Open(data,callBack)
|
|
self.data = data
|
|
self.callBack = callBack
|
|
BaseView.Open(self)
|
|
end
|
|
function ChildGetView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:obj:img","btn_close:obj",
|
|
"confirmBtn:obj","btn2:obj:raw","btn1:obj:raw",
|
|
"moneyBg_right/num_right:txt","moneyBg_left/num_left:txt",
|
|
"moneyBg_left/moneyIcon_left:img", "moneyBg_right/moneyIcon_right:img",
|
|
|
|
"babyConLeft:raw", "babyConRight:raw",
|
|
"light2:img:obj", "light1:img:obj",
|
|
|
|
"con_talk_girl/lb_talk_girl:tmp", "con_talk_boy/lb_talk_boy:tmp",
|
|
"con_select_girl:obj", "con_talk_boy:obj",
|
|
"con_select_boy:obj", "con_talk_girl:obj",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self.lb_talk_girl_tmp.text = "嘿嘿,人家是漂亮的女孩子哦!"
|
|
self.lb_talk_boy_tmp.text = "嘻嘻,我是可爱的男孩子哦!"
|
|
self.con_select_boy_obj:SetActive(false)
|
|
self.con_talk_boy_obj:SetActive(false)
|
|
self.con_select_girl_obj:SetActive(false)
|
|
self.con_talk_girl_obj:SetActive(false)
|
|
|
|
|
|
self.input_text = self:GetChild("input"):GetComponent("InputField")
|
|
lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetChildIcon("child_get_view_bg"), false)
|
|
lua_resM:setOutsideImageSprite(self, self.light1_img, GameResPath.GetChildIcon("child_get_light_bg"), false)
|
|
lua_resM:setOutsideImageSprite(self, self.light2_img, GameResPath.GetChildIcon("child_get_light_bg"), false)
|
|
|
|
-- 微调宝宝模型的位置
|
|
SetAnchoredPosition(self.btn1, -228, 22)
|
|
SetAnchoredPosition(self.babyConLeft, -214, 50)
|
|
SetAnchoredPosition(self.btn2, 252, 22)
|
|
SetAnchoredPosition(self.babyConRight, 234, 50)
|
|
|
|
-- 下面是模型反向的参数
|
|
-- SetAnchoredPosition(self.btn1, -228 -23, 22)
|
|
-- SetAnchoredPosition(self.babyConLeft, -214 - 23, 50)
|
|
-- SetAnchoredPosition(self.btn2, 252 -23, 22)
|
|
-- SetAnchoredPosition(self.babyConRight, 234 -23, 50)
|
|
-- SetLocalScale(self.babyConLeft, -1, 1, 1)
|
|
-- SetLocalScale(self.babyConRight, -1, 1, 1)
|
|
|
|
-- self.light1_obj:SetActive(false)
|
|
-- self.light2_obj:SetActive(false)
|
|
local active_cost = stringtotable(self.model:GetConfigChildKvVal("active_cost"))
|
|
self.num_left_txt.text = active_cost[1][3]
|
|
self.num_right_txt.text = active_cost[1][3]
|
|
|
|
local asset, source = WordManager:GetCommonMoneyIcon(tonumber(active_cost[1][1]))
|
|
lua_resM:setImageSprite(self, self.moneyIcon_left_img, asset, source, true)
|
|
lua_resM:setImageSprite(self, self.moneyIcon_right_img, asset, source, true)
|
|
end
|
|
|
|
function ChildGetView:AddEvent()
|
|
local on_click = function ( click_obj )
|
|
if self.btn_close_obj == click_obj then
|
|
self:Close()
|
|
elseif self.confirmBtn_obj == click_obj then
|
|
if not self.selectSex then
|
|
Message.show("请选择宝宝性别")
|
|
return
|
|
end
|
|
if HasLimitChar(self.input_text.text) then
|
|
Message.show("宝宝名存在非法字符,请重新输入")
|
|
return
|
|
end
|
|
local _, filter = LanguageFilter.FilterMsg(self.input_text.text)
|
|
if filter == false then
|
|
Message.show("内容有敏感词")
|
|
return
|
|
end
|
|
if Trim(self.input_text.text) == "" then
|
|
-- Message.show("名字不能为空")
|
|
--return
|
|
-- self.input_text.text = "宝宝"
|
|
end
|
|
local filter = LanguageFilter.NameFilter(self.input_text.text)
|
|
if filter == nil then
|
|
Message.show("角色名存在敏感词,请重新输入")
|
|
return
|
|
end
|
|
if string.find(self.input_text.text, "(<#f_%d>)") then
|
|
Message.show("该名字含有非法字符 ")
|
|
return
|
|
end
|
|
if EnglineVersion and AppConst_EnglineVer > 30 then
|
|
self.input_text.text = Util.SetNonBreakSpaceText(self.input_text.text)
|
|
end
|
|
local _name = Trim(self.input_text.text)
|
|
self:Close()
|
|
self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16502,self.selectSex,_name)
|
|
--self.model:Fire(ChildConst.OPEN_CHILD_BASE_VIEW,1,1,1)
|
|
|
|
elseif self.btn1_obj == click_obj then
|
|
self:ChoiceChild(true)
|
|
elseif self.btn2_obj == click_obj then
|
|
self:ChoiceChild(false)
|
|
end
|
|
end
|
|
AddClickEvent(self.btn_close_obj, on_click)
|
|
AddClickEvent(self.confirmBtn_obj, on_click)
|
|
AddClickEvent(self.btn1_obj, on_click)
|
|
AddClickEvent(self.btn2_obj, on_click)
|
|
end
|
|
|
|
function ChildGetView:UpdateView()
|
|
self:UpdateRoleModel( 1 )
|
|
self:UpdateRoleModel( 2 )
|
|
-- 默认选择
|
|
-- local function delay_method( )
|
|
-- self:ChoiceChild(true)
|
|
-- end
|
|
-- setTimeout(delay_method, 0.5)
|
|
|
|
--local marble_cost = self.model:GetConfigMarbleKvVal("marble_cost")
|
|
|
|
--[[if not self.item_list_com then
|
|
self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
|
|
end
|
|
local info = {
|
|
data_list = self.model.degree_cfg,
|
|
item_con = self.Content,
|
|
item_class = ChildGetViewItem,
|
|
item_width = 864,
|
|
item_height = 160,
|
|
-- space_x = 0,
|
|
-- space_y = 0,
|
|
start_x = 13.4,
|
|
start_y = -12.5,
|
|
scroll_view = self.ScrollView,
|
|
create_frequency = 0.02,
|
|
on_update_item = function(item, i, v)
|
|
item:SetData(v)
|
|
end,
|
|
}
|
|
self.item_list_com:UpdateItems(info)
|
|
self.item_list_com:ScrollToItem(self.model.degree,-17.5)]]
|
|
end
|
|
|
|
-- 更新孩子模型
|
|
function ChildGetView:UpdateRoleModel( child_sex )
|
|
local show_figure_id = self.model:GetChildOriginalModelID(child_sex)
|
|
local parent = child_sex == 1 and self.babyConLeft or self.babyConRight
|
|
-- local rotate = child_sex == 1 and Vector3(0, 160, 0) or Vector3(0, 0, 0)
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = parent,
|
|
fashion_type = FuncOpenModel.TypeId.Child,
|
|
figure_id = show_figure_id,
|
|
ui_model_type = UIModelCommon.ModelType.RT,
|
|
can_rotate = false,
|
|
scale = 300,
|
|
-- rotate = rotate,
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
end
|
|
|
|
function ChildGetView:ChoiceChild(isLeft)
|
|
self.con_select_boy_obj:SetActive(isLeft)
|
|
self.con_talk_boy_obj:SetActive(isLeft)
|
|
self.con_select_girl_obj:SetActive(not isLeft)
|
|
self.con_talk_girl_obj:SetActive(not isLeft)
|
|
-- if self.hide_con_timer_id then
|
|
-- GlobalTimerQuest:CancelQuest(self.hide_con_timer_id)
|
|
-- self.hide_con_timer_id = nil
|
|
-- end
|
|
-- SetImageGray(self.light1_img, not isLeft)
|
|
-- SetImageGray(self.light2_img, isLeft)
|
|
self.light1_obj:SetActive(not isLeft)
|
|
self.light2_obj:SetActive(isLeft)
|
|
if isLeft then
|
|
self.input_text.text = "蓝宝宝"
|
|
self.selectSex = 1
|
|
-- local function delay( )
|
|
-- self.con_talk_boy_obj:SetActive(false)
|
|
-- end
|
|
-- self.hide_con_timer_id = GlobalTimerQuest:AddDelayQuest(delay, 2)
|
|
-- self.btn1_obj:SetActive(false)
|
|
-- self.btn2_obj:SetActive(true)
|
|
-- self.babyConLeft_raw.material = UIModelClassByRT.RT_Material.render_texture
|
|
-- self.babyConRight_raw.material = UIModelClassByRT.RT_Material.gray
|
|
else
|
|
self.input_text.text = "粉宝宝"
|
|
self.selectSex = 2
|
|
-- local function delay( )
|
|
-- self.con_talk_girl_obj:SetActive(false)
|
|
-- end
|
|
-- self.hide_con_timer_id = GlobalTimerQuest:AddDelayQuest(delay, 2)
|
|
|
|
-- self.btn1_obj:SetActive(true)
|
|
-- self.btn2_obj:SetActive(false)
|
|
-- self.babyConLeft_raw.material = UIModelClassByRT.RT_Material.gray
|
|
-- self.babyConRight_raw.material = UIModelClassByRT.RT_Material.render_texture
|
|
-- SetImageGray(self.light1_img, true)
|
|
-- SetImageGray(self.light2_img, false)
|
|
end
|
|
|
|
end
|
|
function ChildNiceRecordView:SetCallBack(callBack)
|
|
self.callBack = callBack
|
|
end
|
|
|
|
function ChildGetView:DestroySuccess( )
|
|
-- if self.hide_con_timer_id then
|
|
-- GlobalTimerQuest:CancelQuest(self.hide_con_timer_id)
|
|
-- self.hide_con_timer_id = nil
|
|
-- end
|
|
end
|