UIPetLvUpView.lua 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. local UIPetLvUpView = require("UIPet/UIPetLvUpView_Generate")
  2. local PetViewSystem = require("PetViewSystem")
  3. local PreviewSystem = require("PreviewSystem")
  4. local ColorExtension = require("ColorExtension")
  5. local IconItemCtr = require("Common/IconItemCtr")
  6. local LvUpPage = {
  7. LvUp = 1,
  8. SkillUp = 2,
  9. }
  10. local pageToggleData = {}
  11. local curModel = nil
  12. local previewSystem = nil
  13. local petViewSystem = nil
  14. local isZenyLack = false
  15. local isExpLack = false
  16. local skillUpCost
  17. local attrSortList
  18. local SkillFxSpeedList = {0.25,0.125,0.0625,1}
  19. local StampSlotCount = 6
  20. local attrsShowState = false
  21. function UIPetLvUpView:OnAwake(data)
  22. self.controller = require("UIPet/UIPetLvUpCtr"):new()
  23. self.controller:SetData(data)
  24. self.controller:Init(self)
  25. end
  26. function UIPetLvUpView:AddEventListener()
  27. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  28. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_LVUP_REFRESH_NTF, self, self.OnLvUpNtf)
  29. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_ADVENCE_REFRESH_NTF, self, self.OnAdvenceCallBackNtf)
  30. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_SKILLUP_REFRESH_NTF, self, self.OnSkillUpMatNtf)
  31. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_SKILLUP_SUCCESS_NTF, self, self.OnSkillUpSuccessNtf)
  32. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, self, self.RefreshTopOwnedRes)
  33. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_BATTLE_SUCCESS_NTF, self, self.BattleChanged)
  34. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_STAMP_SLOT_REFRESH, self, self.OnSlotRefreshNtf)
  35. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SIDEFIGHTPOWER_REFRESH, self, self.ShowFightPower)
  36. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.FIGHTPOWER_REFRESH, self, self.ShowFightPower)
  37. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ACTOR_SERVER_CHANGE_ATTRS, self, self.OnAttrChange)
  38. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PET_DETAIL_QUERY_SUCCESS, self, self.OnPetDetailQuerySuccess)
  39. end
  40. function UIPetLvUpView:FillContent(data, uiBase)
  41. self.uiBase = uiBase
  42. local gameObject = self.uiBase:GetRoot()
  43. if gameObject ~= nil then
  44. self.gameObject = gameObject
  45. self.transform = gameObject.transform
  46. end
  47. self:InitGenerate(self.transform, data)
  48. self:Init()
  49. end
  50. --同步当前面板宠物属性
  51. function UIPetLvUpView:SyncSverPetData()
  52. local actorData = self.controller:GetPetActorData()
  53. if not actorData then
  54. return
  55. end
  56. self.SyncCbId = ManagerContainer.LuaActorAttributeMgr:SyncServerActorData(actorData,function()
  57. self:RefreshPetTotalAttrs()
  58. self:RefreshAttrs()
  59. end
  60. )
  61. end
  62. function UIPetLvUpView:OnAttrChange(tbArrtDeffrent)
  63. --LogError(Inspect(tbArrtDeffrent))
  64. --LogError("Refresh pet Attr")
  65. self.controller:AttrsChanged(tbArrtDeffrent)
  66. self:RefreshPetTotalAttrs()
  67. self:RefreshAttrs()
  68. end
  69. function UIPetLvUpView:Init()
  70. self.model:SetActive(false)
  71. self:RefreshTopOwnedRes()
  72. skillUpCost = GlobalConfig.Instance:GetConfigIntValue(207)
  73. attrSortList = {}
  74. for k,v in pairs(Enum.HeroAttrType) do
  75. attrSortList[#attrSortList + 1] = v
  76. end
  77. table.sort(attrSortList, function (a,b)
  78. return a < b
  79. end)
  80. end
  81. function UIPetLvUpView:OnPetDetailQuerySuccess()
  82. self.model:SetActive(true)
  83. self:RefresPetRP()
  84. CommonUtil.CreateToggleMouduleOnlyBtns(self, pageToggleData, self.toggleGroup, LvUpPage.LvUp, self.OnValueChangedToggle)
  85. self:LoadPars()
  86. self:ResetPetView()
  87. self:CloseTotalAttr()
  88. self:Refresh()
  89. self.advenceOK:SetActive(false)
  90. self:SyncSverPetData()
  91. self:RefreshPetStamps()
  92. end
  93. function UIPetLvUpView:CloseTotalAttr()
  94. self.lvUpNode.animator:Play("MoveBoxHide")
  95. attrsShowState = false
  96. self.iconUp:SetActive(attrsShowState)
  97. self.iconDown:SetActive(not attrsShowState)
  98. self.UpDownText.uILocalizeScript:SetContent("BtnDetails")
  99. end
  100. function UIPetLvUpView:OnPageInEnd()
  101. self.controller:QueryPetDetailInfo()
  102. self.super.OnPageInEnd(self)
  103. end
  104. function UIPetLvUpView:LoadPars()
  105. if self.top.uIEffectCfg and not self.top.uIEffectCfg.Ready then
  106. self.top.uIEffectCfg:LoadEffect()
  107. end
  108. if self.skillView.uIEffectCfg and not self.skillView.uIEffectCfg.Ready then
  109. self.skillView.uIEffectCfg:LoadEffect()
  110. end
  111. end
  112. function UIPetLvUpView:ResetPetView()
  113. local petData = self.controller:GetCurPetData()
  114. if not petData then return end
  115. local petCfgData = ManagerContainer.CfgMgr:GetPetDataById(petData.cfgId)
  116. local camPos = petCfgData.CamPos or {-0.116, 2.28, 3.89}
  117. local camRot = petCfgData.CamRot or {12.174, 177.372, 0.085}
  118. if not previewSystem then
  119. previewSystem = PreviewSystem:new("Role", 1024, 1024)
  120. end
  121. previewSystem:SetView(Vector3(camPos[1], camPos[2], camPos[3]), Quaternion.Euler(camRot[1], camRot[2], camRot[3]))
  122. self:RemoveCurModel()
  123. self.model.rawImage.texture = previewSystem:GetRenderTexture()
  124. self:RefreshPetView(petData)
  125. local multiply = petCfgData.ConversionRate*0.0001
  126. self.lvUpNode.text.uILocalizeScript:SetContentAndValues("DscAttrToRole", {multiply*100})
  127. end
  128. function UIPetLvUpView:RemoveCurModel()
  129. if previewSystem and curModel ~= nil then
  130. curModel:SetActive(false)
  131. previewSystem:RemoveGo(curModel)
  132. petViewSystem:Recycle()
  133. curModel = nil
  134. end
  135. end
  136. function UIPetLvUpView:RefreshPetView(petData)
  137. if petData == nil then return nil end
  138. if not petViewSystem then
  139. petViewSystem = PetViewSystem:new()
  140. end
  141. return petViewSystem:RefreshView(Enum.RoleInEnvType.PetLvUp, petData.cfgId, petData.extGoesShowData, self, self.LoadModelCB)
  142. end
  143. function UIPetLvUpView:RefreshModleScale()
  144. local Scale = self.controller:GetScale()
  145. if nil ~= curModel then
  146. curModel.transform.localScale = Vector3.one * Scale
  147. end
  148. end
  149. function UIPetLvUpView:LoadModelCB(model)
  150. curModel = model
  151. if previewSystem and model ~= nil then
  152. previewSystem:UpdateGo(model)
  153. end
  154. curModel:SetActive(true)
  155. self:RefreshModleScale()
  156. --是否默认动作
  157. petViewSystem:RolePlayAni(curModel, "s_click")
  158. end
  159. function UIPetLvUpView:RefreshTopOwnedRes()
  160. local zenyOwned = CommonUtil.GetOwnResCountByItemId(Enum.ItemIds.Coin)
  161. local expOwned = ManagerContainer.DataMgr.UserData:GetResById(Enum.ItemIds.PetExp) or 0
  162. local crystalOwned = CommonUtil.GetOwnResCountByItemId(Enum.ItemIds.PetCrystal)
  163. self.currency.number.text.text = CommonUtil.FormatNumber(zenyOwned)
  164. self.currency1.number.text.text = CommonUtil.FormatNumber(expOwned)
  165. self.currency2.number.text.text = CommonUtil.FormatNumber(crystalOwned)
  166. end
  167. function UIPetLvUpView:Refresh()
  168. self:RefreshTop()
  169. self.baseSView.loopVerticalScrollRect:ClearCells()
  170. self.addSView.loopVerticalScrollRect:ClearCells()
  171. end
  172. function UIPetLvUpView:BattleChanged()
  173. self:Refresh()
  174. self:RefresPetRP()
  175. self:RefreshPetStamps()
  176. end
  177. function UIPetLvUpView:RefreshTop()
  178. local petData = self.controller:GetCurPetData()
  179. local petCfgData = ManagerContainer.CfgMgr:GetPetDataById(petData.cfgId)
  180. if not petCfgData then
  181. return
  182. end
  183. --LogError(Inspect(petData))
  184. self.btnGoOut:SetActive(not petData.isBattle)
  185. self.btnDown:SetActive(petData.isBattle)
  186. self.info.petName.text.text = petData.advanceLevel > 0 and I18N.T(petCfgData.Name).."+"..petData.advanceLevel or I18N.T(petCfgData.Name)
  187. self.stampSlots.battleInfo:SetActive(petData.heroId > 0)
  188. if petData.heroId > 0 then
  189. local content
  190. if petData.heroId == 1 then
  191. content = ManagerContainer.DataMgr.UserData:GetUserNickname()
  192. else
  193. local heroData = CommonUtil.GetHeroCfgDataByUid(petData.heroId)
  194. content = I18N.T(heroData.Name)
  195. end
  196. self.stampSlots.battleInfo.text.uILocalizeScript:SetContentAndValues("PetBattleFollow1", {content})
  197. end
  198. self:ShowFightPower()
  199. self:RefreshTopSkills()
  200. self:InitRoleNatureIcon()
  201. end
  202. function UIPetLvUpView:InitRoleNatureIcon()
  203. local petData = self.controller:GetCurPetData()
  204. local cfgData = ManagerContainer.CfgMgr:GetPetDataById(petData.cfgId)
  205. local natureId = cfgData.NatureType
  206. local natureCfgData = ManagerContainer.CfgMgr:GetNatureDataById(natureId)
  207. local icon = natureCfgData.Icon
  208. CommonUtil.LoadIcon(self, icon, function (sprite)
  209. self.btnNature.icon.image.sprite = sprite
  210. end)
  211. end
  212. function UIPetLvUpView:ShowFightPower()
  213. local id = self.controller:GetData()
  214. local Power = ManagerContainer.DataMgr.UserData:GetAsideFighterSvrPower(id,true)
  215. if nil ~= Power and -1 ~= Power then
  216. self.fightPower.num.text.text = Power
  217. else
  218. self.fightPower.num.text.text = ManagerContainer.DataMgr.PetDataMgr:GetTotalFightPower(id)
  219. end
  220. end
  221. function UIPetLvUpView:RefreshTopSkills()
  222. local petData = self.controller:GetCurPetData()
  223. for i = 1, 3 do
  224. local data = petData.skillList[i]
  225. local item = self.skillView["skillItem"..i]
  226. item:SetActive(data ~= nil)
  227. if data then
  228. local itemlua = CommonUtil.BindGridViewItem2Lua(self, 'SkillItem', item.gameObject)
  229. CommonUtil.SetCommonSkillItem(self, itemlua, data.cfgId, data.level, self.OnSkillClick, data)
  230. self["skill"..i.."Fx"].transform:SetParent(item.transform)
  231. self["skill"..i.."Fx"].rectTransform.anchoredPosition3D = Vector3.zero
  232. end
  233. end
  234. end
  235. function UIPetLvUpView:RefreshLvUpPage()
  236. local petData = self.controller:GetCurPetData()
  237. local curMaxLv = self.controller:GetCurPetMaxLv()
  238. self.LvNum.text.text = petData.level.."/"..curMaxLv
  239. CommonUtil.LoadIcon(self, Constant.Quality_CardType_Icons[petData.quality], function (sprite)
  240. self.LabelIcon.image.sprite = sprite
  241. end, self, "labelIcon")
  242. self:RefreshAttrs()
  243. self:RefreshLvUpCost()
  244. end
  245. function UIPetLvUpView:RefreshAttrs()
  246. local attrs = self.controller:GetSimpleSecondAttrs()
  247. if not attrs then return end
  248. local petData = self.controller:GetCurPetData()
  249. local relationAttrs = {}
  250. if petData.heroId == 0 then
  251. relationAttrs = self.controller:GetRelationAddAttrs()
  252. end
  253. local petStarIcon, textContent = CommonUtil.GetPetSkillStarIconAndColor(petData.skillList)
  254. CommonUtil.LoadIcon(self, petStarIcon, function (sprite)
  255. self.advence.image.sprite = sprite
  256. end)
  257. self.advenceLv.text.text = textContent
  258. local idx = 0
  259. for k,v in pairs(attrs) do
  260. idx = idx + 1
  261. local item = self["attrItem"..idx]
  262. item.text.uILocalizeScript:SetContent("Attr_" .. k)
  263. if k >= Enum.HeroAttrType.Life and k <= Enum.HeroAttrType.CastAcceleration then
  264. --v = SDataUtil.Add(v, relationAttrs[k] or 0)
  265. else
  266. if k >= Enum.HeroAttrType.Nature_None_Damage_Percent then
  267. v = SDataUtil.Add(v, (relationAttrs[k] and relationAttrs[k]*0.0001 or 0))
  268. end
  269. end
  270. item.number.text.text = CommonUtil.HeroAttrFormatValue(k, v)
  271. end
  272. end
  273. function UIPetLvUpView:RefreshLvUpCost()
  274. local petData = self.controller:GetCurPetData()
  275. local petExpData = ManagerContainer.CfgMgr:GetPetExpCfgDataById(petData.level)
  276. local expCost = petExpData["experience"..petData.quality] or 0
  277. local zenyCost = petExpData["CostMoney"..petData.quality] or 0
  278. if not petExpData or expCost == 0 or zenyCost == 0 then
  279. self.cost1:SetActive(false)
  280. self.cost2:SetActive(false)
  281. self.btnLvUp:SetActive(false)
  282. self.btnAdvence:SetActive(false)
  283. return
  284. end
  285. local zenyOwned = CommonUtil.GetOwnResCountByItemId(Enum.ItemIds.Coin)
  286. local expOwned = ManagerContainer.DataMgr.UserData:GetResById(Enum.ItemIds.PetExp) or 0
  287. CommonUtil.IsConditionOutColor(self.cost2.num.text, expCost > expOwned, expCost)
  288. isZenyLack = zenyCost > zenyOwned
  289. isExpLack = expCost > expOwned
  290. local curMaxLv, isMax = self.controller:GetCurPetMaxLv()
  291. local maxLv = self.controller:GetPetMaxLv()
  292. local lvUpState = petData.level < curMaxLv
  293. self.btnLvUp:SetActive(lvUpState)
  294. local advenceState = petData.level == curMaxLv and not isMax
  295. if advenceState then
  296. local petProgressCfgData = ManagerContainer.CfgMgr:GetPetProgressCfgDataById(petData.cfgId)
  297. local nextAdvenceLv = petData.advanceLevel + 1
  298. zenyCost = petProgressCfgData.CostMoney[nextAdvenceLv]
  299. end
  300. CommonUtil.IsConditionOutColor(self.cost1.num.text, zenyCost > zenyOwned, CommonUtil.FormatNumber(zenyCost))
  301. self.btnAdvence:SetActive(advenceState)
  302. self.cost1:SetActive(zenyCost >= 0 and not advenceState)
  303. self.cost2:SetActive(expCost >= 0 and not advenceState)
  304. self.cost.advanceDsc:SetActive(advenceState)
  305. end
  306. function UIPetLvUpView:RefreshSkillUpPage()
  307. local isMax = self.controller:IsSkillMax()
  308. local skillMatId = self.controller:GetSkillUpMat()
  309. self.item.owned:SetActive(skillMatId ~= nil and not isMax)
  310. self.item.unowned:SetActive(skillMatId == nil and not isMax)
  311. if skillMatId then
  312. local petData = ManagerContainer.DataMgr.PetDataMgr:GetPetDataById(skillMatId)
  313. if petData then
  314. petData.selected = 0
  315. end
  316. CommonUtil.UpdateItemPrefab(self, self.skillNode.iconPetItem, petData, Enum.ItemIEnterType.Pet, self, self.OnOpenMatUI)
  317. end
  318. self.item.max:SetActive(isMax)
  319. self:RefreshSkillUpCost()
  320. self.skillNode.number.text.text = skillMatId and "1/1" or "0/1"
  321. self.skillNode.btnOneKey.on:SetActive(skillMatId ~= nil)
  322. self.skillNode.btnOneKey.off:SetActive(skillMatId == nil)
  323. self.skillNode.btnOneKey.text.uILocalizeScript:SetContent(skillMatId == nil and "TextAutoChoose" or "TextAutoChoose_001")
  324. end
  325. local lackSkillUpCoin
  326. function UIPetLvUpView:RefreshSkillUpCost()
  327. self.cost1:SetActive(true)
  328. self.cost2:SetActive(false)
  329. self.cost.advanceDsc:SetActive(false)
  330. local zenyCost = skillUpCost
  331. local zenyOwned = CommonUtil.GetOwnResCountByItemId(Enum.ItemIds.Coin)
  332. lackSkillUpCoin = zenyOwned < zenyCost
  333. CommonUtil.IsConditionOutColor(self.cost1.num.text, zenyCost > zenyOwned, CommonUtil.FormatNumber(zenyCost))
  334. end
  335. function UIPetLvUpView:OnLvUpNtf()
  336. if self.top.uIEffectCfg then
  337. self.top.uIEffectCfg:HideEffect("FX_UI_ChongWuShengJi_01",self.lvFx.transform)
  338. self.top.uIEffectCfg:ShowEffect("FX_UI_ChongWuShengJi_01",self.lvFx.transform)
  339. end
  340. self:OnLvUpCallBackNtf()
  341. petViewSystem:RolePlayAni(curModel, "s_upgrade")
  342. if self.moreBoxAnim.activeSelf then
  343. self:RefreshPetTotalAttrs()
  344. end
  345. end
  346. function UIPetLvUpView:OnLvUpCallBackNtf()
  347. self:RefresPetRP()
  348. self:OnValueChangedToggle()
  349. if self.moreBoxAnim.activeSelf then
  350. self:RefreshPetTotalAttrs()
  351. end
  352. end
  353. function UIPetLvUpView:OnAdvenceCallBackNtf()
  354. local petData = self.controller:GetCurPetData()
  355. local petCfgData = ManagerContainer.CfgMgr:GetPetDataById(petData.cfgId)
  356. local petProgressCfgData = ManagerContainer.CfgMgr:GetPetProgressCfgDataById(petData.cfgId)
  357. self.info.petName.text.text = petData.advanceLevel > 0 and I18N.T(petCfgData.Name).."+"..petData.advanceLevel or I18N.T(petCfgData.Name)
  358. if petData then
  359. petData.selected = 0
  360. end
  361. CommonUtil.UpdateItemPrefab(self, self.advenceOK.iconPetItem, petData, Enum.ItemIEnterType.Pet)
  362. self.advenceOK.iconPetItem.petName.text.text = I18N.T(petCfgData.Name)
  363. self.advenceOK.iconPetItem.nameBg:SetActive(true)
  364. local data = petProgressCfgData["Attribute"..(petData.advanceLevel)]
  365. if data == nil then
  366. LogError(logicData.configId.." 宠物进阶 "..petData.advanceLevel.." 进阶属性错误")
  367. return
  368. end
  369. local curMaxLv, nextMaxLv = self.controller:GetCurAdvenceMaxLv()
  370. --self.attrs.lVLimit.text.text.text = I18N.T("LVLimit")
  371. self.advenceOK.lVLimit.number1.text.text = curMaxLv
  372. self.advenceOK.lVLimit.number2.text.text = nextMaxLv
  373. self.advenceOK.lVLimit:SetActive(true)
  374. local petData = self.controller:GetCurPetData()
  375. local relationAttrs = {}
  376. if petData.heroId == 0 then
  377. relationAttrs = self.controller:GetRelationAddAttrs()
  378. end
  379. local idx = 0
  380. for i = 1, 5 do
  381. local v = data[i]
  382. idx = idx + 1
  383. local attr = self.advenceOK["attr"..idx]
  384. attr:SetActive(v ~= nil)
  385. if attr and v then
  386. local key = v[1]
  387. local val = self.controller:GetCurPetAttr(key)
  388. if val then
  389. --if key >= Enum.HeroAttrType.Life and key <= Enum.HeroAttrType.CastAcceleration then
  390. -- val = SDataUtil.Add(val, relationAttrs[key] or 0)
  391. --else
  392. -- if key >= Enum.HeroAttrType.STR_Percent then
  393. -- val = SDataUtil.Add(val, (relationAttrs[key] and relationAttrs[key]*0.0001 or 0))
  394. -- end
  395. --end
  396. --val = SDataUtil.InvConvert(val)
  397. --attr.text.text.text = I18N.T("Attr_" .. v[1])
  398. --attr.number1.text.text = math.floor(val - v[2])
  399. --attr.number2.text.text = math.floor(val)
  400. val = SDataUtil.InvConvert(val)
  401. attr.text.text.text = I18N.T("Attr_" .. v[1])
  402. val = key > 21 and CommonUtil.GetPreciseDecimalFloor(val, 3) or math.floor(val)
  403. local val1 = key > 21 and CommonUtil.GetPreciseDecimalFloor(v[2]*0.0001, 3) or math.floor(v[2])
  404. attr.number1.text.text = CommonUtil.HeroAttrFormatValueNoSign(key, val - val1, true)
  405. attr.number2.text.text = CommonUtil.HeroAttrFormatValueNoSign(key, val, true)
  406. end
  407. end
  408. end
  409. self.advenceOK:SetActive(true)
  410. self:OnLvUpCallBackNtf()
  411. self:ShowFightPower()
  412. petViewSystem:RolePlayAni(curModel, "s_advance")
  413. end
  414. function UIPetLvUpView:OnValueChangedToggle()
  415. self.lvUpNode:SetActive(pageToggleData.toggleDefaultIndex == LvUpPage.LvUp)
  416. self.skillNode:SetActive(pageToggleData.toggleDefaultIndex == LvUpPage.SkillUp)
  417. self.btnLvUp:SetActive(pageToggleData.toggleDefaultIndex == LvUpPage.LvUp)
  418. self.btnAdvence:SetActive(pageToggleData.toggleDefaultIndex == LvUpPage.LvUp)
  419. self.btnSkillUp:SetActive(pageToggleData.toggleDefaultIndex == LvUpPage.SkillUp)
  420. if pageToggleData.toggleDefaultIndex == LvUpPage.LvUp then
  421. self.controller:SetSkillUpMatId()
  422. self:RefreshLvUpPage()
  423. elseif pageToggleData.toggleDefaultIndex == LvUpPage.SkillUp then
  424. self:RefreshSkillUpPage()
  425. end
  426. end
  427. function UIPetLvUpView:OnSkillClick(button, params)
  428. local data = params[0]
  429. local petData = self.controller:GetCurPetData()
  430. local petCfgData = ManagerContainer.CfgMgr:GetPetDataById(petData.cfgId)
  431. local maxLimit = #petCfgData.Skill1Rate
  432. data = {cfgId = data.cfgId, num = data.level, isMax = data.level >= maxLimit}
  433. ManagerContainer.LuaUIMgr:OpenTipsSkill(data)
  434. end
  435. function UIPetLvUpView:RemoveEventListener()
  436. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  437. end
  438. function UIPetLvUpView:AddUIEventListener()
  439. self.uiBase:AddButtonEventListener(self.btnBack.button, self, self.OnCloseClick)
  440. self.uiBase:AddButtonEventListener(self.btnUpDown.button, self, self.RefreshAttrsShowState)
  441. self.uiBase:AddButtonEventListener(self.lvUpNode.btnAttrs.button, self, self.OnPetAttrsClick, 2)
  442. --self.uiBase:AddButtonEventListener(self.btnLvUp.button, self, self.OnLvUpClick)
  443. self.uiBase:AddButtonEventListener(self.btnAdvence.button, self, self.OnAdvenceClick)
  444. self.uiBase:AddButtonEventListener(self.btnSkillUp.button, self, self.OnSkillUpClick)
  445. self.uiBase:AddButtonEventListener(self.btnLeft.button, self, self.OnLeftClick)
  446. self.uiBase:AddButtonEventListener(self.btnRight.button, self, self.OnRightClick)
  447. self.uiBase:AddButtonEventListener(self.top.btnPlayRule.button, self, self.OnClickPlayRuleBtn)
  448. self.uiBase:AddButtonEventListener(self.item.unowned.icon.button, self, self.OnOpenMatUI)
  449. self.uiBase:AddButtonEventListener(self.btnNature.button, self, self.OnNatureDscClick)
  450. self.uiBase:AddButtonEventListener(self.btnGoOut.button, self, self.OnBattleClick)
  451. self.uiBase:AddButtonEventListener(self.btnDown.button, self, self.OnBattleDown)
  452. self.uiBase:AddButtonEventListener(self.btnOnekeyDown.button, self, self.OnOnekeyDown)
  453. self.uiBase:AddButtonEventListener(self.btnOneKeyEquip.button, self, self.OnOnekeyUp)
  454. self.uiBase:AddButtonEventListener(self.petBlessLv.button, self, self.OnPetBlessClick)
  455. self.uiBase:AddButtonEventListener(self.slot1.button, self, self.OnSlotClick, 1)
  456. self.uiBase:AddButtonEventListener(self.slot2.button, self, self.OnSlotClick, 2)
  457. self.uiBase:AddButtonEventListener(self.slot3.button, self, self.OnSlotClick, 3)
  458. self.uiBase:AddButtonEventListener(self.slot4.button, self, self.OnSlotClick, 4)
  459. self.uiBase:AddButtonEventListener(self.slot5.button, self, self.OnSlotClick, 5)
  460. self.uiBase:AddButtonEventListener(self.slot6.button, self, self.OnSlotClick, 6)
  461. self.model.uIEventTriggerListener.onDrag = function()
  462. local deltaX = self.model.uIEventTriggerListener.currentEventData.delta.x
  463. curModel.transform:Rotate(Vector3.New(0, deltaX > 0 and -7 or 7, 0))
  464. end
  465. self.model.uIEventTriggerListener.onClick = function()
  466. petViewSystem:RolePlayAni(curModel, "s_click")
  467. end
  468. self.btnLvUp.repeatButton:AddRepeatClickEventListener(function (index, isOver)
  469. self:OnLvUpClick()
  470. end)
  471. self.uiBase:AddButtonEventListener(self.skillNode.btnOneKey.button, self, self.OnSkillAutoMatClick)
  472. self.uiBase:AddButtonEventListener(self.btnContract.button, self, self.OnContractClick)
  473. end
  474. function UIPetLvUpView:OnSkillAutoMatClick()
  475. if self.controller:IsSkillMax() then
  476. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("539")
  477. return
  478. end
  479. local skillMatId = self.controller:GetSkillUpMat()
  480. if not skillMatId then
  481. self.controller:RefreshSkillMatsData()
  482. else
  483. self.controller:SetSkillUpMatId()
  484. end
  485. self:RefreshSkillUpPage()
  486. end
  487. function UIPetLvUpView:OnNatureDscClick()
  488. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINatureInfo)
  489. end
  490. function UIPetLvUpView:OnBattleClick()
  491. local petData = self.controller:GetCurPetData()
  492. if petData.qiyueHeroId > 0 then
  493. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("PetContractState6")
  494. return
  495. end
  496. ManagerContainer.LuaUIMgr:Hide(self.uiData.id)
  497. local data = {curId = self.controller:GetData()}
  498. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetBattle,data,self.uiData.id)
  499. end
  500. function UIPetLvUpView:OnBattleDown()
  501. self.controller:SendPetBattleDown()
  502. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Petfight_005")
  503. end
  504. function UIPetLvUpView:OnClickPlayRuleBtn()
  505. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', "PetText001"})
  506. end
  507. function UIPetLvUpView:OnOpenMatUI()
  508. if self.controller:IsSkillMax() then
  509. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("539")
  510. return
  511. end
  512. local petId = self.controller:GetData()
  513. local skillMatId = self.controller:GetSkillUpMat()
  514. local data = {selfId = petId, selectedId = skillMatId, fromUIId = self.uiData.id, enterType = Enum.ItemIEnterType.PetMats}
  515. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetMats, data)
  516. end
  517. function UIPetLvUpView:OnSkillUpClick()
  518. if self.controller:IsSkillMax() then
  519. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("539")
  520. return
  521. else
  522. local hasSkillMats = self.controller:GetSkillUpMat()
  523. if not hasSkillMats then
  524. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("DscChooseSillUpMet")
  525. return
  526. end
  527. end
  528. if lackSkillUpCoin then
  529. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("4")
  530. return
  531. end
  532. local costPetData = self.controller:GetSkillMatPetData()
  533. if costPetData and costPetData.isRelevant then
  534. local data = {"PetCostNotify8", nil, nil, self, self.PetClickSure}
  535. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  536. return
  537. end
  538. if costPetData and (costPetData.level > 1 or self.controller:WasSkillUp(costPetData)) then
  539. local data = {"PetCostNotify4", nil, nil, self, self.PetClickSure}
  540. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  541. return
  542. end
  543. self.controller:SendPetSkillUp()
  544. end
  545. function UIPetLvUpView:PetClickSure()
  546. self.controller:SendPetSkillUp()
  547. end
  548. function UIPetLvUpView:OnLeftClick()
  549. self.controller:RefreshLeftPet()
  550. self.controller:SetSkillUpMatId()
  551. self.controller:QueryPetDetailInfo()
  552. end
  553. function UIPetLvUpView:OnRightClick()
  554. self.controller:RefreshRightPet()
  555. self.controller:SetSkillUpMatId()
  556. self.controller:QueryPetDetailInfo()
  557. end
  558. function UIPetLvUpView:RefreshAttrsShowState(button, params)
  559. attrsShowState = not attrsShowState
  560. self.iconUp:SetActive(attrsShowState)
  561. self.iconDown:SetActive(not attrsShowState)
  562. if attrsShowState then
  563. self.UpDownText.uILocalizeScript:SetContent("BtnClose")
  564. self.lvUpNode.animator:Play("MoreBoxUp")
  565. --self:RefreshPetTotalAttrs()
  566. else
  567. self.UpDownText.uILocalizeScript:SetContent("BtnDetails")
  568. self.lvUpNode.animator:Play("MoreBoxDown")
  569. end
  570. end
  571. function UIPetLvUpView:OnSubClose(path)
  572. local target = CommonUtil.ParseUITargetPath(self, path)
  573. if target == self.lvUpNode then
  574. self:RefreshPetTotalAttrs()
  575. else
  576. self.super.OnSubClose(self, path)
  577. end
  578. end
  579. function UIPetLvUpView:RefreshPetTotalAttrs()
  580. local actorData = self.controller:GetPetActorData()
  581. if not actorData then
  582. return
  583. end
  584. local petData = self.controller:GetCurPetData()
  585. local relationAttrs = {}
  586. if petData.heroId == 0 then
  587. relationAttrs = self.controller:GetRelationAddAttrs()
  588. end
  589. self.baseList = {}
  590. self.addList = {}
  591. for k,v in pairs(attrSortList) do
  592. if v >= Enum.HeroAttrType.Life and v <= Enum.HeroAttrType.CastAcceleration then
  593. local num = actorData:GetFinalAttr(v)--SDataUtil.Add(actorData:GetFinalAttr(v), (relationAttrs[v] or 0))
  594. if SDataUtil.IsGreater(num, 0) then
  595. self.baseList[#self.baseList + 1] = {v, num, 0}
  596. end
  597. else
  598. if v >= Enum.HeroAttrType.Nature_None_Damage_Percent then
  599. local num = actorData:GetFinalAttr(v)
  600. if SDataUtil.IsGreater(num, 0) then
  601. self.addList[#self.addList + 1] = {v, num, 0}
  602. end
  603. end
  604. end
  605. end
  606. if self.baseSView.loopVerticalScrollRect.totalCount ~= #self.baseList then
  607. --self.baseSView.loopVerticalScrollRect:ClearCells()
  608. CommonUtil.LoopGridViewEleCreateNew(self, self.baseSView.loopVerticalScrollRect, self.baseSView.content.gridLayoutGroup, self.baseList, 0, nil, function (itemLua, idx)
  609. CommonUtil.UpdateItemPrefab(self, itemLua, self.baseList[idx + 1])
  610. end)
  611. else
  612. self.baseSView.loopVerticalScrollRect:RefreshCellsData()
  613. end
  614. if self.addSView.loopVerticalScrollRect.totalCount ~= #self.addList then
  615. --self.addSView.loopVerticalScrollRect:ClearCells()
  616. CommonUtil.LoopGridViewEleCreateNew(self, self.addSView.loopVerticalScrollRect, self.addSView.content.gridLayoutGroup, self.addList, 0, nil, function (itemLua, idx)
  617. CommonUtil.UpdateItemPrefab(self, itemLua, self.addList[idx + 1])
  618. end)
  619. else
  620. self.addSView.loopVerticalScrollRect:RefreshCellsData()
  621. end
  622. --if not self.attrsInited then
  623. -- self.baseSView.loopVerticalScrollRect:ClearCells()
  624. -- CommonUtil.LoopGridViewEleCreateNew(self, self.baseSView.loopVerticalScrollRect, self.baseSView.content.gridLayoutGroup, self.baseList, 0, nil, function (itemLua, idx)
  625. -- CommonUtil.UpdateItemPrefab(self, itemLua, self.baseList[idx + 1])
  626. -- end)
  627. -- self.addSView.loopVerticalScrollRect:ClearCells()
  628. -- CommonUtil.LoopGridViewEleCreateNew(self, self.addSView.loopVerticalScrollRect, self.addSView.content.gridLayoutGroup, self.addList, 0, nil, function (itemLua, idx)
  629. -- CommonUtil.UpdateItemPrefab(self, itemLua, self.addList[idx + 1])
  630. -- end)
  631. --else
  632. -- self.baseSView.loopVerticalScrollRect:RefreshCellsData()
  633. -- self.addSView.loopVerticalScrollRect:RefreshCellsData()
  634. --end
  635. self.addSView:SetActive(#self.addList > 0)
  636. self.none:SetActive(#self.addList == 0)
  637. self.attrsInited = true
  638. end
  639. function UIPetLvUpView:OnPetAttrsClick(button, params)
  640. local id = self.controller:GetData()
  641. local data = {id = id, type = params[0]}
  642. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetAttribute, data)
  643. end
  644. function UIPetLvUpView:OnLvUpClick()
  645. if isZenyLack then
  646. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Petlvup_001")
  647. return
  648. end
  649. if isExpLack then
  650. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Petlvup_002")
  651. return
  652. end
  653. local petData = self.controller:GetCurPetData()
  654. local maxLv = self.controller:GetPetMaxLv()
  655. if petData.level == maxLv then
  656. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Petlvup_003")
  657. return
  658. end
  659. self.controller:SendPetLvUp()
  660. end
  661. function UIPetLvUpView:OnAdvenceClick()
  662. --local petData = self.controller:GetCurPetData()
  663. --local maxLv = self.controller:GetPetMaxLv()
  664. --if petData.level == maxLv then
  665. -- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Petadvance_002")
  666. -- return
  667. --end
  668. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetAdvence, self.controller:GetData())
  669. end
  670. function UIPetLvUpView:OnCloseClick()
  671. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  672. end
  673. function UIPetLvUpView:OnSkillUpMatNtf(id)
  674. self.controller:SetSkillUpMatId(id)
  675. self:OnValueChangedToggle()
  676. self:RefresPetRP()
  677. self:RefreshModleScale()
  678. end
  679. function UIPetLvUpView:OnSkillUpSuccessNtf(id)
  680. local petData = self.controller:GetCurPetData()
  681. local skillCount = #petData.skillList
  682. if skillCount > 1 then
  683. ManagerContainer.LuaUIMgr:OpenInputMask(10000)
  684. self:SkillUpPerform(id, skillCount)
  685. else
  686. self:SkillUpResult(id)
  687. end
  688. end
  689. function UIPetLvUpView:ShowSkillUpEffect(idx)
  690. if self.skillView.uIEffectCfg then
  691. self.skillView.uIEffectCfg:HideEffect("FX_UI_LingWu_01",self["skill"..idx.."Fx"].transform)
  692. self.skillView.uIEffectCfg:ShowEffect("FX_UI_LingWu_01",self["skill"..idx.."Fx"].transform)
  693. if self.lastIdx then
  694. self.skillView.uIEffectCfg:HideEffect("FX_UI_LingWu_01",self["skill"..self.lastIdx.."Fx"].transform)
  695. end
  696. end
  697. self.lastIdx = idx
  698. end
  699. function UIPetLvUpView:SkillUpPerform(id, skillCount)
  700. local petData = self.controller:GetCurPetData()
  701. self.sequence = DG.Tweening.DOTween.Sequence()
  702. self.curIdx = 0
  703. self.lastIdx = nil
  704. self.curIdx = self.curIdx + 1
  705. local item = self.skillView["skillItem"..self.curIdx]
  706. if item then
  707. self:ShowSkillUpEffect(self.curIdx)
  708. end
  709. local t1 = self.transform:DOScale(1, SkillFxSpeedList[1]):SetLoops(skillCount * 3 - 1):OnStepComplete(function ()
  710. self.curIdx = self.curIdx + 1
  711. if self.curIdx > skillCount then
  712. self.curIdx = 1
  713. end
  714. local item = self.skillView["skillItem"..self.curIdx]
  715. if item then
  716. self:ShowSkillUpEffect(self.curIdx)
  717. end
  718. end)
  719. self.sequence:Append(t1)
  720. local t2 = self.transform:DOScale(1, SkillFxSpeedList[2]):SetDelay(SkillFxSpeedList[1] - SkillFxSpeedList[2]):SetLoops(skillCount):OnStepComplete(function ()
  721. self.curIdx = self.curIdx + 1
  722. if self.curIdx > skillCount then
  723. self.curIdx = 1
  724. end
  725. local item = self.skillView["skillItem"..self.curIdx]
  726. if item then
  727. self:ShowSkillUpEffect(self.curIdx)
  728. end
  729. end)
  730. self.sequence:Append(t2)
  731. local count = 1
  732. for i = 1, #petData.skillList do
  733. if petData.skillList[i].cfgId == id then
  734. count = i
  735. break
  736. end
  737. end
  738. local t3 = self.transform:DOScale(1, SkillFxSpeedList[3]):SetDelay(SkillFxSpeedList[2] - SkillFxSpeedList[3]):SetLoops(count):OnStepComplete(function ()
  739. self.curIdx = self.curIdx + 1
  740. if self.curIdx > skillCount then
  741. self.curIdx = 1
  742. end
  743. local item = self.skillView["skillItem"..self.curIdx]
  744. if item then
  745. self:ShowSkillUpEffect(self.curIdx)
  746. end
  747. end)
  748. self.sequence:Append(t3)
  749. local t4 = self.transform:DOScale(1, SkillFxSpeedList[4]):OnComplete(function ()
  750. for i = 1, skillCount do
  751. if self.skillView.uIEffectCfg then
  752. self.skillView.uIEffectCfg:HideEffect("FX_UI_LingWu_01",self["skill"..i.."Fx"].transform)
  753. end
  754. end
  755. self:SkillUpResult(id)
  756. self.sequence = nil
  757. ManagerContainer.LuaUIMgr:CloseInputMask()
  758. end)
  759. self.sequence:Append(t4)
  760. self.sequence:SetAutoKill(true)
  761. end
  762. function UIPetLvUpView:SkillUpResult(id)
  763. local skillId = id
  764. local skillData = self.controller:GetCurPetSkillData(id)
  765. local skillLevel = skillData.level
  766. local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgById(skillData.cfgId)
  767. local skillLevelCfgId = CommonUtil.GetSkillCfgIdByIdAndLv(skillId, skillLevel)
  768. local skillLevelCfgData = ManagerContainer.CfgMgr:GetSkillLevelCfgById(skillLevelCfgId)
  769. local skillShowData = ManagerContainer.CfgMgr:GetSkillShowCfgById(skillId)
  770. local itemlua = self.skillUpOK.skillItem
  771. CommonUtil.SetCommonSkillItem(self, itemlua, skillCfgData, skillLevel)
  772. self.skillUpOK.lVLimit.number1.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLevel - 1))
  773. self.skillUpOK.lVLimit.number2.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLevel))
  774. if skillCfgData then
  775. self.skillUpOK.textName.text.text = string.formatbykey(skillCfgData.Name)
  776. else
  777. self.skillUpOK.textName.text.text = ''
  778. end
  779. self.skillDescContent.rectTransform.anchoredPosition3D = Vector3.zero
  780. if skillLevelCfgData then
  781. self.skillUpOK.type1.text2.text.text = tostring(skillLevelCfgData.CD) .. string.formatbykey('S')
  782. self.skillUpOK.type2.text2.text.text = tostring(skillLevelCfgData.Cost) .. string.formatbykey('sp')
  783. local descParam = skillLevelCfgData.DescParam
  784. if descParam then
  785. if type(descParam) == 'table' then
  786. self.skillUpOK.text.text.text = string.formatbykey(skillLevelCfgData.Desc, unpack(descParam))
  787. else
  788. self.skillUpOK.text.text.text = string.formatbykey(skillLevelCfgData.Desc, descParam)
  789. end
  790. else
  791. self.skillUpOK.text.text.text = string.formatbykey(skillLevelCfgData.Desc)
  792. end
  793. else
  794. self.skillUpOK.type1.text2.text.text = '-'
  795. self.skillUpOK.type2.text2.text.text = '-'
  796. self.skillUpOK.text.text.text = ''
  797. end
  798. local tags = nil
  799. local num = 0
  800. if skillShowData then
  801. tags = skillShowData.Label
  802. if tags then
  803. if type(tags[1]) == 'number' then
  804. tags = {tags}
  805. end
  806. num = #tags
  807. end
  808. end
  809. for i = 1, 4 do
  810. local skillTagItem = self.skillUpOK['skillTagItem' .. i]
  811. if skillTagItem then
  812. if i <= num then
  813. local tagId = tags[i][1]
  814. local colorId = tags[i][2]
  815. skillTagItem:SetActive(true)
  816. skillTagItem.bgColorID.image.color = ColorExtension.HexStringToColor(I18N.SetLanguageValue('ColorID' .. tostring(colorId)))
  817. skillTagItem.textSkillID.uILocalizeScript:SetContent('SkillTagID' .. tostring(tagId))
  818. else
  819. skillTagItem:SetActive(false)
  820. end
  821. end
  822. end
  823. self.skillUpOK.type1:SetActive(true)
  824. self.skillUpOK.type2:SetActive(true)
  825. self.skillUpOK.type1.text1.uILocalizeScript:SetContent('SkillCD1')
  826. self.skillUpOK.type2.text1.uILocalizeScript:SetContent('SkillCost')
  827. self.skillUpOK.type3:SetActive(false)
  828. self.skillUpOK.type4:SetActive(false)
  829. self.skillUpOK.type5:SetActive(false)
  830. self.skillUpOK.skillTag:SetActive(true)
  831. self.skillUpOK:SetActive(true)
  832. self:RefreshTopSkills()
  833. self:ShowFightPower()
  834. self:OnSkillUpMatNtf(nil)
  835. petViewSystem:RolePlayAni(curModel, "s_study")
  836. local petData = self.controller:GetCurPetData()
  837. local petStarIcon, textContent, count = CommonUtil.GetPetSkillStarIconAndColor(petData.skillList)
  838. CommonUtil.LoadIcon(self, petStarIcon, function (sprite)
  839. self.advence2.image.sprite = sprite
  840. end)
  841. self.advence2.advenceLv.text.text = textContent
  842. count = count - 1
  843. local idx = math.floor((math.max(count - 1, 0)) / 10) + 1
  844. local num = count % 10
  845. local num1 = num == 0 and 10 or num
  846. CommonUtil.LoadIcon(self, Constant.Pet_Star_Icons[idx], function (sprite)
  847. self.advence1.image.sprite = sprite
  848. end)
  849. self.advence1.advenceLv.text.text = string.format(Constant.Pet_Star_Text_Color[idx], num1)
  850. end
  851. function UIPetLvUpView:RefreshPetStamps()
  852. local petData = self.controller:GetCurPetData()
  853. if not petData then return end
  854. local slots = petData.slots
  855. local count = StampSlotCount
  856. self.controller:SetSlotCount(count)
  857. local canInsert = false
  858. local states = {}
  859. for i = 1, count do
  860. local slotItem = self["slot"..i]
  861. local slot = slots and slots[i] or nil
  862. local state = slot and (slot.stampId > 0) or false
  863. slotItem.inserted:SetActive(state)
  864. slotItem.empty:SetActive(not state)
  865. states[i] = slot and slot.stampId or 0
  866. if state then
  867. local stampData = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetPetStampDataMapById(slot.stampId)
  868. if stampData then
  869. IconItemCtr:SetData(self, self["stamp"..i], stampData, Enum.ItemIEnterType.Bag)
  870. else
  871. slotItem.empty:SetActive(true)
  872. slotItem.inserted:SetActive(false)
  873. local list, qualityStamp = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetAllPetStampDatasByTypeExcludeId(i)
  874. if qualityStamp and qualityStamp.petId == 0 then
  875. canInsert = true
  876. end
  877. end
  878. else
  879. local list, qualityStamp = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetAllPetStampDatasByTypeExcludeId(i)
  880. if qualityStamp and qualityStamp.petId == 0 then
  881. canInsert = true
  882. end
  883. end
  884. --红点
  885. local insertRP = ManagerContainer.RedPointMgr.PetRPCtr:GetPetSlotInsertRPState(petData.id, i)
  886. local redpoint = self:RefreshRPShow(slotItem.rpRoot.transform, insertRP, "redpoint", "UIRedPointRP")
  887. if slot then
  888. if not insertRP then
  889. local lvUpRP = ManagerContainer.RedPointMgr.PetRPCtr:GetPetSlotLvUpRPState(petData.id, i)
  890. if lvUpRP then
  891. redpoint.gameObject:SetActive(true)
  892. else
  893. local advanceRP = ManagerContainer.RedPointMgr.PetRPCtr:GetPetSlotAdvanceRPState(petData.id, i)
  894. if advanceRP then
  895. redpoint.gameObject:SetActive(true)
  896. end
  897. end
  898. end
  899. else
  900. redpoint.gameObject:SetActive(insertRP)
  901. end
  902. --处理 stone
  903. end
  904. self.btnOneKeyEquip:SetActive(canInsert)
  905. self.redPointItem1:SetActive(petData.isBattle and canInsert)
  906. self.btnOnekeyDown:SetActive(not canInsert)
  907. self:RefreshPetStampBless()
  908. end
  909. function UIPetLvUpView:RefreshPetStampBless()
  910. local petData = self.controller:GetCurPetData()
  911. local stampSuit = petData.stampSuit
  912. self.petBlessLv.lightGreen:SetActive(stampSuit[1] == 1)
  913. self.petBlessLv.lightBlue:SetActive(stampSuit[1] == 2)
  914. self.petBlessLv.lightPurple:SetActive(stampSuit[1] == 3)
  915. self.petBlessLv.lightGold:SetActive(stampSuit[1] == 4)
  916. self.petBlessLv.lightRed:SetActive(stampSuit[1] == 5)
  917. for i = 1, 6 do
  918. local quality = stampSuit[4][i]
  919. local slot = self.petBlessLv["slot"..i]
  920. slot:SetActive(quality ~= nil)
  921. if quality then
  922. local image = slot.image
  923. local slotTb = tolua.getpeer(slot)
  924. CommonUtil.LoadIcon(self, Constant.Pet_Stamp_Bless_Icons[quality], function (sprite)
  925. image.sprite = sprite
  926. end, slotTb, 'BlessIcon')
  927. end
  928. end
  929. end
  930. function UIPetLvUpView:OnOnekeyUp()
  931. self.controller:SendOneKeyUp()
  932. end
  933. function UIPetLvUpView:OnOnekeyDown()
  934. self.controller:SendOneKeyDown()
  935. end
  936. function UIPetLvUpView:OnSlotClick(button, params)
  937. self:CloseTotalAttr()
  938. local slotIdx = params[0]
  939. local petData = self.controller:GetCurPetData()
  940. local slots = petData.slots
  941. local slot = slots[slotIdx]
  942. local stampId = 0
  943. if slot then
  944. stampId = slot.stampId
  945. end
  946. local petId = self.controller:GetData()
  947. if stampId > 0 then
  948. local stampData = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetPetStampDataMapById(stampId)
  949. if stampData then
  950. local data = {stampData = stampData, slotIdx = slotIdx, petId = petId}
  951. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetStampTips, data)
  952. end
  953. else
  954. local data = {curStamp = nil, slotIdx = slotIdx, petId = petId}
  955. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetStampList, data)
  956. end
  957. end
  958. function UIPetLvUpView:OnPetBlessClick()
  959. local petId = self.controller:GetData()
  960. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetStampBlessTips, petId)
  961. end
  962. function UIPetLvUpView:OnSlotRefreshNtf()
  963. self:RefreshPetStamps()
  964. self:Refresh()
  965. self:OnValueChangedToggle()
  966. self:RefreshTopOwnedRes()
  967. self:RefreshAttrs()
  968. end
  969. function UIPetLvUpView:RefresPetRP()
  970. local id = self.controller:GetData()
  971. ManagerContainer.RedPointMgr.PetRPCtr:RefreshPetLvUpState(id)
  972. ManagerContainer.RedPointMgr.PetRPCtr:RefreshPetAdvenceState(id)
  973. ManagerContainer.RedPointMgr.PetRPCtr:RefreshSkillUpState(id)
  974. local petData = self.controller:GetCurPetData()
  975. self.btnContract.uIRedPointRP:SetActive(ManagerContainer.RedPointMgr.PetRPCtr:RefreshBattlePetQiyueRPState(petData))
  976. end
  977. function UIPetLvUpView:RefreshRPShow(parent, state, redName, redPath)
  978. local redP = parent:Find(redName)
  979. if not redP then
  980. redP = self:CreateNormalRedPoint(parent, redName, redPath)
  981. end
  982. redP.gameObject:SetActive(state)
  983. return redP
  984. end
  985. function UIPetLvUpView:CreateNormalRedPoint(parent, redName, redPath)
  986. local redPoint = ManagerContainer.ResMgr:GetGoFromPool(Constants.UICommonPath, redPath)
  987. if redPoint then
  988. redPoint.transform:SetParent(parent)
  989. redPoint.transform.localPosition = Vector3.zero
  990. redPoint.transform.localRotation = Quaternion.identity
  991. redPoint.transform.localScale = Vector3.one
  992. redPoint.name = redName
  993. redPoint:SetActive(true)
  994. end
  995. return redPoint.transform
  996. end
  997. function UIPetLvUpView:OnContractClick()
  998. local qiyueFunc, _, content = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(77)
  999. if not qiyueFunc then
  1000. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content)
  1001. return
  1002. end
  1003. local petData = self.controller:GetCurPetData()
  1004. if petData.heroId == 0 then
  1005. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("PetContractTips1")
  1006. return
  1007. end
  1008. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.QIYUE_TOGGLE_JUMP_TRIGGER)
  1009. self:UIClose()
  1010. end
  1011. function UIPetLvUpView:OnHide()
  1012. curModel = nil
  1013. if previewSystem then
  1014. previewSystem:Dispose(true)
  1015. end
  1016. previewSystem = nil
  1017. if petViewSystem then
  1018. petViewSystem:Dispose()
  1019. end
  1020. petViewSystem = nil
  1021. end
  1022. function UIPetLvUpView:OnShow(data)
  1023. self.controller:SetData(data)
  1024. self:OnPetDetailQuerySuccess()
  1025. end
  1026. function UIPetLvUpView:OnClose()
  1027. pageToggleData = nil
  1028. ManagerContainer.LuaActorAttributeMgr:ClearCb(self.SyncCbId)
  1029. if self.showAttrsTimer then
  1030. self.showAttrsTimer:Stop()
  1031. self.showAttrsTimer = nil
  1032. end
  1033. end
  1034. function UIPetLvUpView:OnDispose()
  1035. curModel = nil
  1036. if previewSystem then
  1037. previewSystem:Dispose(true)
  1038. end
  1039. previewSystem = nil
  1040. if petViewSystem then
  1041. petViewSystem:Recycle()
  1042. end
  1043. petViewSystem = nil
  1044. self.model.uIEventTriggerListener.onDrag = nil
  1045. self.model.uIEventTriggerListener.onClick = nil
  1046. self.baseList = nil
  1047. self.addList = nil
  1048. self.baseSView.loopVerticalScrollRect:ClearCells()
  1049. self.addSView.loopVerticalScrollRect:ClearCells()
  1050. self.top.uIEffectCfg:Clean()
  1051. self.skillView.uIEffectCfg:Clean()
  1052. for i = 1, 3 do
  1053. self["skill"..i.."Fx"].transform:SetParent(self.skillView.transform)
  1054. end
  1055. DG.Tweening.DOTween.KillAll()
  1056. --DG.Tweening.DOTween.Kill(self.transform)
  1057. self.sequence = nil
  1058. self.controller:OnDispose()
  1059. end
  1060. return UIPetLvUpView