UIRoleMain1View.lua 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  1. local UIRoleMain1View = require("UIRoleMain/UIRoleMain1View_Generate")
  2. local IconItemCtr = require ("Common.IconItemCtr")
  3. local RoleListItemCtr = require("Common/RoleListItemCtr")
  4. local HeroHeadIcon = require("Common/HeroHeadIcon")
  5. local RoleViewSystem = require("RoleViewSystem")
  6. local PreviewSystem = require("PreviewSystem")
  7. local RedPointItemCtr = require("Common/RedPointItemCtr")
  8. local EquipSlotItemNewCtr = require("Common/EquipSlotItemNewCtr")
  9. local ColorExtension = require("ColorExtension")
  10. local attrField = {}
  11. local oldAttrs = {}
  12. local newAttrs = {}
  13. local activationList
  14. local curModel
  15. local allEquiped = false
  16. local isLeader = false
  17. local partnerId
  18. local battleData
  19. local recruitCostId
  20. local recruitCostNum
  21. local animatorNames = {"Lead", "Sword", "Mage", "Priest", "Archer", "Thief"}
  22. local lastClickLogTime
  23. local lastClickNum
  24. local UIRedPointRP = "UIRedPointRP"
  25. function UIRoleMain1View:OnAwake(data)
  26. self.controller = require("UIRoleMain/UIRoleMain1Ctr")
  27. self.controller:Init(self)
  28. self.controller:SetData(data)
  29. attrField[1] = GlobalConfig.Instance:GetConfigIntValue(GlobalConfig.c_base_attr_id)
  30. attrField[2] = #ManagerContainer.CfgMgr.QualityPointCfg
  31. end
  32. function UIRoleMain1View:AddEventListener()
  33. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.NICK_NAME_CREATED, self, self.RefreshUserNickName)
  34. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.USER_HEADPROTRAIT_CHANGED, self, self.RefreshUserHeadProtrait)
  35. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.HERO_ATTR_ADD_SUCCESS, function()
  36. --self.leadBox.btnNature.redPoint1:SetActive(ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroAttrRPStatus())
  37. end)
  38. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, function()
  39. self:RefershOneKeyState()
  40. end)
  41. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SKILL_CHANGED, function()
  42. self:RefreshSkillSuitBtn()
  43. end)
  44. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ONE_KEY_EQUIP_REDPOINT_NOTICE, function()
  45. self:RefershOneKeyState()
  46. end)
  47. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_HERO_UI, function()
  48. self:RefreshFellowBtns()
  49. self:RefreshFightPower()
  50. self:RefreshAttrs()
  51. self:RefershOneKeyState()
  52. self:RefreshSkillSuitBtn()
  53. self:RefreshCardSuitBtn()
  54. end)
  55. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_CARD_SUIT, function()
  56. self:RefreshCardSuitBtn()
  57. end)
  58. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.HERO_EQUIP_REFRESH, function()
  59. self:RefreshFellowBtns()
  60. self:RefreshFightPower()
  61. self:RefreshEquips()
  62. self:RefreshCardSlotRP()
  63. self:RefreshAttrs(true)
  64. self:RefreshCardSuitBtn()
  65. local slotIndex = self.controller:GetCurSLotIndex()
  66. ManagerContainer.LuaUIMgr:AttrNoticeDisplay(slotIndex)
  67. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.MAIN_UI_ROLE_REDPOINT_NOTICE)
  68. end)
  69. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SLOT_REFINE_LV_UP_SUCCESS, function(result)
  70. if result == Enum.NetErrorCode.ERROR_OK then
  71. self:RefreshEquips()
  72. end
  73. end)
  74. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.FIGHTPOWER_REFRESH, function()
  75. self:RefreshFightPower()
  76. end)
  77. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SIDEFIGHTPOWER_REFRESH, function()
  78. self:RefreshFightPower()
  79. end)
  80. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SWICH_PARTNER_VIEW, function(data)
  81. self.controller:SetData(data)
  82. self:Refresh()
  83. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_MAIN_TOP_RES_TYPE, isLeader and Enum.ItemType.Diamond or Enum.ItemType.ParterExp)
  84. end)
  85. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PARTNER_BATTLE_REQ_SUCCESS, function()
  86. --CommonUtil.SetGOLayer(curModel, Constant.DefaultLayer)
  87. local battleStatus = self.controller:GetBattleStatus()
  88. if battleStatus then
  89. local logicData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataByUniqueId(self.controller:GetData())
  90. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  91. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.PARTNER_BATTLE_CHANGE_INDEX, cfgData.ParterId)
  92. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("Change", I18N.T(cfgData.Name))
  93. end
  94. --self.controller:SetData(battleData)
  95. self:Refresh()
  96. --self.popReplace:SetActive(false)
  97. end)
  98. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PARTNER_STRENGTH_SUCCESS, function()
  99. self:RefreshFellowBtns()
  100. local logicData = self.controller:GetHeroLogicData()
  101. self:RefreshPartnerView(logicData.id, logicData.configId, logicData)
  102. end)
  103. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.FIGHTPOWER_PARTNER_ACK, function()
  104. self:RefreshFightPower()
  105. end)
  106. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.HERO_JOB_CHANGE_SUCCESS, function()
  107. end)
  108. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.RED_POINT_NOTICE, self, self.RefreshRedPoint)
  109. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PARTNER_ACTIVE_SUCCESS, function(configId)
  110. local logicData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataById(configId)
  111. self.controller:SetCurOwnerIndex(logicData.post)
  112. self.controller:SetData(logicData.id)
  113. --self:Refresh()
  114. self:RecruitSucceed()
  115. end)
  116. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ACTOR_SERVER_CHANGE_ATTRS, function(tbArrtDeffrent)
  117. local slotIndex = self.controller:GetCurSLotIndex()
  118. ManagerContainer.DataMgr.CardData:RefreshEquipedCardSuitData(slotIndex)
  119. if #tbArrtDeffrent < 1 then
  120. return
  121. end
  122. -- local slotIndex = self.controller:GetCurSLotIndex()
  123. if slotIndex == 1 then
  124. oldAttrs = ManagerContainer.DataMgr.UserData:GetLastTotalAtttrs()
  125. newAttrs = ManagerContainer.DataMgr.UserData:GetHeroData().attrs
  126. else
  127. oldAttrs = ManagerContainer.DataMgr.PartnerData:GetLastTotalAttrs(slotIndex)
  128. local list = ManagerContainer.DataMgr.PartnerData:GetPartnerDataBySlotIndex(slotIndex)
  129. newAttrs = list == nil and nil or list.attrs
  130. end
  131. if nil ~= newAttrs then
  132. -- LogError(Inspect(newAttrs))
  133. -- LogError(Inspect(oldAttrs))
  134. --刷新卡牌祝福等级信息
  135. --ManagerContainer.DataMgr.CardData:RefreshEquipedCardSuitData(slotIndex)
  136. --属性变化弹窗
  137. self:AttrChangeTipsDisplay()
  138. end
  139. end)
  140. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.PARTNER_ACTIVE_SUCCESS_OVER, function()
  141. self:Refresh()
  142. end)
  143. --ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SKILL_SLOT_CHANGED,self,self.OnRefreshSkillSlot)
  144. --ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_PARTENR_SKILL_REFRESH,self,self.OnRefreshHeroSkill)
  145. -- 由服务器发起,角色刷新形象
  146. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.FASHION_WEAR_CHANGE, self, self.RefreshDefaultRoleView)
  147. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.CARDSLOT_REDPOINT_ROLE_UI_NTF, self, self.RefreshCardSlotOpenRP)
  148. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ROLE_UI_REDPOINT_CHANGE, self, self.RefreshOtherRedPoint)
  149. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CRUISE_CHANGED, self, self.OnCruiseChanged)
  150. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_SLOT_REFRESH, self, self.RefreshSkillEquip)
  151. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_LV_UP_REFRESH, self, self.SkillEquipSlotSuccess)
  152. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_RP_REFRESH, self, self.RefreshSkillEquipRP)
  153. end
  154. function UIRoleMain1View:FillContent(data, uiBase)
  155. self.uiBase = uiBase
  156. local gameObject = self.uiBase:GetRoot()
  157. if gameObject ~= nil then
  158. self.gameObject = gameObject
  159. self.transform = gameObject.transform
  160. end
  161. self:InitGenerate(self.transform, data)
  162. self:Init()
  163. end
  164. function UIRoleMain1View:Init()
  165. self:InitRoleSystems()
  166. lastClickLogTime = nil
  167. lastClickNum = nil
  168. self.equipments:SetActive(false)
  169. self.transform:DOScale(1, 0.5):OnComplete(function ()
  170. self.equipments:SetActive(true)
  171. end)
  172. self:Refresh()
  173. end
  174. function UIRoleMain1View:InitRoleSystems()
  175. if not self.roleViewSystems then
  176. self.roleViewSystems = {}
  177. end
  178. for i = 1, 6 do
  179. if not self.roleViewSystems[i] then
  180. local roleViewSystem = RoleViewSystem:new()
  181. self.roleViewSystems[i] = roleViewSystem
  182. end
  183. end
  184. end
  185. function UIRoleMain1View:OnPageInEnd()
  186. self.super.OnPageInEnd(self)
  187. end
  188. function UIRoleMain1View:LoadModelCB(model)
  189. curModel = model
  190. if self.previewSystem and model ~= nil then
  191. self.previewSystem:UpdateGo(model)
  192. end
  193. curModel.transform.position = Vector3.zero
  194. curModel:SetActive(true)
  195. local logicData = self.controller:GetHeroLogicData()
  196. if not isLeader then
  197. self.roleViewSystems[logicData.id]:RolePlayAni(curModel, logicData.owned and "f_show" or "f_Injured")
  198. end
  199. end
  200. function UIRoleMain1View:OnEffectLoaded(effect)
  201. if self.previewSystem and effect then
  202. self.previewSystem:UpdateGo(effect)
  203. end
  204. end
  205. function UIRoleMain1View:OwnedHeadSelction(button, params)
  206. local index = params[0]
  207. if self.controller:GetCurOwnerIndex() == index then return end
  208. self.controller:SetCurOwnerIndex(index)
  209. self.controller:SetData(params[1])
  210. self.equipments:SetActive(false)
  211. self.equipments:SetActive(true)
  212. self:Refresh()
  213. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_MAIN_TOP_RES_TYPE, isLeader and Enum.ItemType.Diamond or Enum.ItemType.ParterExp)
  214. end
  215. function UIRoleMain1View:RefreshFellowBtns()
  216. --local id = self.controller:GetData()
  217. --local battlePower = ManagerContainer.DataMgr.UserData:GetSlotFightPower(id)
  218. --if battlePower == 0 then
  219. -- self.controller:SendFightPowerReq(id)
  220. --end
  221. local selectedIdx = self.controller:GetCurOwnerIndex()
  222. self.roleListAnim.animator:Play(animatorNames[selectedIdx])
  223. local roleId = ManagerContainer.DataMgr.UserData:GetUserRoleId()
  224. local logicData = ManagerContainer.DataMgr.UserData:GetHeroData()
  225. local cfgData = ManagerContainer.CfgMgr:GetRoleDataById(roleId)
  226. local data = {1, logicData, cfgData}
  227. RoleListItemCtr:SetData(self, self["role"..1], data, self, self.OwnedHeadSelction)
  228. local rpState = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroRPStatus()
  229. self["roleRP"..1]:SetActive(rpState ~= Enum.RedPointEnum.None)
  230. if rpState ~= Enum.RedPointEnum.None then
  231. RedPointItemCtr:SetData(self, self["roleRP"..1], rpState, Enum.HeroRPSource.HeadIcon, 1)
  232. end
  233. local partnerDatas = self.controller:GetSortedPartnerDatas()
  234. for k, v in pairs(partnerDatas) do
  235. local idx = k + 1
  236. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(v.configId)
  237. local data = {idx, v, cfgData}
  238. RoleListItemCtr:SetData(self, self["role"..idx], data, self, self.OwnedHeadSelction)
  239. rpState = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerRPStatus(v.id)
  240. self["roleRP"..idx]:SetActive(rpState ~= Enum.RedPointEnum.None)
  241. if rpState ~= Enum.RedPointEnum.None then
  242. RedPointItemCtr:SetData(self, self["roleRP"..idx], rpState, Enum.HeroRPSource.HeadIcon, v.id)
  243. end
  244. end
  245. --for i = 2,6 do
  246. -- local logicData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataByUniqueId(i)
  247. -- local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  248. -- local data = {i, logicData, cfgData}
  249. -- RoleListItemCtr:SetData(self, self["role"..i], data, self, self.OwnedHeadSelction, logicData ~= nil and ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerRPStatus(logicData.id) or nil)
  250. --end
  251. end
  252. --移除当前的model
  253. function UIRoleMain1View:RemoveCurModel()
  254. if curModel ~= nil then
  255. curModel:SetActive(false)
  256. self.previewSystem:RemoveGo(curModel)
  257. for i = 1, 6 do
  258. self.roleViewSystems[i]:Recycle()
  259. end
  260. curModel = nil
  261. end
  262. end
  263. function UIRoleMain1View:Refresh()
  264. local uid = self.controller:GetData()
  265. if not uid then
  266. self.controller:SetData(1)
  267. uid = 1
  268. end
  269. self.recommendSkillId = nil
  270. self.recommendSkillType = nil
  271. ManagerContainer.LuaUIMgr:SetOldSlot(nil)
  272. self.controller:RefreshPartnersLists()
  273. if not self.previewSystem then
  274. self.previewSystem = PreviewSystem:new("Role", 512, 512)
  275. self.previewSystem:SetView(Vector3(-0.116, 1.649, 2.5), Quaternion.Euler(12.174, -182.628, 0.085))
  276. end
  277. for i = 1, 6 do
  278. self.roleViewSystems[i]:CancelCreate()
  279. end
  280. self:RemoveCurModel();
  281. local cfgData
  282. isLeader = self.controller:GetIsLeader()
  283. local logicData = self.controller:GetHeroLogicData()
  284. self.btnPvpSuppress:SetActive(isLeader)
  285. local pressValue = ManagerContainer.DataMgr.UserData:GetCurrRoleSkillPress()
  286. self.btnPvpSuppress.num.text.text = pressValue
  287. self.leadBox:SetActive(isLeader)
  288. self.ptBox:SetActive(not isLeader and logicData.owned)
  289. self.ptBox1:SetActive(not isLeader and not logicData.owned)
  290. --self.btnLeft:SetActive(isLeader)
  291. --self.btnRight:SetActive(isLeader)
  292. --self.btnReplace:SetActive(logicData.owned and self.controller:GetActivationPartnerCount() > 3)
  293. --self.main:SetActive(isLeader)
  294. --self.pt:SetActive(not isLeader)
  295. self.leadBox.btnFashion:SetActive(isLeader)
  296. self.leadBox.btnTitle:SetActive(isLeader)
  297. self:RefreshFellowBtns()
  298. partnerId = nil
  299. if isLeader then
  300. --self:RefreshFellowBtns()
  301. cfgData = ManagerContainer.CfgMgr:GetJobDataById(ManagerContainer.DataMgr.UserData:GetJobCfgId())
  302. self:RefreshDefaultRoleView()
  303. self:RefreshUserNickName()
  304. else
  305. local logicData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataByUniqueId(uid)
  306. cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  307. partnerId = cfgData.ParterId
  308. --if logicData.isBattle then
  309. -- UIRoleListCtr:RefreshPartnersLists()
  310. --self:RefreshFellowBtns()
  311. --end
  312. --self.controller:NilOldSlot()
  313. activationList = self.controller:RefreshPartnersLists()
  314. self:RefreshPartnerView(uid, partnerId, logicData)
  315. --self.name.uILocalizeScript:SetContent(cfgData.Name)
  316. end
  317. self.model.rawImage.texture = self.previewSystem:GetRenderTexture()
  318. self:RefreshFightPower()
  319. self:RefreshEquips()
  320. if isLeader or logicData.owned then
  321. self:RefreshAttrs()
  322. end
  323. self:RereshAttrPointRP()
  324. self:RefreshRedPoint()
  325. self:RefreshOtherRedPoint()
  326. self:RefreshRecruit()
  327. self:RefreshCardSlotRP()
  328. self.itemGroup:SetActive(isLeader or logicData.owned)
  329. self.btnGroup:SetActive(isLeader or logicData.owned)
  330. --self:InitSkillItemGos()
  331. --self:RefreshSkills();
  332. self.btnGoOut:SetActive(not isLeader and not logicData.isBattle and logicData.owned)
  333. self.btnDown:SetActive(not isLeader and logicData.isBattle and logicData.owned)
  334. if isLeader then
  335. --self.leadBox.btnNature.redPoint1:SetActive(ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroAttrRPStatus())
  336. end
  337. self:RefreshOneKeyLock()
  338. self:InitRoleNatureIcon()
  339. self.btnPveBless:SetActive(cfgData and cfgData.JobStage >= 3)
  340. self:RefreshSkillSuitBtn()
  341. self:RefreshCardSuitBtn()
  342. self:RefreshSkillEquip()
  343. self.artifact:SetActive(isLeader or logicData.owned)
  344. end
  345. function UIRoleMain1View:InitRoleNatureIcon()
  346. local id = self.controller:GetData()
  347. local cfgData = CommonUtil.GetHeroJobCfgDataByUid(id)
  348. local natureId = cfgData.NatureId
  349. local natureCfgData = ManagerContainer.CfgMgr:GetNatureDataById(natureId)
  350. local icon = natureCfgData.Icon
  351. CommonUtil.LoadIcon(self, icon, function (sprite)
  352. self.btnNature.icon.image.sprite = sprite
  353. end)
  354. end
  355. function UIRoleMain1View:RefreshOneKeyLock()
  356. --self.btnOneKeyEquip_lock:SetActive(false)
  357. --self.btnOneKeyForge_lock:SetActive(not ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(13))
  358. --self.btnOneKeyCardUp_lock:SetActive(not ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(20))
  359. --self.btnOneKeyCardForge_lock:SetActive(not ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(3))
  360. end
  361. function UIRoleMain1View:RefreshUserNickName()
  362. if not isLeader then return end
  363. --self.name.text.text = ManagerContainer.DataMgr.UserData:GetUserNickname()
  364. end
  365. function UIRoleMain1View:RefreshUserHeadProtrait()
  366. self:RefreshFellowBtns()
  367. end
  368. function UIRoleMain1View:RefreshAttrs(isNew)
  369. -- local logicData = self.controller:GetHeroLogicData()
  370. -- for _,v in pairs(Enum.HeroAttrType) do
  371. -- if not isNew then
  372. -- oldAttrs[v] = math.floor(SDataUtil.InvConvert(logicData.attrs[v] or 0))
  373. -- else
  374. -- newAttrs[v] = math.floor(SDataUtil.InvConvert(logicData.attrs[v] or 0))
  375. -- end
  376. -- end
  377. end
  378. function UIRoleMain1View:RefreshRecruit()
  379. local recruitCost = GlobalConfig.Instance:GetConfigStrValue(123)
  380. local cost = recruitCost:split(':')
  381. recruitCostId = tonumber(cost[1])
  382. recruitCostNum = tonumber(cost[2])
  383. local recruitCostOwned = CommonUtil.GetOwnResCountByItemId(recruitCostId)
  384. CommonUtil.SetTotalChildrenGray(self.ptBox1.btnRecruit, recruitCostOwned < recruitCostNum)
  385. self.ptBox1.recruitDsc:SetActive(recruitCostOwned == 0)
  386. local curRecruitTask = self.controller:GetCurRecruitCondDsc()
  387. self.ptBox1.dsc.text.text = ""
  388. if curRecruitTask ~= nil then
  389. self.ptBox1.dsc.text.text = I18N.SetLanguageValue("Healthtips_1", I18N.T(curRecruitTask))
  390. end
  391. local logicData = self.controller:GetHeroLogicData()
  392. local recruitRP = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerRecruitRPStatusById(logicData.id)
  393. self.ptBox1.btnRecruit.uIHartRP:SetActive(recruitRP == Enum.RedPointEnum.RecruitRP)
  394. end
  395. function UIRoleMain1View:RereshAttrPointRP()
  396. local id = self.controller:GetData()
  397. if id == 1 then
  398. ManagerContainer.RedPointMgr.HeroRPCtr:HeroAttrRPNotify()
  399. else
  400. ManagerContainer.RedPointMgr.HeroRPCtr:PartnerAttrRPNotify(id)
  401. end
  402. end
  403. function UIRoleMain1View:OnCruiseChanged()
  404. local btnSkill
  405. if isLeader then
  406. btnSkill = self.leadBox.btnSkill
  407. else
  408. btnSkill = self.ptBox.btnSkill
  409. end
  410. local heroId = self.controller:GetHeroLogicId()
  411. local status = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroSkillUnlockRPStatus(heroId)
  412. local redPointParent = nil
  413. if status ~= Enum.RedPointEnum.None then
  414. btnSkill.redPoint1:SetActive(true)
  415. btnSkill.redPointRoot:SetActive(false)
  416. else
  417. btnSkill.redPoint1:SetActive(false)
  418. if CommonUtil.HasSkillCanUp(heroId) then
  419. btnSkill.redPointRoot:SetActive(true)
  420. redPointParent = btnSkill.redPointRoot.transform
  421. else
  422. btnSkill.redPointRoot:SetActive(false)
  423. end
  424. end
  425. if redPointParent then
  426. if redPointParent.childCount == 0 then
  427. self:CreateNormalRedPoint(redPointParent)
  428. end
  429. end
  430. end
  431. function UIRoleMain1View:RefreshRedPoint(rpType)
  432. if rpType == nil then
  433. self:OnCruiseChanged()
  434. return
  435. end
  436. if rpType == Enum.RedPointEnum.FashionNewRP then
  437. return
  438. elseif rpType == Enum.RedPointEnum.SkillUnlockRP then
  439. self:OnCruiseChanged()
  440. end
  441. end
  442. function UIRoleMain1View:CreateNormalRedPoint(parent)
  443. local redPoint = ManagerContainer.ResMgr:GetGoFromPool(Constants.UICommonPath, UIRedPointRP)
  444. if redPoint then
  445. redPoint.transform:SetParent(parent)
  446. redPoint.transform.localPosition = Vector3.zero
  447. redPoint.transform.localRotation = Quaternion.identity
  448. redPoint.transform.localScale = Vector3.one
  449. redPoint:SetActive(true)
  450. end
  451. end
  452. function UIRoleMain1View:RefreshOtherRedPoint()
  453. local natureState, tranferState, breakState, lvUpState = false,false, false, false
  454. local natureParent, tranferParent, breakParent, lvUpParent = nil, nil, nil, nil
  455. if isLeader then
  456. ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroAttrRPStatus()
  457. natureState = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroAttrRPStatus()
  458. natureParent = self.leadBox.btnNature.redPointRoot.transform
  459. tranferState = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroTransferRPStatus()
  460. tranferParent = self.leadBox.btnTransfer.redPointRoot.transform
  461. else
  462. local heroId = self.controller:GetHeroLogicId()
  463. natureState = ManagerContainer.RedPointMgr.HeroRPCtr:GetAttrPointRPStatus(heroId)
  464. natureParent = self.ptBox.btnNature.redPointRoot.transform
  465. tranferState = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerTransferRPStatusById(heroId)
  466. tranferParent = self.ptBox.btnTransfer.redPointRoot.transform
  467. breakState = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerStrengthRPStatusById(heroId)
  468. breakParent = self.ptBox.btnBreak.redPointRoot.transform
  469. lvUpState = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerLvUpRPStatusById(heroId)
  470. lvUpParent = self.ptBox.btnLvUp.redPointRoot.transform
  471. end
  472. if natureParent then
  473. natureParent.gameObject:SetActive(natureState)
  474. if natureState then
  475. if natureParent.childCount == 0 then
  476. self:CreateNormalRedPoint(natureParent)
  477. end
  478. end
  479. end
  480. if tranferParent then
  481. tranferParent.gameObject:SetActive(tranferState)
  482. if tranferState then
  483. if tranferParent.childCount == 0 then
  484. self:CreateNormalRedPoint(tranferParent)
  485. end
  486. end
  487. end
  488. if breakParent then
  489. breakParent.gameObject:SetActive(breakState)
  490. if breakState then
  491. if breakParent.childCount == 0 then
  492. self:CreateNormalRedPoint(breakParent)
  493. end
  494. end
  495. end
  496. if lvUpParent then
  497. lvUpParent.gameObject:SetActive(lvUpState)
  498. if lvUpState then
  499. if lvUpParent.childCount == 0 then
  500. self:CreateNormalRedPoint(lvUpParent)
  501. end
  502. end
  503. end
  504. end
  505. function UIRoleMain1View:RefreshCardSlotRP()
  506. local id = self.controller:GetData()
  507. local cardState = self.controller:InsertedCards()
  508. local emptyRP = ManagerContainer.RedPointMgr.HeroRPCtr:GetRoleCardSlotEmptyRP(id)
  509. self.redPointItem3:SetActive(emptyRP)
  510. local upRP = ManagerContainer.RedPointMgr.HeroRPCtr:GetRoleCardSlotUpRP(id)
  511. self.redPointItem4:SetActive(upRP)
  512. self.btnOneKeyCardUp:SetActive(not cardState or emptyRP)
  513. self.btnOnekeyCardDown:SetActive(cardState and not emptyRP)
  514. end
  515. function UIRoleMain1View:RefreshFightPower()
  516. local logicData = self.controller:GetHeroLogicData()
  517. --LogError("刷新伙伴战力"..tostring(logicData.id))
  518. local Power = ManagerContainer.DataMgr.UserData:GetAsideFighterSvrPower(logicData.id,false)
  519. if nil ~= Power and -1 ~= Power then
  520. local TotalPower = Power
  521. local PetPower = ManagerContainer.DataMgr.UserData:GetAsideFighterSvrPower(logicData.battlePetId,true)
  522. if nil ~= PetPower and -1 ~= PetPower then
  523. TotalPower = TotalPower + PetPower
  524. end
  525. self.fightPower.text.text = tostring(TotalPower)
  526. else
  527. self.fightPower.text.text = ManagerContainer.DataMgr.UserData:GetSlotFightPower(logicData.id)
  528. end
  529. end
  530. function UIRoleMain1View:RefreshPress()
  531. local pressValue = ManagerContainer.DataMgr.UserData:GetCurrRoleSkillPress()
  532. self.btnPvpSuppress.num.text.text = pressValue
  533. end
  534. function UIRoleMain1View:RefreshDefaultRoleView()
  535. if self.uiBase.IsHide then return end
  536. local userData = ManagerContainer.DataMgr.UserData
  537. local heroData = userData:GetMainRoleData()
  538. self:RefreshRoleView(userData:GetUserRoleId(), userData:GetViewData(), heroData.extGoesShowData)
  539. end
  540. function UIRoleMain1View:RefreshRoleView(roleId, viewData, extGoesShowData)
  541. self.roleViewSystems[1]:RefreshView(Enum.RoleInEnvType.RoleMainView, roleId, viewData, extGoesShowData, self, self.LoadModelCB)
  542. end
  543. function UIRoleMain1View:RefreshPartnerView(uid, partnerCfgId, heroData)
  544. local extGoesShowData = heroData.extGoesShowData
  545. return self.roleViewSystems[uid]:RefreshView(Enum.RoleInEnvType.RoleMainView, partnerCfgId, nil, extGoesShowData, self, self.LoadModelCB)
  546. end
  547. function UIRoleMain1View:RefreshEquipList(button, params)
  548. local data = {params[0], Enum.ItemIEnterType.HeroEquip}
  549. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIEquipList, data)
  550. end
  551. function UIRoleMain1View:RefreshEquipTips(button, params)
  552. local data = {params[0], Enum.ItemIEnterType.HeroEquip, true}
  553. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIEquipTips, data)
  554. end
  555. function UIRoleMain1View:ChangeCurEquip(button, params)
  556. self.controller:SendCurEquipDress(params[0], params[1])
  557. local slotLua = self["slot"..params[0]]
  558. --slotLua.equipFx:SetActive(true)
  559. slotLua.equipFx.uIParticle:PlayCachedParticalSystem(true)
  560. end
  561. function UIRoleMain1View:PutOffCurEquip(button, params)
  562. self.controller:SendCurEquipPutOff(params[0], params[1])
  563. end
  564. function UIRoleMain1View:RefreshEquips()
  565. local id = self.controller:GetData()
  566. local oldSlot = ManagerContainer.LuaUIMgr:GetOldSlot()
  567. local logicData = self.controller:GetHeroLogicData()
  568. local jobData
  569. if isLeader then
  570. ManagerContainer.RedPointMgr.HeroRPCtr:HeroEquipRefineRPNotify()
  571. jobData = ManagerContainer.CfgMgr:GetJobDataById(ManagerContainer.DataMgr.UserData:GetJobCfgId())
  572. else
  573. ManagerContainer.RedPointMgr.HeroRPCtr:PartnerEquipRefineRPNotify(id)
  574. jobData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  575. end
  576. local slotIndex = self.controller:GetCurSLotIndex()
  577. local slots = ManagerContainer.DataMgr.UserData:GetCurSlotInfos(slotIndex)
  578. --self.equipments:SetActive(logicData.isBattle)
  579. --self.btnOneKeyEquip:SetActive(logicData.isBattle)
  580. self.btnOneKeyForge:SetActive(isLeader or logicData.owned)
  581. --self.btnOnekeyDown:SetActive(logicData.isBattle)
  582. local needPars = {false,false,false,false,false,false}
  583. --if logicData.isBattle then
  584. if slots == nil then
  585. self.btnOneKeyEquip:SetActive((isLeader or logicData.owned))
  586. self.btnOnekeyDown:SetActive(false)
  587. else
  588. local canChange = false
  589. local hasEquiped = false
  590. allEquiped = true
  591. for i = 1, 6 do
  592. local slotDressRPStatus = isLeader and ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroEquipDressRPStatusByIdx(i)
  593. or ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerEquipDressRPStatusByIdAndIdx(logicData.id, i)
  594. if slotDressRPStatus == Enum.RedPointEnum.EquipDressRP then
  595. canChange = true
  596. end
  597. if oldSlot ~= nil and i <= #slots and slots[i].equip_id ~= 0 then
  598. if oldSlot[i] == nil or slots[i].equip_id ~= oldSlot[i].equip_id then
  599. needPars[i] = true
  600. end
  601. end
  602. if i <= #slots and slots[i].equip_id > 0 then
  603. hasEquiped = true
  604. else
  605. if slotDressRPStatus == Enum.RedPointEnum.EquipDressRP then
  606. allEquiped = false
  607. end
  608. end
  609. end
  610. self.btnOneKeyEquip:SetActive((isLeader or logicData.owned) and (not hasEquiped or canChange))
  611. self.btnOnekeyDown:SetActive((isLeader or logicData.owned) and (allEquiped and hasEquiped and not canChange))
  612. end
  613. self:RefershOneKeyState()
  614. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIEquipList)
  615. --end
  616. --self.btnOneKeyEquip_lock:SetActive(isLeader and oneKeyEquipLockState)
  617. --self.btnOneKeyForge_lock:SetActive(isLeader and oneKeyForgeLockState)
  618. for i = 1, 6 do
  619. self["slot"..i].equipFx:SetActive(false)
  620. local data = {isLeader, logicData, jobData, slots, slotIndex, i, self.RefreshEquipTips}
  621. EquipSlotItemNewCtr:SetData(self, self["slot"..i], data, self, self.RefreshEquipList, needPars[i])
  622. end
  623. end
  624. function UIRoleMain1View:RefershOneKeyState()
  625. local logicData = self.controller:GetHeroLogicData()
  626. local oneKeyRP = isLeader and ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroEquipDressRPStatus()
  627. or ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerEquipDressRPStatusById(logicData.id)
  628. self.redPointItem1:SetActive(oneKeyRP == Enum.RedPointEnum.EquipDressRP)
  629. local oneKeyUpRP = isLeader and ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroEquipForgeRPStatus()
  630. or ManagerContainer.RedPointMgr.HeroRPCtr:GetpartnerEquipForgeRPStatusById(logicData.id)
  631. self.redPointItem2:SetActive(oneKeyUpRP == Enum.RedPointEnum.EquipForgeRP)
  632. end
  633. function UIRoleMain1View:GetNoBattlePartnerList()
  634. local actList = {}
  635. for _,v in pairs(activationList) do
  636. actList[#actList + 1] = v.id
  637. end
  638. CommonUtil.LoopGridViewEleCreate(self, self.popReplace.scrollView.loopVerticalScrollRect, self.content.gridLayoutGroup, actList, 0, function (itemLua, idx)
  639. local id = actList[idx + 1]
  640. local heroData = ManagerContainer.CfgMgr:GetPartnerDataById(id)
  641. HeroHeadIcon:SetActivationHeroIcon(self, false, heroData, ManagerContainer.DataMgr.PartnerData:GetPartnerDataById(id), itemLua, false, Enum.RedPointEnum.None)
  642. self.uiBase:AddButtonUniqueEventListener(itemLua.head.button, self, self.PartnerBattleReq, heroData)
  643. end)
  644. end
  645. function UIRoleMain1View:RefreshPopReplace()
  646. self:GetNoBattlePartnerList()
  647. self.popReplace:SetActive(true)
  648. end
  649. function UIRoleMain1View:AttrChangeTipsDisplay()
  650. local delta = {}
  651. local increase = false
  652. for k,_ in pairs(oldAttrs) do
  653. delta[k] = SDataUtil.InvConvert(newAttrs[k]) - SDataUtil.InvConvert(oldAttrs[k])
  654. if delta[k] > 0 then
  655. increase = true
  656. end
  657. end
  658. local specialAttr = nil
  659. local slotIndex = self.controller:GetCurSLotIndex()
  660. local temp = CommonUtil.GetCurCardLv(slotIndex)
  661. if temp then
  662. specialAttr = {{temp[1],temp[2]}}
  663. end
  664. if increase then
  665. ManagerContainer.LuaUIMgr:AttrNoticeDisplay1({oldAttrs, newAttrs,specialAttr})
  666. oldAttrs = CommonUtil.TableClone(newAttrs)
  667. end
  668. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIAttrAddTips, delta)
  669. end
  670. ---------------------------------------------Skill Module -----------------------------
  671. function UIRoleMain1View:OnClickSkillBtn()
  672. --self:UIHide(false)
  673. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillSettings, {self.controller:GetData()}, self.uiData.id)
  674. end
  675. function UIRoleMain1View:OnRefreshSkillSlot()
  676. self:RefreshSkills()
  677. end
  678. function UIRoleMain1View:OnRefreshHeroSkill(heroCfgId)
  679. local hero = self.controller:GetHeroLogicData()
  680. if hero~= nil and hero.configId == heroCfgId then
  681. self:RefreshSkills()
  682. end
  683. end
  684. function UIRoleMain1View:ShowUnlockSkill()
  685. local logicData = self.controller:GetHeroLogicData()
  686. local nextAdvanceLevel = logicData.advanceLevel + 1
  687. if nextAdvanceLevel+1 > #logicData.skills then
  688. self.UnlockSkillItem.transform.parent.gameObject:SetActive(false)
  689. return
  690. end
  691. self.UnlockSkillItem.transform.parent.gameObject:SetActive(true)
  692. if self.UnlockSkillLua == nil then
  693. self.UnlockSkillLua = self.UnlockSkillItem
  694. end
  695. self:SetSkillData(self.UnlockSkillLua,logicData.skills[nextAdvanceLevel+1])
  696. self.UnlockSkillLua.lock:SetActive(false)
  697. self.UnlockSkillLua.mask:SetActive(false)
  698. end
  699. function UIRoleMain1View:InitSkillItemGos()
  700. self.SkillItemCls = {}
  701. for i=1, 4 do
  702. local skillItemGo = self:GetSkillItemGo(i);
  703. local skillLua = skillItemGo
  704. self.SkillItemCls[#self.SkillItemCls+1] = skillLua
  705. if isLeader then
  706. self.uiBase:AddButtonEventListener(skillLua.add.button,self, self.OnClickSkillSlotAddBtn)
  707. end
  708. end
  709. end
  710. function UIRoleMain1View:OnClickSkillIconBtn(btn,params)
  711. local slotIdx = params[0];
  712. --self:UIHide(false)
  713. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillTips,slotIdx, nil, self.uiData.id)
  714. end
  715. function UIRoleMain1View:OnClickSkillLockBtn(btn,params)
  716. local slotIdx = params[0];
  717. local skillSlot = ManagerContainer.DataMgr.SkillsData:GetSkillSlotData(slotIdx);
  718. if skillSlot ~= nil then
  719. skillSlot:ShowLockTips()
  720. end
  721. end
  722. function UIRoleMain1View:OnClickSkillSlotAddBtn()
  723. --self:UIHide(false)
  724. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillTree, nil, self.uiData.id)
  725. end
  726. function UIRoleMain1View:RefreshSkills()
  727. if isLeader then
  728. for i=1, 4 do
  729. self:RefreshSkillSlot(i)
  730. end
  731. else
  732. local skills = self.controller:GetHeroLogicData().skills
  733. for i=1, 4 do
  734. self:RefreshSkillSlot(i,skills[i])
  735. end
  736. end
  737. end
  738. function UIRoleMain1View:OnShowSkillTips(btn,params)
  739. local skillId = params[0]
  740. if skillId == nil then
  741. return
  742. end
  743. local skill = self.controller:GetSkillById(skillId)
  744. --self:UIHide(false)
  745. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillPTTips,skill, self.uiData.id)
  746. end
  747. function UIRoleMain1View:RefreshSkillSlot(slotIdx, skill)
  748. local skillSlot = ManagerContainer.DataMgr.SkillsData:GetSkillSlotData(slotIdx);
  749. if skillSlot == nil then
  750. return
  751. end
  752. local vis = skillSlot:IsUnlocked()
  753. local skillLua = self.SkillItemCls[slotIdx]
  754. local skillIcon = skillLua.transform:Find("Icon"):GetComponent(Enum.TypeInfo.Image);
  755. local iconBtn = skillLua.transform:Find("Icon"):GetComponent(Enum.TypeInfo.Button);
  756. local uiDragItem = skillLua.transform:Find("Icon"):GetComponent(Enum.TypeInfo.UIDragItem);
  757. if isLeader then
  758. skillLua.gameObject:SetActive(true)
  759. skillIcon.gameObject:SetActive(vis)
  760. skillLua.frame:SetActive(vis)
  761. -- skillLua.label:SetActive(vis)
  762. skillLua.lvbg:SetActive(vis)
  763. skillLua.add:SetActive(vis)
  764. skillLua.lock:SetActive(not vis)
  765. skillLua.mask:SetActive(not vis)
  766. self.uiBase:AddButtonUniqueEventListener(iconBtn,self, self.OnClickSkillIconBtn,slotIdx)
  767. self.uiBase:AddButtonUniqueEventListener(skillLua.lock.button,self, self.OnClickSkillLockBtn,slotIdx)
  768. if vis then
  769. skillLua.text.text.text = "lv." .. skillSlot.level
  770. if skillSlot:HasArrangeSkill() then
  771. skillLua.add:SetActive(false)
  772. CommonUtil.LoadIcon(self, skillSlot.skill.skillCfg.Icon, function (sprite)
  773. if skillIcon~= nil then
  774. skillIcon.sprite = sprite
  775. end
  776. end)
  777. if isLeader then
  778. uiDragItem:Reset(slotIdx)
  779. uiDragItem.onBeginDrag = function()
  780. iconBtn.interactable = false;
  781. self.MoveSkillItem.image.sprite = skillIcon.sprite;
  782. uiDragItem:SetMoveItem(self.MoveSkillItem.rectTransform)
  783. end
  784. uiDragItem.onEndDrag = function()
  785. if uiDragItem.LastSlotIdx ~= uiDragItem.slotIdx then
  786. ManagerContainer.DataMgr.SkillsData:SendSwapSkill(uiDragItem.LastSlotIdx,uiDragItem.slotIdx)
  787. end
  788. self.MoveSkillItem:SetActive(false)
  789. iconBtn.interactable = true;
  790. end
  791. end
  792. else
  793. skillLua.add:SetActive(true)
  794. skillLua.lvbg:SetActive(false)
  795. skillIcon.gameObject:SetActive(false)
  796. end
  797. end
  798. else
  799. skillLua.gameObject:SetActive(skill ~= nil)
  800. skillLua.icon:SetActive(skill ~= nil)
  801. skillLua.transform.parent:Find("Lable"..slotIdx).gameObject:SetActive(skill ~= nil)
  802. skillLua.frame:SetActive(true)
  803. skillLua.label:SetActive(skill ~= nil and not skill:IsPassiveSkill())
  804. skillLua.lvbg:SetActive(skill ~= nil)
  805. skillLua.add:SetActive(false)
  806. skillLua.lock:SetActive(skill ~= nil and not skill.isUnlocked)
  807. skillLua.mask:SetActive(skill ~= nil and not skill.isUnlocked)
  808. if skill ~= nil then
  809. skillLua.text.text.text = "lv" .. skill.level
  810. self.uiBase:AddButtonUniqueEventListener(skillLua.icon.button,self, self.OnShowSkillTips,skill.skillId)
  811. self.uiBase:AddButtonUniqueEventListener(skillLua.lock.button,self, self.OnShowSkillTips,skill.skillId)
  812. if skill.skillCfg~= nil then
  813. CommonUtil.LoadIcon(self, skill.skillCfg.Icon, function (sprite)
  814. if skillLua.icon~= nil then
  815. skillLua.icon.image.sprite = sprite
  816. end
  817. end)
  818. end
  819. end
  820. end
  821. end
  822. function UIRoleMain1View:RefreshSkillSlotPartner(slotIdx,skill)
  823. local skillLua = self.SkillItemCls[slotIdx]
  824. if skillLua == nil then
  825. LogError("UIRolePtView:RefreshSkillSlot:" .. slotIdx);
  826. return
  827. end
  828. --self:RefreshSkillSlot(slotIdx,skill)
  829. self:SetSkillData(skillLua,skill)
  830. end
  831. function UIRoleMain1View:GetSkillItemGo(slotIdx)
  832. if slotIdx == 1 then
  833. return self.Skill1;
  834. end
  835. if slotIdx == 2 then
  836. return self.Skill2;
  837. end
  838. if slotIdx == 3 then
  839. return self.Skill3;
  840. end
  841. if slotIdx == 4 then
  842. return self.Skill4;
  843. end
  844. end
  845. function UIRoleMain1View:SetSkillData(skillLua,skill)
  846. skillLua.gameObject:SetActive(true)
  847. skillLua.frame:SetActive(true)
  848. skillLua.label:SetActive(not skill:IsPassiveSkill())
  849. skillLua.lvbg:SetActive(true)
  850. skillLua.add:SetActive(false)
  851. skillLua.lock:SetActive(not skill.isUnlocked)
  852. skillLua.mask:SetActive(not skill.isUnlocked)
  853. skillLua.text.text.text = "lv" .. skill.level
  854. self.uiBase:AddButtonUniqueEventListener(skillLua.icon.button,self, self.OnShowSkillTips,skill.skillId)
  855. self.uiBase:AddButtonUniqueEventListener(skillLua.lock.button,self, self.OnShowSkillTips,skill.skillId)
  856. if skill.skillCfg~= nil then
  857. CommonUtil.LoadIcon(skill.skillCfg.Icon, function (sprite)
  858. if skillLua.icon~= nil then
  859. skillLua.icon.image.sprite = sprite
  860. end
  861. end, self.uiData.id, self.controller:GetAsyncIdx())
  862. end
  863. end
  864. function UIRoleMain1View:RemoveEventListener()
  865. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  866. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.FASHION_WEAR_CHANGE, self, self.RefreshDefaultRoleView)
  867. end
  868. function UIRoleMain1View:OpenFashionChangeView()
  869. --self:UIHide(false)
  870. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIFashion, nil, self.uiData.id)
  871. end
  872. function UIRoleMain1View:OpenTitleListView()
  873. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITitleList, nil, self.uiData.id)
  874. end
  875. function UIRoleMain1View:OnPvpSuppressClick()
  876. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPvpSuppressTips)
  877. end
  878. function UIRoleMain1View:OnPveBlessClick()
  879. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPveBlessTips,self.controller:GetData())
  880. end
  881. function UIRoleMain1View:OnTransferClick()
  882. local logicData = self.controller:GetHeroLogicData()
  883. --self:UIHide(false)
  884. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleChangeJob, logicData.id, self.uiData.id)
  885. end
  886. function UIRoleMain1View:AddUIEventListener()
  887. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  888. self.uiBase:AddButtonEventListener(self.leadBox.btnSkill.button,self,self.OnClickSkillBtn)
  889. self.uiBase:AddButtonEventListener(self.ptBox.btnSkill.button,self,self.OnClickSkillBtn)
  890. self.uiBase:AddButtonEventListener(self.leadBox.btnNature.button, function ()
  891. --self:UIHide(false)
  892. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleNaturePoint, self.controller:GetData(), self.uiData.id)
  893. end)
  894. self.uiBase:AddButtonEventListener(self.ptBox.btnNature.button, function ()
  895. --self:UIHide(false)
  896. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleNaturePoint, self.controller:GetData(), self.uiData.id)
  897. end)
  898. self.uiBase:AddButtonEventListener(self.leadBox.btnTransfer.button, self, self.OnTransferClick)
  899. self.uiBase:AddButtonEventListener(self.ptBox.btnTransfer.button, self, self.OnTransferClick)
  900. self.uiBase:AddButtonEventListener(self.btnPvpSuppress.button, self, self.OnPvpSuppressClick)
  901. self.uiBase:AddButtonEventListener(self.btnPveBless.button, self, self.OnPveBlessClick)
  902. self.uiBase:AddButtonEventListener(self.btnOneKeyEquip.button, function ()
  903. local hasRp = true
  904. if isLeader then
  905. hasRp = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroEquipDressRPStatus() == Enum.RedPointEnum.EquipDressRP
  906. else
  907. local logicData = self.controller:GetHeroLogicData()
  908. if logicData.isBattle then
  909. hasRp = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerEquipDressRPStatusById(logicData.id) == Enum.RedPointEnum.EquipDressRP
  910. end
  911. end
  912. local hasEquip = self.controller:HasEquipOn()
  913. if not hasEquip and not hasRp then
  914. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(Enum.ActionNotiveType.NoSuitableEquip)
  915. return
  916. end
  917. if hasRp then
  918. self.controller:SendOneKeyEquipDress()
  919. end
  920. end)
  921. self.uiBase:AddButtonEventListener(self.btnOnekeyDown.button, function ()
  922. local hasRp = false
  923. if isLeader then
  924. hasRp = ManagerContainer.RedPointMgr.HeroRPCtr:GetHeroEquipDressRPStatus() == Enum.RedPointEnum.EquipDressRP
  925. else
  926. local logicData = self.controller:GetHeroLogicData()
  927. --if logicData.isBattle then
  928. hasRp = ManagerContainer.RedPointMgr.HeroRPCtr:GetPartnerEquipDressRPStatusById(logicData.id) == Enum.RedPointEnum.EquipDressRP
  929. --end
  930. end
  931. local hasEquip = self.controller:HasEquipOn()
  932. if not hasEquip and not hasRp then
  933. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(Enum.ActionNotiveType.NoSuitableEquip)
  934. return
  935. end
  936. if not hasRp then
  937. self.controller:SendOneKeyEquipPutOff()
  938. end
  939. end)
  940. self.uiBase:AddButtonEventListener(self.btnOneKeyForge.button, function ()
  941. self.controller:SendOneKeyUp()
  942. end)
  943. self.uiBase:AddButtonEventListener(self.btnLeft.button, function ()
  944. self.controller:SwichParterHero(-1)
  945. end)
  946. self.uiBase:AddButtonEventListener(self.btnRight.button, function ()
  947. self.controller:SwichParterHero(1)
  948. end)
  949. self.uiBase:AddButtonEventListener(self.btnRefineExtra.button, function ()
  950. local slotIndex = self.controller:GetCurSLotIndex()
  951. local slots = ManagerContainer.DataMgr.UserData:GetCurSlotInfos(slotIndex)
  952. if slots == nil then return end
  953. local lv = ManagerContainer.DataMgr.UserData:GetMinRefineLevel(slots)
  954. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRefineExtraPop, lv)
  955. end)
  956. self.uiBase:AddButtonEventListener(self.ptBox.btnLvUp.button, function ()
  957. local logicData = self.controller:GetHeroLogicData()
  958. local curMaxLv, advenceMaxLv = self.controller:GetPartnerCurMaxLv()
  959. local maxLv = advenceMaxLv or curMaxLv
  960. local stepData = self.controller:GetHeroStepData()
  961. if logicData.baseLevel >= maxLv and logicData.advanceLevel >= #stepData.AddLv then
  962. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("ParterLvUpMax")
  963. return
  964. end
  965. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPartnerLvUp, self.controller:GetData())
  966. end)
  967. self.uiBase:AddButtonEventListener(self.ptBox.btnBreak.button, function ()
  968. local logicData = self.controller:GetHeroLogicData()
  969. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  970. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleStrength, cfgData.ParterId)
  971. end)
  972. self.uiBase:AddButtonEventListener(self.btnDown.button, function ()
  973. local logicData = self.controller:GetHeroLogicData()
  974. self.controller:PartnerBattleReq(logicData.id, false)
  975. end)
  976. self.uiBase:AddButtonEventListener(self.btnGoOut.button, function ()
  977. local partnerBattleCount = self.controller:GetBattlePartnerCount()
  978. if partnerBattleCount >= 3 then
  979. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("ChangePartnerTips")
  980. return
  981. end
  982. local logicData = self.controller:GetHeroLogicData()
  983. self.controller:PartnerBattleReq(logicData.id, true)
  984. end)
  985. self.model.uIEventTriggerListener.onDrag = function()
  986. local deltaX = self.model.uIEventTriggerListener.currentEventData.delta.x
  987. curModel.transform:Rotate(Vector3.New(0, deltaX > 0 and -7 or 7, 0))
  988. end
  989. self.uiBase:AddButtonEventListener(self.ptBox1.btnRecruit.button, self, self.OnBtnRecruitClick)
  990. self.uiBase:AddButtonEventListener(self.leadBox.btnFashion.button, self, self.OpenFashionChangeView)
  991. self.uiBase:AddButtonEventListener(self.leadBox.btnTitle.button, self, self.OpenTitleListView)
  992. self.uiBase:AddButtonEventListener(self.btnOneKeyCardUp.button, self, self.OnOneKeyCardUp)
  993. self.uiBase:AddButtonEventListener(self.btnOnekeyCardDown.button, self, self.OnOneKeyCardDown)
  994. self.uiBase:AddButtonEventListener(self.btnOneKeyCardForge.button, self, self.OnOneKeyCardForge)
  995. self.uiBase:AddButtonEventListener(self.btnNature.button, self, self.OnNatureDscClick)
  996. self.uiBase:AddButtonEventListener(self.btnCardBless.button, self, self.OnCardBlessClick)
  997. self.uiBase:AddButtonEventListener(self.btnLog.button, self, self.OnClickBtnLog)
  998. self.uiBase:AddButtonEventListener(self.skillEquipSlot.button, self, self.OnSkillEquipClick)
  999. end
  1000. function UIRoleMain1View:OnClickBtnLog(button, params)
  1001. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  1002. if not lastClickLogTime or (curTime - lastClickLogTime) > 15000 then
  1003. lastClickLogTime = curTime
  1004. lastClickNum = 0
  1005. end
  1006. if not lastClickNum then
  1007. lastClickNum = 0
  1008. end
  1009. lastClickNum = lastClickNum + 1
  1010. if lastClickNum >= 30 then
  1011. lastClickNum = 0
  1012. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('Egg2')
  1013. end
  1014. end
  1015. function UIRoleMain1View:OnNatureDscClick()
  1016. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINatureInfo)
  1017. end
  1018. function UIRoleMain1View:OnCardBlessClick()
  1019. local id = self.controller:GetData()
  1020. local curLv = ManagerContainer.DataMgr.CardData:GetCardSuitLvById(id)
  1021. local count,totalCount = ManagerContainer.DataMgr.CardData:GetCardSuitCountById(id)
  1022. local state = ManagerContainer.DataMgr.CardData:GetCardSuitStateById(id)
  1023. local slot = ManagerContainer.DataMgr.UserData:GetSlotInfoById(id)
  1024. local data = {curLv = curLv, count = count, totalCount = totalCount, state = state, slot = slot}
  1025. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UICardBlessTips, data)
  1026. end
  1027. function UIRoleMain1View:OnBtnRecruitClick(button, params)
  1028. local recruitCostOwned = CommonUtil.GetOwnResCountByItemId(recruitCostId)
  1029. if recruitCostOwned < recruitCostNum then
  1030. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("RecruitItemUnFull")
  1031. return
  1032. end
  1033. local logicData = self.controller:GetHeroLogicData()
  1034. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(logicData.configId)
  1035. --判断队伍里是否已经有坦有奶
  1036. local partnerCount = ManagerContainer.DataMgr.PartnerData:GetOwnedPartnerCount()
  1037. local hasTank, hasPure = false, false
  1038. local needSecondNtf = true
  1039. if partnerCount == 0 or partnerCount >= 3 then
  1040. needSecondNtf = false
  1041. else
  1042. local roleJobId = ManagerContainer.DataMgr.UserData:GetJobCfgId()
  1043. local roleJobData = ManagerContainer.CfgMgr:GetJobDataById(roleJobId)
  1044. if not hasTank or not hasPure then
  1045. if roleJobData and (roleJobData.JobType == 1 or roleJobData.JobType == 5) then
  1046. if not hasTank then
  1047. hasTank = roleJobData.JobType == 1
  1048. end
  1049. if not hasPure then
  1050. hasPure = roleJobData.JobType == 5
  1051. end
  1052. end
  1053. end
  1054. if not hasTank or not hasPure then
  1055. local partnerDatas = ManagerContainer.DataMgr.PartnerData:GetPartnerDatas()
  1056. for k,v in pairs(partnerDatas) do
  1057. if v.owned then
  1058. local cfgData1 = ManagerContainer.CfgMgr:GetPartnerDataById(v.configId)
  1059. if cfgData1 and (cfgData1.JobType == 1 or cfgData1.JobType == 5) then
  1060. if not hasTank then
  1061. hasTank = cfgData1.JobType == 1
  1062. end
  1063. if not hasPure then
  1064. hasPure = cfgData1.JobType == 5
  1065. end
  1066. end
  1067. end
  1068. end
  1069. end
  1070. if cfgData and (cfgData.JobType == 1 or cfgData.JobType == 5) then
  1071. if not hasTank then
  1072. hasTank = cfgData.JobType == 1
  1073. end
  1074. if not hasPure then
  1075. hasPure = cfgData.JobType == 5
  1076. end
  1077. end
  1078. if partnerCount < 2 then
  1079. needSecondNtf = not hasTank and not hasPure
  1080. else
  1081. needSecondNtf = not hasTank or not hasPure
  1082. end
  1083. end
  1084. local data = {}
  1085. local data1
  1086. if not needSecondNtf then
  1087. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(recruitCostId)
  1088. data[1] = I18N.T(itemCfgData.Name)
  1089. data[2] = recruitCostNum
  1090. data[3] = I18N.T(cfgData.Name)
  1091. data[4] = I18N.T(cfgData.JobName)
  1092. data1 = {"PartnerActive", data, nil, self, self.OnRecruitSure}
  1093. else
  1094. data[1] = I18N.T(cfgData.JobName)
  1095. data[2] = I18N.T(cfgData.Name)
  1096. data1 = {"PartnerActive1", nil, nil, self, nil, self.OnRecruitSure, data}
  1097. end
  1098. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data1)
  1099. end
  1100. function UIRoleMain1View:OnRecruitSure()
  1101. local count = CommonUtil.GetOwnResCountByItemId(Enum.ItemIds.Recruit)
  1102. if count < recruitCostNum then
  1103. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("RecruitItemUnFull")
  1104. return
  1105. end
  1106. local logicData = self.controller:GetHeroLogicData()
  1107. self.controller:SendRecruit(logicData.configId)
  1108. end
  1109. function UIRoleMain1View:RecruitSucceed()
  1110. self:RemoveCurModel()
  1111. local logicData = self.controller:GetHeroLogicData()
  1112. local data = {1, self.previewSystem, false, self.roleViewSystems[logicData.id], nil, logicData.configId}
  1113. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITransPerform, data)
  1114. end
  1115. function UIRoleMain1View:GetModelRawImageTex()
  1116. return self.model.rawImage.texture
  1117. end
  1118. function UIRoleMain1View:OnHide()
  1119. if self.previewSystem then
  1120. self.previewSystem:Dispose(true)
  1121. end
  1122. self.previewSystem = nil
  1123. for i = 1, 6 do
  1124. self.roleViewSystems[i]:Dispose()
  1125. end
  1126. self.roleViewSystems = nil
  1127. end
  1128. function UIRoleMain1View:OnShow(data)
  1129. self.controller:SetData(data)
  1130. if not data then
  1131. self.controller:SetData(data)
  1132. end
  1133. self:Init()
  1134. self.delayTimer = FrameTimer.New(function()
  1135. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_MAIN_TOP_RES_TYPE, isLeader and Enum.ItemType.Diamond or Enum.ItemType.ParterExp)
  1136. end, 1)
  1137. self.delayTimer:Start()
  1138. end
  1139. function UIRoleMain1View:OnBackIn()
  1140. end
  1141. function UIRoleMain1View:OnClose()
  1142. -- CommonUtil.SetGOLayer(curModel, Constant.DefaultLayer)
  1143. if self.inited then
  1144. DG.Tweening.DOTween.Kill(self.transform)
  1145. self.recommendSkillId = nil
  1146. self.model.uIEventTriggerListener.onDrag = nil
  1147. self.controller:SetCurOwnerIndex(1)
  1148. end
  1149. curModel = nil
  1150. lastClickLogTime = nil
  1151. lastClickNum = nil
  1152. if self.previewSystem then
  1153. self.previewSystem:Dispose()
  1154. end
  1155. self.previewSystem = nil
  1156. if self.roleViewSystems then
  1157. for i = 1, 6 do
  1158. self.roleViewSystems[i]:Dispose()
  1159. end
  1160. self.roleViewSystems = nil
  1161. end
  1162. if self.delayTimer then
  1163. self.delayTimer:Stop()
  1164. end
  1165. self.delayTimer = nil
  1166. end
  1167. function UIRoleMain1View:RefreshCardSlotOpenRP()
  1168. self:RefreshFellowBtns()
  1169. self:RefreshEquips()
  1170. end
  1171. function UIRoleMain1View:OnOneKeyCardUp()
  1172. self.controller:OnOneKeyCardUp()
  1173. end
  1174. function UIRoleMain1View:OnOneKeyCardDown()
  1175. self.controller:OnOneKeyCardDown()
  1176. end
  1177. function UIRoleMain1View:OnOneKeyCardForge()
  1178. self.controller:OnOneKeyCardForge()
  1179. end
  1180. function UIRoleMain1View:RefreshCardSuitBtn()
  1181. local id = self.controller:GetData()
  1182. local curLv = ManagerContainer.DataMgr.CardData:GetCardSuitLvById(id)
  1183. local state = ManagerContainer.DataMgr.CardData:GetCardSuitStateById(id)
  1184. local allCfgDatas = ManagerContainer.CfgMgr:GetAllCardSuitNewCfg()
  1185. if not state then
  1186. curLv = curLv - 1
  1187. end
  1188. self.cardBlessLv.lv0:SetActive(curLv == 0)
  1189. for i = 1, #allCfgDatas do
  1190. if self.cardBlessLv["lv"..i] then
  1191. self.cardBlessLv["lv"..i]:SetActive(curLv == i)
  1192. end
  1193. end
  1194. end
  1195. function UIRoleMain1View:RefreshSkillSuitBtn()
  1196. local id = self.controller:GetData()
  1197. local pressValue = ManagerContainer.DataMgr.UserData:GetCurrRoleSkillPress()
  1198. self.btnPvpSuppress.num.text.text = pressValue
  1199. local skillData = ManagerContainer.DataMgr.UserData:GetSkillData(id)
  1200. if skillData == nil then
  1201. self.pveBlessLv:SetActive(false)
  1202. return
  1203. end
  1204. self.pveBlessLv:SetActive(true)
  1205. local currNerveLv = skillData:GetCurrNerveLv()
  1206. local allCfgDatas = ManagerContainer.CfgMgr:GetAllSkillSuitNewCfg()
  1207. for i = 1, #allCfgDatas do
  1208. if self.pveBlessLv["lv"..(i - 1)] then
  1209. self.pveBlessLv["lv"..(i - 1)]:SetActive(currNerveLv == i)
  1210. end
  1211. end
  1212. end
  1213. -------------------------------------------------------神器-----------------------------------------------------
  1214. function UIRoleMain1View:RefreshSkillEquip()
  1215. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIArtifactTips)
  1216. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIEquipList)
  1217. if isLeader then
  1218. self:RefreshDefaultRoleView()
  1219. else
  1220. local logicData = self.controller:GetHeroLogicData()
  1221. self:RefreshPartnerView(logicData.id, logicData.configId, logicData)
  1222. end
  1223. self:SkillEquipSlotSuccess()
  1224. self:RefreshSkillEquipRP()
  1225. end
  1226. function UIRoleMain1View:RefreshSkillEquipRP()
  1227. self:RefreshFellowBtns()
  1228. local heroId = self.controller:GetData()
  1229. local skillEquipRP = ManagerContainer.RedPointMgr.HeroRPCtr:GetRoleSkillEuipSlotRP(heroId)
  1230. self.skillEquipSlot.redPointItem.redPoint:SetActive(skillEquipRP)
  1231. end
  1232. function UIRoleMain1View:SkillEquipSlotSuccess()
  1233. local curSkillEquipData = self.controller:GetCurHeroSkillEquipSlotData()
  1234. self.skillEquipSlot.iconItem:SetActive(curSkillEquipData ~= nil and curSkillEquipData.id > 0)
  1235. self.artifact.lightBlue:SetActive(curSkillEquipData ~= nil and curSkillEquipData.id > 0)
  1236. if curSkillEquipData and curSkillEquipData.cfgId > 0 then
  1237. IconItemCtr:SetData(self, self.skillEquipSlot.iconItem, curSkillEquipData, Enum.ItemIEnterType.HeroEquip, self, self.OnSkillEquipClick)
  1238. end
  1239. end
  1240. function UIRoleMain1View:ChangeSkillEquip(button, params)
  1241. local skillEquipId = params[0]
  1242. self.controller:SendSkillEquipUpReq(skillEquipId)
  1243. end
  1244. function UIRoleMain1View:DownSkillEquip()
  1245. self.controller:SendSkillEquipDownReq()
  1246. end
  1247. function UIRoleMain1View:OnSkillEquipClick(button, params)
  1248. local heroData = self.controller:GetHeroLogicData()
  1249. local jobType = self.controller:GetHeroJobType()
  1250. local curSkillEquipData = self.controller:GetCurHeroSkillEquipSlotData()
  1251. if not curSkillEquipData or curSkillEquipData.id == 0 then
  1252. local data = {{cfgId = 0, cbOwner = self, cb = self.ChangeSkillEquip, cb1 = self.DownSkillEquip, jobType = jobType, logicData = curSkillEquipData}, Enum.ItemIEnterType.SkillEquip}
  1253. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIEquipList, data)
  1254. else
  1255. local data = {{cfgId = curSkillEquipData.cfgId, cbOwner = self, cb = self.ChangeSkillEquip, cb1 = self.DownSkillEquip, jobType = jobType, logicData = curSkillEquipData, heroId = heroData.id, heroCfgId = heroData.configId, nickname = heroData.nickname}, Enum.ItemIEnterType.SkillEquip, self.uiData.id}
  1256. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactTips, data)
  1257. end
  1258. end
  1259. ------------------------------------------------------------------------------------------------------------------
  1260. function UIRoleMain1View:RecommendRoleById(id, owner, ownerCB)
  1261. local logicData = ManagerContainer.DataMgr.UserData:GetHeroData()
  1262. local jobData = ManagerContainer.CfgMgr:GetJobDataById(logicData.configId)
  1263. if jobData.JobStage ~= 1 then
  1264. if owner and ownerCB then
  1265. ownerCB(owner)
  1266. end
  1267. return
  1268. end
  1269. local recommendType = Enum.JobRecommend[jobData.JobType]
  1270. local partners = ManagerContainer.DataMgr.PartnerData:GetPartnerDatas()
  1271. for _,v in pairs(partners) do
  1272. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(v.configId)
  1273. if cfgData.JobType == recommendType[1] then
  1274. self.controller:SetData(v.id)
  1275. self:Refresh()
  1276. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_MAIN_TOP_RES_TYPE, isLeader and Enum.ItemType.Diamond or Enum.ItemType.ParterExp)
  1277. break
  1278. end
  1279. end
  1280. if owner and ownerCB then
  1281. ownerCB(owner)
  1282. end
  1283. end
  1284. function UIRoleMain1View:PartnerLvUpById(id, owner, ownerCB)
  1285. local partnerData = ManagerContainer.DataMgr.PartnerData:GetPartnerDataByUniqueId(id)
  1286. if not partnerData.owned then
  1287. if owner and ownerCB then
  1288. ownerCB(owner)
  1289. end
  1290. return
  1291. end
  1292. local target = self["role"..id]
  1293. if target == nil then
  1294. if owner and ownerCB then
  1295. ownerCB(owner)
  1296. end
  1297. return
  1298. end
  1299. target = target.head
  1300. if target == nil then
  1301. if owner and ownerCB then
  1302. ownerCB(owner)
  1303. end
  1304. return
  1305. end
  1306. if owner and ownerCB then
  1307. ownerCB(owner, target)
  1308. end
  1309. end
  1310. function UIRoleMain1View:OnDispose()
  1311. self.controller:OnDispose()
  1312. end
  1313. return UIRoleMain1View