源战役客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

240 rader
8.1 KiB

1 månad sedan
  1. ChildGetView = ChildGetView or BaseClass(BaseView)
  2. local ChildGetView = ChildGetView
  3. function ChildGetView:__init()
  4. self.base_file = "child"
  5. self.layout_file = "ChildGetView"
  6. self.layer_name = "UI"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.hide_maincancas = true
  10. self.change_scene_close = true
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.model = ChildModel:GetInstance()
  13. self.selectSex = false
  14. self.load_callback = function ()
  15. self:LoadSuccess()
  16. self:AddEvent()
  17. end
  18. self.open_callback = function ( )
  19. self:UpdateView()
  20. end
  21. self.destroy_callback = function ( )
  22. self:DestroySuccess()
  23. end
  24. end
  25. function ChildNiceRecordView:Open(data,callBack)
  26. self.data = data
  27. self.callBack = callBack
  28. BaseView.Open(self)
  29. end
  30. function ChildGetView:LoadSuccess()
  31. local nodes = {
  32. "bg:obj:img","btn_close:obj",
  33. "confirmBtn:obj","btn2:obj:raw","btn1:obj:raw",
  34. "moneyBg_right/num_right:txt","moneyBg_left/num_left:txt",
  35. "moneyBg_left/moneyIcon_left:img", "moneyBg_right/moneyIcon_right:img",
  36. "babyConLeft:raw", "babyConRight:raw",
  37. "light2:img:obj", "light1:img:obj",
  38. "con_talk_girl/lb_talk_girl:tmp", "con_talk_boy/lb_talk_boy:tmp",
  39. "con_select_girl:obj", "con_talk_boy:obj",
  40. "con_select_boy:obj", "con_talk_girl:obj",
  41. }
  42. self:GetChildren(nodes)
  43. self.lb_talk_girl_tmp.text = "嘿嘿,人家是漂亮的女孩子哦!"
  44. self.lb_talk_boy_tmp.text = "嘻嘻,我是可爱的男孩子哦!"
  45. self.con_select_boy_obj:SetActive(false)
  46. self.con_talk_boy_obj:SetActive(false)
  47. self.con_select_girl_obj:SetActive(false)
  48. self.con_talk_girl_obj:SetActive(false)
  49. self.input_text = self:GetChild("input"):GetComponent("InputField")
  50. lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetChildIcon("child_get_view_bg"), false)
  51. lua_resM:setOutsideImageSprite(self, self.light1_img, GameResPath.GetChildIcon("child_get_light_bg"), false)
  52. lua_resM:setOutsideImageSprite(self, self.light2_img, GameResPath.GetChildIcon("child_get_light_bg"), false)
  53. -- 微调宝宝模型的位置
  54. SetAnchoredPosition(self.btn1, -228, 22)
  55. SetAnchoredPosition(self.babyConLeft, -214, 50)
  56. SetAnchoredPosition(self.btn2, 252, 22)
  57. SetAnchoredPosition(self.babyConRight, 234, 50)
  58. -- 下面是模型反向的参数
  59. -- SetAnchoredPosition(self.btn1, -228 -23, 22)
  60. -- SetAnchoredPosition(self.babyConLeft, -214 - 23, 50)
  61. -- SetAnchoredPosition(self.btn2, 252 -23, 22)
  62. -- SetAnchoredPosition(self.babyConRight, 234 -23, 50)
  63. -- SetLocalScale(self.babyConLeft, -1, 1, 1)
  64. -- SetLocalScale(self.babyConRight, -1, 1, 1)
  65. -- self.light1_obj:SetActive(false)
  66. -- self.light2_obj:SetActive(false)
  67. local active_cost = stringtotable(self.model:GetConfigChildKvVal("active_cost"))
  68. self.num_left_txt.text = active_cost[1][3]
  69. self.num_right_txt.text = active_cost[1][3]
  70. local asset, source = WordManager:GetCommonMoneyIcon(tonumber(active_cost[1][1]))
  71. lua_resM:setImageSprite(self, self.moneyIcon_left_img, asset, source, true)
  72. lua_resM:setImageSprite(self, self.moneyIcon_right_img, asset, source, true)
  73. end
  74. function ChildGetView:AddEvent()
  75. local on_click = function ( click_obj )
  76. if self.btn_close_obj == click_obj then
  77. self:Close()
  78. elseif self.confirmBtn_obj == click_obj then
  79. if not self.selectSex then
  80. Message.show("请选择宝宝性别")
  81. return
  82. end
  83. if HasLimitChar(self.input_text.text) then
  84. Message.show("宝宝名存在非法字符,请重新输入")
  85. return
  86. end
  87. local _, filter = LanguageFilter.FilterMsg(self.input_text.text)
  88. if filter == false then
  89. Message.show("内容有敏感词")
  90. return
  91. end
  92. if Trim(self.input_text.text) == "" then
  93. -- Message.show("名字不能为空")
  94. --return
  95. -- self.input_text.text = "宝宝"
  96. end
  97. local filter = LanguageFilter.NameFilter(self.input_text.text)
  98. if filter == nil then
  99. Message.show("角色名存在敏感词,请重新输入")
  100. return
  101. end
  102. if string.find(self.input_text.text, "(<#f_%d>)") then
  103. Message.show("该名字含有非法字符 ")
  104. return
  105. end
  106. if EnglineVersion and AppConst_EnglineVer > 30 then
  107. self.input_text.text = Util.SetNonBreakSpaceText(self.input_text.text)
  108. end
  109. local _name = Trim(self.input_text.text)
  110. self:Close()
  111. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16502,self.selectSex,_name)
  112. --self.model:Fire(ChildConst.OPEN_CHILD_BASE_VIEW,1,1,1)
  113. elseif self.btn1_obj == click_obj then
  114. self:ChoiceChild(true)
  115. elseif self.btn2_obj == click_obj then
  116. self:ChoiceChild(false)
  117. end
  118. end
  119. AddClickEvent(self.btn_close_obj, on_click)
  120. AddClickEvent(self.confirmBtn_obj, on_click)
  121. AddClickEvent(self.btn1_obj, on_click)
  122. AddClickEvent(self.btn2_obj, on_click)
  123. end
  124. function ChildGetView:UpdateView()
  125. self:UpdateRoleModel( 1 )
  126. self:UpdateRoleModel( 2 )
  127. -- 默认选择
  128. -- local function delay_method( )
  129. -- self:ChoiceChild(true)
  130. -- end
  131. -- setTimeout(delay_method, 0.5)
  132. --local marble_cost = self.model:GetConfigMarbleKvVal("marble_cost")
  133. --[[if not self.item_list_com then
  134. self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
  135. end
  136. local info = {
  137. data_list = self.model.degree_cfg,
  138. item_con = self.Content,
  139. item_class = ChildGetViewItem,
  140. item_width = 864,
  141. item_height = 160,
  142. -- space_x = 0,
  143. -- space_y = 0,
  144. start_x = 13.4,
  145. start_y = -12.5,
  146. scroll_view = self.ScrollView,
  147. create_frequency = 0.02,
  148. on_update_item = function(item, i, v)
  149. item:SetData(v)
  150. end,
  151. }
  152. self.item_list_com:UpdateItems(info)
  153. self.item_list_com:ScrollToItem(self.model.degree,-17.5)]]
  154. end
  155. -- 更新孩子模型
  156. function ChildGetView:UpdateRoleModel( child_sex )
  157. local show_figure_id = self.model:GetChildOriginalModelID(child_sex)
  158. local parent = child_sex == 1 and self.babyConLeft or self.babyConRight
  159. -- local rotate = child_sex == 1 and Vector3(0, 160, 0) or Vector3(0, 0, 0)
  160. local res_data = {
  161. father_node = self,
  162. transform = parent,
  163. fashion_type = FuncOpenModel.TypeId.Child,
  164. figure_id = show_figure_id,
  165. ui_model_type = UIModelCommon.ModelType.RT,
  166. can_rotate = false,
  167. scale = 300,
  168. -- rotate = rotate,
  169. }
  170. FuncOpenModel:getInstance():SetModelRes(res_data)
  171. end
  172. function ChildGetView:ChoiceChild(isLeft)
  173. self.con_select_boy_obj:SetActive(isLeft)
  174. self.con_talk_boy_obj:SetActive(isLeft)
  175. self.con_select_girl_obj:SetActive(not isLeft)
  176. self.con_talk_girl_obj:SetActive(not isLeft)
  177. -- if self.hide_con_timer_id then
  178. -- GlobalTimerQuest:CancelQuest(self.hide_con_timer_id)
  179. -- self.hide_con_timer_id = nil
  180. -- end
  181. -- SetImageGray(self.light1_img, not isLeft)
  182. -- SetImageGray(self.light2_img, isLeft)
  183. self.light1_obj:SetActive(not isLeft)
  184. self.light2_obj:SetActive(isLeft)
  185. if isLeft then
  186. self.input_text.text = "蓝宝宝"
  187. self.selectSex = 1
  188. -- local function delay( )
  189. -- self.con_talk_boy_obj:SetActive(false)
  190. -- end
  191. -- self.hide_con_timer_id = GlobalTimerQuest:AddDelayQuest(delay, 2)
  192. -- self.btn1_obj:SetActive(false)
  193. -- self.btn2_obj:SetActive(true)
  194. -- self.babyConLeft_raw.material = UIModelClassByRT.RT_Material.render_texture
  195. -- self.babyConRight_raw.material = UIModelClassByRT.RT_Material.gray
  196. else
  197. self.input_text.text = "粉宝宝"
  198. self.selectSex = 2
  199. -- local function delay( )
  200. -- self.con_talk_girl_obj:SetActive(false)
  201. -- end
  202. -- self.hide_con_timer_id = GlobalTimerQuest:AddDelayQuest(delay, 2)
  203. -- self.btn1_obj:SetActive(true)
  204. -- self.btn2_obj:SetActive(false)
  205. -- self.babyConLeft_raw.material = UIModelClassByRT.RT_Material.gray
  206. -- self.babyConRight_raw.material = UIModelClassByRT.RT_Material.render_texture
  207. -- SetImageGray(self.light1_img, true)
  208. -- SetImageGray(self.light2_img, false)
  209. end
  210. end
  211. function ChildNiceRecordView:SetCallBack(callBack)
  212. self.callBack = callBack
  213. end
  214. function ChildGetView:DestroySuccess( )
  215. -- if self.hide_con_timer_id then
  216. -- GlobalTimerQuest:CancelQuest(self.hide_con_timer_id)
  217. -- self.hide_con_timer_id = nil
  218. -- end
  219. end