| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- local UINewCreateRoleView = require("UICreateRole/UINewCreateRoleView_Generate")
- local RoleViewSystem = require("RoleViewSystem")
- local PreviewSystem = require("PreviewSystem")
- local BoxCollider = typeof(UnityEngine.BoxCollider)
- local maleViewSystem = nil
- local femaleViewSystem = nil
- function UINewCreateRoleView:OnAwake(data)
- self.controller = require("UICreateRole/UINewCreateRoleCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- end
- function UINewCreateRoleView:AddEventListener()
- -- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SELECT_ROLE,self,self.OnSelectRole);
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_USED_ACTIVATIONCODE,self,self.OnUsedActivationCode)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CLOSED_ACTIVATIONCODE,self,self.OnCloseActivationCode)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CREATE_ROLE_FAILED,self,self.OnCreateRoleFailed)
- end
- function UINewCreateRoleView:FillContent(data, uiBase)
- self.uiBase = uiBase
- local gameObject = self.uiBase:GetRoot()
- if gameObject ~= nil then
- self.gameObject = gameObject
- self.transform = gameObject.transform
- end
- self:InitGenerate(self.transform, data)
- self.firstSelected = true
- self:Init()
-
- self.rewardHideState = true
- self:InitComs(false)
- --self.notice:SetActive(false)
- self.createAnim.animator:Play("BannerKeepOut")
- --self.delayShowNoticeTimer = ManagerContainer.LuaTimerMgr:AddTimer(3000, 1, self, self.DelayHideNotice, nil)
- end
- function UINewCreateRoleView:DelayHideNotice()
- self.createAnim.animator:Play("BannerKeepOut")
- self.createAnim:SetActive(false)
- self.btnBox:SetActive(false)
- self.delayShowNoticeTimer = ManagerContainer.LuaTimerMgr:AddTimer(24000, 1, self, self.DelayShowNotice, nil)
- end
- function UINewCreateRoleView:DelayShowNotice()
- --self.notice:SetActive(true)
- self.delayShowNoticeTimer = ManagerContainer.LuaTimerMgr:AddTimer(3000, 1, self, self.DelayShowbtnBox, nil)
- end
- function UINewCreateRoleView:DelayShowbtnBox()
-
- self.btnBox:SetActive(true)
- self.delayShowNoticeTimer = ManagerContainer.LuaTimerMgr:AddTimer(3000, 1, self, self.DelayShowcreateAnim, nil)
- end
- function UINewCreateRoleView:DelayShowcreateAnim()
-
- self.createAnim:SetActive(true)
- self.createAnim.animator:Play("BannerKeepOut")
- end
- function UINewCreateRoleView:Init()
- LuaBattleBridge.SetCreateRoleLuaTable(self.controller)
-
- self.malePos = ManagerContainer.LuaGameMgr.CreateMaleRoot.transform.position
- self.femalePos = ManagerContainer.LuaGameMgr.CreateFemaleRoot.transform.position
- self.showPos = ManagerContainer.LuaGameMgr.CreateShowRoot.transform.position
- LuaBattleBridge.ShowCreateRoleCam()
- self.sendCreateRole = nil
- self.sendCreateRoleTime = nil
- self.IsOpeningActivationCodePage = false
- self.backBtn:SetActive(false)
- self:SetTexture()
- end
- function UINewCreateRoleView:SetLayer(trans, layer, enterChild)
- if not trans then return end
- trans.gameObject.layer = layer
- if not enterChild then return end
- for i = 0, trans.childCount - 1 do
- self:SetLayer(trans:GetChild(i), layer, enterChild)
- end
- end
- function UINewCreateRoleView:SetTexture()
- if not self.modeTexture then
- return
- end
- local w = UnityEngine.Screen.width
- local h = UnityEngine.Screen.height
- local texture = UnityEngine.RenderTexture(w,h,0)
- self.modeTexture.rawImage.texture = texture
- --self.modeTexture.rawImage:SetNativeSize()
- UnityEngine.Camera.main.targetTexture = texture
- self:SetLayer(self.FxObj.transform,10,true)
- end
- function UINewCreateRoleView:InitComs(vis)
- self.confirmBtn:SetActive(vis)
- -- self.backBtn:SetActive(vis)
- self.shadow:SetActive(vis)
- self.grass:SetActive(vis)
- self.notice:SetActive(not vis)
- end
- function UINewCreateRoleView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UINewCreateRoleView:AddUIEventListener()
- self.uiBase:AddButtonEventListener(self.confirmBtn.button,self, self.OnClickCreateRole)
- -- self.uiBase:AddButtonEventListener(self.backBtn.button,self,self.OnClickBack)
- end
- function UINewCreateRoleView:OnHide()
- end
- function UINewCreateRoleView:OnShow(data)
- self.controller:SetData(data)
- self:Init()
- end
- function UINewCreateRoleView:OnClose()
- if self.delayCreateRoleTimer ~= nil then
- ManagerContainer.LuaTimerMgr:RemoveTimer(self.delayCreateRoleTimer)
- self.delayCreateRoleTimer = nil
- end
- if self.delayHideRoleTimer ~= nil then
- ManagerContainer.LuaTimerMgr:RemoveTimer(self.delayHideRoleTimer)
- self.delayHideRoleTimer = nil
- end
- if self.delayShowNoticeTimer ~= nil then
- ManagerContainer.LuaTimerMgr:RemoveTimer(self.delayShowNoticeTimer)
- self.delayShowNoticeTimer = nil
- end
- self.selectGo = nil
- ManagerContainer.LuaGameMgr:SetCreateRoleStatus(false)
- LuaBattleBridge.ClearCreateRole()
- end
- function UINewCreateRoleView:OnDispose()
- self.startAnimEnd = nil
- if self.rewardTimer then
- if self.rewardTimer.running then
- self.rewardTimer:Stop()
- end
- self.rewardTimer = nil
- end
- self.rewardHideState = nil
- end
- function UINewCreateRoleView:OnClickCreateRole()
- if self:IsSendCreating() then
- return
- end
- self.activationCode = nil
- if ManagerContainer.LuaGameMgr.IsActivationCodeMode then
- self:OnOpenActivationCodePage()
- else
- self:HandleCreateRole()
- end
- end
- function UINewCreateRoleView:OnCloseActivationCode()
- self.IsOpeningActivationCodePage = false
- end
- function UINewCreateRoleView:OnUsedActivationCode(code)
- self.IsOpeningActivationCodePage = false
- self.activationCode = code
- self:HandleCreateRole()
- end
- function UINewCreateRoleView:HandleCreateRole()
- if self.controller:GetSexType() == Enum.SexType.Man then
- if self.controller.maleAnimator ~= nil then
- -- self.controller.maleAnimator:Play("f_show")
- end
- else
- if self.controller.femaleAnimator ~= nil then
- -- self.controller.femaleAnimator:Play("f_show")
- end
- end
- if self:IsSendCreating() then return end
- self.sendCreateRole = true
- self.sendCreateRoleTime = ManagerContainer.LuaTimerMgr.GetTimeSecond()
- self.controller:OnCreateClick(self.activationCode)
- self:ChangeRewardState(true)
- end
- function UINewCreateRoleView:DelayCreateRole()
- ManagerContainer.DataMgr.UserData:StartEnterGame(true)
- end
- function UINewCreateRoleView:DelayHideRole()
- LuaBattleBridge.SetGameObjectLayerFrom(ManagerContainer.LuaGameMgr.CreateMaleRoot,"Fighter","Hide")
- LuaBattleBridge.SetGameObjectLayerFrom(ManagerContainer.LuaGameMgr.CreateFemaleRoot,"Fighter","Hide")
- end
- function UINewCreateRoleView:OnCreateRoleFailed(error)
- if error == Enum.NetErrorCode.ERROR_OK then
- self.sendCreateRoleTime = nil
- LuaBattleBridge.PlayCreateRoleTransferEffect()
- self.delayCreateRoleTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(135)*1000, 1, self, self.DelayCreateRole, nil)
- self.delayHideRoleTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(136)*1000, 1, self, self.DelayHideRole, nil)
- else
- self.sendCreateRole = nil
- self.sendCreateRoleTime = nil
- LuaBattleBridge.SetGameObjectLayerFrom(ManagerContainer.LuaGameMgr.CreateMaleRoot,"Hide","Fighter")
- LuaBattleBridge.SetGameObjectLayerFrom(ManagerContainer.LuaGameMgr.CreateFemaleRoot,"Hide","Fighter")
- -- 激活码错误
- if error == Enum.NetErrorCode.ERROR_ROLE_ACTIVE_CODE_ERROR or error == Enum.NetErrorCode.ERROR_ROLE_ACTIVECODE_USED then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("冒险码错误!")
- end
- end
- end
- function UINewCreateRoleView:OnOpenActivationCodePage()
- self.IsOpeningActivationCodePage = true
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIActivationCodePage)
- end
- function UINewCreateRoleView:OnClickBack()
- -- if self.selectGo == nil then
- -- return
- -- end
- -- if self.controller:GetSexType() == Enum.SexType.Man then
- -- LuaBattleBridge.PlayCamAnim("CM_vcam5",false)
- -- if self.controller.maleAnimator ~= nil then
- -- self.controller.maleAnimator:Play("f_go")
- -- end
- -- if self.controller.femaleAnimator ~= nil then
- -- self.controller.femaleAnimator:Play("f_Ahead")
- -- end
- -- else
- -- LuaBattleBridge.PlayCamAnim("CM_vcam4",false)
- -- if self.controller.femaleAnimator ~= nil then
- -- self.controller.femaleAnimator:Play("f_go")
- -- end
- -- if self.controller.maleAnimator ~= nil then
- -- self.controller.maleAnimator:Play("f_Ahead")
- -- end
- -- end
- -- self.controller:SetSexType(nil)
- -- self:InitComs(false)
- -- LuaBattleBridge.CloseDof()
- end
- function UINewCreateRoleView:OnSelectRole(isMale,go)
- if self.IsOpeningActivationCodePage then
- return false
- end
- if self:IsSendCreating() then
- return false
- end
- if not self.startAnimEnd then
- if LuaBattleBridge.IsPlayCamAnimEnd("CM_vcam1") then
- self.startAnimEnd = true
- else
- return false
- end
- end
-
- -- if self.controller:GetSexType() ~= nil then
- -- self:CancelSelected()
- -- return
- -- end
- -- LogError("OnSelectRole = " .. tostring(isMale) .." type=" .. tostring(self.controller:GetSexType()))
- if self.controller:GetSexType() == Enum.SexType.Man and isMale then
- return false
- end
- if self.controller:GetSexType() == Enum.SexType.Woman and isMale == false then
- return false
- end
- self.selectGo = go
- if isMale then
- self.controller:SetSexType(Enum.SexType.Man)
- if self.firstSelected then
- LuaBattleBridge.PlayCamAnim("CM_vcam3",true)
- if self.controller.maleAnimator ~= nil then
- self.controller.maleAnimator:Play("f_Ahead_down")
- end
- if self.controller.femaleAnimator ~= nil then
- self.controller.femaleAnimator:Play("f_Ahead_go")
- end
- else
- LuaBattleBridge.PlayCamAnim("CM_vcam5",true)
- if self.controller.maleAnimator ~= nil then
- self.controller.maleAnimator:Play("f_back")
- end
- if self.controller.femaleAnimator ~= nil then
- self.controller.femaleAnimator:Play("f_Ahead_go")
- end
- end
- else
- self.controller:SetSexType(Enum.SexType.Woman)
- if self.firstSelected then
- LuaBattleBridge.PlayCamAnim("CM_vcam2",true)
- if self.controller.maleAnimator ~= nil then
- self.controller.maleAnimator:Play("f_Ahead_go")
- end
- if self.controller.femaleAnimator ~= nil then
- self.controller.femaleAnimator:Play("f_Ahead_down")
- end
- else
- LuaBattleBridge.PlayCamAnim("CM_vcam4",true)
- if self.controller.femaleAnimator ~= nil then
- self.controller.femaleAnimator:Play("f_back")
- end
- if self.controller.maleAnimator ~= nil then
- self.controller.maleAnimator:Play("f_Ahead_go")
- end
- end
- end
- self:InitComs(true)
- self.firstSelected = false
- self:ChangeRewardState(true)
- if self.rewardTimer then
- self.rewardTimer.time = 1.8
- self.rewardTimer.loop = 1
- else
- self.rewardTimer = Timer.New(slot(self.ChangeRewardState, self), 1.8, 1)
- end
- if not self.rewardTimer.running then
- self.rewardTimer:Start()
- end
- return true
- end
- function UINewCreateRoleView:CancelSelected()
- if self.IsOpeningActivationCodePage then
- return
- end
- self:OnClickBack()
- end
- function UINewCreateRoleView:IsSendCreating()
- if not self.sendCreateRole then
- return false
- end
- if self.sendCreateRoleTime then
- if ManagerContainer.LuaTimerMgr.GetTimeSecond() - self.sendCreateRoleTime > 10 then
- return false
- end
- end
- return true
- end
- function UINewCreateRoleView:ChangeRewardState(hide)
- if self.rewardHideState == hide then
- return
- end
- self.rewardHideState = hide
- if not hide then
- self.createAnim.animator:CrossFade("BannerIn", 0.2)
- else
- self.createAnim.animator:CrossFade("BannerOut", 0.2)
- end
- end
- return UINewCreateRoleView
|