UINewCreateRoleCtr.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. local UINewCreateRoleCtr = class("UINewCreateRoleCtr", require("UICtrBase"))
  2. function UINewCreateRoleCtr:Init(view)
  3. self.view = view
  4. self.sexType = nil
  5. self.maleAnimator = nil
  6. self.femaleAnimator = nil
  7. end
  8. function UINewCreateRoleCtr:SetData(data)
  9. self.asyncIdx = 0
  10. if data == nil then return end
  11. self.data = data
  12. end
  13. function UINewCreateRoleCtr:GetAsyncIdx()
  14. self.asyncIdx = self.asyncIdx + 1
  15. return self.asyncIdx
  16. end
  17. function UINewCreateRoleCtr:GetData()
  18. return self.data
  19. end
  20. function UINewCreateRoleCtr:OnDispose()
  21. self.data = nil
  22. self.view = nil
  23. self.maleAnimator = nil
  24. self.femaleAnimator = nil
  25. end
  26. function UINewCreateRoleCtr:GetSexType()
  27. return self.sexType
  28. end
  29. function UINewCreateRoleCtr:SetSexType(newSexType)
  30. self.sexType = newSexType
  31. end
  32. function UINewCreateRoleCtr:GetMaleCfgId()
  33. return CommonUtil.JobIdToRoleId(GlobalConfig.Instance:GetConfigIntValue(GlobalConfig.c_default_profession), Enum.SexType.Man)
  34. end
  35. function UINewCreateRoleCtr:GetFemaleCfgId()
  36. return CommonUtil.JobIdToRoleId(GlobalConfig.Instance:GetConfigIntValue(GlobalConfig.c_default_profession), Enum.SexType.Woman)
  37. end
  38. function UINewCreateRoleCtr:SetActorAnim(maleAnim,femaleAnim)
  39. self.maleAnimator = maleAnim
  40. self.femaleAnimator = femaleAnim
  41. end
  42. function UINewCreateRoleCtr:OnSelectRole(isMale,go)
  43. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SELECT_ROLE,isMale,go)
  44. if self.view ~= nil then
  45. return self.view:OnSelectRole(isMale,go)
  46. end
  47. return false
  48. end
  49. function UINewCreateRoleCtr:CancelSelected()
  50. if self.view ~= nil then
  51. self.view:CancelSelected()
  52. end
  53. end
  54. function UINewCreateRoleCtr:OnCreateClick(activationCode)
  55. local country = GlobalConfig.Instance:GetConfigIntValue(GlobalConfig.c_default_country)
  56. local openId = ManagerContainer.LuaGameMgr.openId
  57. local jobId = GlobalConfig.Instance:GetConfigIntValue(GlobalConfig.c_default_profession)
  58. LogWarning("userName = " .. tostring(openId) .. " job_id = " .. tostring(jobId) .. " sex = " .. self.sexType .. "activationCode = " .. tostring(activationCode))
  59. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CREATE_ROLE_REQ, {open_id = openId, job_id = jobId, sex = self.sexType, country = country , active_code = activationCode})
  60. end
  61. return UINewCreateRoleCtr