local UITownHome_FunctionEntry = UIViewClass() local EventSystem = require('Event/EventSystem') function UITownHome_FunctionEntry:OnCreated() --这个是不关闭界面的btn组 self.bottomPanelNotCloseBtn = { [self.event_Bag] = 1, [self.event_Rank] = 1, [self.Formation_Lock] = 1, [self.ShowHero_Lock] = 1, [self.Guild_Lock] = 1, [self.OfficialPosition_Lock] = 1, [self.Setting_Lock] = 1, } end function UITownHome_FunctionEntry:OnOpened() self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.OnFunctionUnlockUpdate) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.HeroBtn, self.RefreshHeroBtnRp) -- 刷新武将红点 self:RegistSystemEvent(EventID.UI_Achievement_RefreshRedPoint, self.RefreshAchievementRp) self:RegistSystemEvent(EventID.UI_ResonanceChange_Refresh, self.RefreshResonanceRp) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshResonanceRp) --红点消息 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.WeaponBtn, self.RefreshWeaponBtnRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Formation, self.RefreshFormationRp) -- 刷新阵容红点 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Equipment, self.RefreshEquipmentRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.OfficialPosition, self.RefreshOfficialPositionBtnRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Reborn, self.RefreshRebornRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Stratagem, self.RefreshStratagemRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Library, self.RefreshLibraryRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild, self.RefreshGuildRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Rank, self.RefreshRankBtnRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Treasure, self.RefreshTreasureRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Bag, self.RefreshBagRedPoint) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Setting, self.RefreshSettingRedPoint) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.GodBeast, self.RefreshGodBeastRp) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshBagFull) self:InitBtns() self:InitBtnsRp() self:RefreshBagFull() end function UITownHome_FunctionEntry:InitBtns() self:UpdateBtns(MDL.Unlock.FunctionType.Weapon, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Weapon)) self:UpdateBtns(MDL.Unlock.FunctionType.Rank, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Rank)) self:UpdateBtns(MDL.Unlock.FunctionType.Formation, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Formation)) self:UpdateBtns(MDL.Unlock.FunctionType.Equipment, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Equipment)) self:UpdateBtns(MDL.Unlock.FunctionType.WarHorse, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WarHorse)) self:UpdateBtns(MDL.Unlock.FunctionType.OfficialPosition, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.OfficialPosition)) self:UpdateBtns(MDL.Unlock.FunctionType.Team, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Team)) self:UpdateBtns(MDL.Unlock.FunctionType.Guild, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild)) self:UpdateBtns(MDL.Unlock.FunctionType.Treasure, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Treasure)) self:UpdateBtns(MDL.Unlock.FunctionType.Bag, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Bag)) self:UpdateBtns(MDL.Unlock.FunctionType.Achievement, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Achievement)) self:UpdateBtns(MDL.Unlock.FunctionType.Library, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Library)) self:UpdateBtns(MDL.Unlock.FunctionType.Resonance, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Resonance)) self:UpdateBtns(MDL.Unlock.FunctionType.Reborn, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Reborn)) self:UpdateBtns(MDL.Unlock.FunctionType.Stratagem, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Stratagem)) self:UpdateBtns(MDL.Unlock.FunctionType.GodBeast, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GodBeast)) self:UpdateBtns(MDL.Unlock.FunctionType.Pet, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Pet)) end function UITownHome_FunctionEntry:OnFunctionUnlockUpdate(id, state) self:UpdateBtns(id, state) end --**_Lock是右下角面板遮罩的显隐,event_**是按钮本身的显隐,请注意 function UITownHome_FunctionEntry:UpdateBtns(id, state) if id == MDL.Unlock.FunctionType.Weapon then self:SetBtnState(self.state_DivineWeapon, state, self.event_DivineWeapon) self:RefreshWeaponBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WeaponBtn)) elseif id == MDL.Unlock.FunctionType.Rank then self:SetBtnState(self.state_Rank, state, self.event_Rank) elseif id == MDL.Unlock.FunctionType.Formation then UIUtils.SetActive(self.Formation_Lock.gameObject, not state) self:RefreshFormationRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation)) elseif id == MDL.Unlock.FunctionType.Equipment then self:SetBtnState(self.state_Equipment, state, self.event_Equipment) self:RefreshEquipmentRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Equipment)) elseif id == MDL.Unlock.FunctionType.WarHorse then self:SetBtnState(self.state_WarHorse, state, self.event_WarHorse) self:RefreshWarHorseRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WarHorse)) elseif id == MDL.Unlock.FunctionType.Reborn then self:SetBtnState(self.state_Reborn, state, self.event_Reborn) self:RefreshRebornRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Reborn)) elseif id == MDL.Unlock.FunctionType.OfficialPosition then UIUtils.SetActive(self.OfficialPosition_Lock.gameObject, not state) self:RefreshOfficialPositionBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition)) elseif id == MDL.Unlock.FunctionType.Guild then UIUtils.SetActive(self.Guild_Lock.gameObject, not state) elseif id == MDL.Unlock.FunctionType.Treasure then self:SetBtnState(self.state_Treasure, state, self.event_Treasure) self:RefreshTreasureRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Treasure)) elseif id == MDL.Unlock.FunctionType.Bag then self:SetBtnState(self.state_Bag, state, self.event_Bag) self:RefreshBagRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Bag)) elseif id == MDL.Unlock.FunctionType.Achievement then self:SetBtnState(self.state_Achievement, state, self.event_Achievement) self:RefreshAchievementRp() elseif id == MDL.Unlock.FunctionType.Resonance then self:SetBtnState(self.state_Resonance, state, self.event_Resonance) self:RefreshResonanceRp() elseif id == MDL.Unlock.FunctionType.Library then self:SetBtnState(self.state_illustratedHandbook, state, self.event_illustratedHandbook) self:RefreshLibraryRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Library)) elseif id == MDL.Unlock.FunctionType.GodBeast then self:SetBtnState(self.state_MythicalAnimals, state, self.event_MythicalAnimals) self:RefreshGodBeastRp() elseif id == MDL.Unlock.FunctionType.Pet then self:SetBtnState(self.state_Pet, state, self.event_Pet) self:RefreshPetRp() elseif id == MDL.Unlock.FunctionType.Stratagem then self:SetBtnState(self.state_Stratagem, state, self.event_Stratagem) self:RefreshWeaponBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Stratagem)) end end function UITownHome_FunctionEntry:SetBtnState(obj, state, btn) obj:SetState(state and 0 or 1) --背包和排行榜不论开启或是未开启点击后面板都不需要关闭,所以这里做判断忽略背包和排行榜 if state and btn ~= self.event_Bag and btn ~= self.event_Rank then self.bottomPanelNotCloseBtn[btn] = nil else self.bottomPanelNotCloseBtn[btn] = 1 end end function UITownHome_FunctionEntry:OnButtonClicked(obj) if self.bottomPanelNotCloseBtn[obj] == nil then EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightBottom, false) end if obj == self.event_Bag then --背包 if self.state_Bag.CurState == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else CTL.Bag.OpenUIBagPanel() end elseif obj == self.event_ShowHero then --界面里的英雄选择 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroSelectPanel) elseif obj == self.event_Setting then --设置 UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif obj == self.event_Equipment then --装备 if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else CTL.Equipment.OpenEquipMainPanel() end elseif obj == self.event_DivineWeapon then --神兵 if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else UIManager.OpenView(Const_UI_Lua.UIEnum.UIDivineWeapon) EventSystem.Dispatch(EventID.BI_ViewClick, BIManager.ViewBIEvent.UITownHome_FunctionEntry_event_DivineWeapon) end elseif obj == self.event_Rank then --排行榜 if self.state_Rank.CurState == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else CTL.Rank.OpenRankPanelByType() end elseif obj == self.event_Formation then --界面里的阵容 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroFormationPanel, nil) elseif obj == self.event_Treasure then --宝物 if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UITreasureMainPanel) end elseif obj == self.event_Achievement then -- 成就 if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIAchievementBase) end elseif obj == self.event_Resonance then -- 阵位共鸣 if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else UIManager.OpenView(Const_UI_Lua.UIEnum.UIMedal) end elseif obj == self.event_illustratedHandbook then if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIIllustratedMainPanel) end elseif obj == self.event_WarHorse then if self.bottomPanelNotCloseBtn[obj] == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else CTL.WarHorse.OpenMainPanel() end elseif obj == self.event_OfficialPosition then EventSystem.Dispatch(EventID.BI_ViewClick, BIManager.ViewBIEvent.UITownHome_FunctionEntry_event_OfficialPosition) CTL.OfficialPosition.OpenMainPanel() elseif obj == self.event_Guild then --界面里的势力 CTL.Guild.OpenGuildMain() elseif obj == self.event_Reborn then if self.state_Reborn.CurState == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") else CTL.Reborn.OpenRebornView() end --有自己的遮罩_Lock的按钮,未开启状态时 elseif obj == self.Guild_Lock or obj == self.OfficialPosition_Lock or obj == self.Formation_Lock or obj == self.ShowHero_Lock then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Formation_RelationShip_Closed"]) CTL.Sound.PlayGameSound("UI_invalid") elseif obj == self.event_MythicalAnimals then if self.state_MythicalAnimals.CurState == 1 then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_Formation_RelationShip_Closed"]) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGodBeastMainPanel) end elseif obj == self.event_Stratagem then if self.state_Stratagem.CurState == 1 then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_Formation_RelationShip_Closed"]) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIStratagemMainPanel) end elseif obj == self.event_Pet then if self.state_Pet.CurState == 1 then local _, condition = CTL.Activities.IsOpen(LuaConst.ActivityType.PetCatch) CTL.Tips.AddTipsMsgAndPlaySound(condition) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIPetBasePanel) end end end function UITownHome_FunctionEntry:RefreshOfficialPositionBtnRp(active) self.event_OfficialPosition:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.OfficialPosition) and active) end --region 红点 function UITownHome_FunctionEntry:InitBtnsRp() self:RefreshSettingRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Setting)) self:RefreshWeaponBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WeaponBtn)) self:RefreshBagRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Bag)) self:RefreshHeroBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.HeroBtn)) -- 初始化武将红点 self:RefreshEquipmentRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Equipment)) self:RefreshWarHorseRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WarHorse)) self:RefreshRebornRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Reborn)) self:RefreshFormationRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation)) -- 初始化阵容红点 self:RefreshGuildRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild)) self:RefreshRankBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Rank)) self:RefreshTreasureRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Treasure)) self:RefreshOfficialPositionBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition)) self:RefreshAchievementRp() self:RefreshResonanceRp() self:RefreshLibraryRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Library)) self:RefreshStratagemRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Stratagem)) self:RefreshGodBeastRp() self:RefreshPetRp() end function UITownHome_FunctionEntry:RefreshWeaponBtnRp(active) self.event_DivineWeapon:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Weapon) and active) end -- 排行榜红点 function UITownHome_FunctionEntry:RefreshRankBtnRp(active) self.event_Rank:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Rank) and active) end -- 武将按钮 function UITownHome_FunctionEntry:RefreshHeroBtnRp(active, userData) self.event_ShowHero:SetRedPoint(active) end function UITownHome_FunctionEntry:RefreshWarHorseRp(active) self.event_WarHorse:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WarHorse) and active) end function UITownHome_FunctionEntry:RefreshEquipmentRp(active) self.event_Equipment:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Equipment) and active) end function UITownHome_FunctionEntry:RefreshRebornRp(active) self.event_Reborn:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Reborn) and active) end -- 阵容红点 function UITownHome_FunctionEntry:RefreshFormationRp(active) self.event_Formation:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Formation) and active) end function UITownHome_FunctionEntry:RefreshGuildRp(active) self.event_Guild:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild) and active) end function UITownHome_FunctionEntry:RefreshTreasureRp(active) self.event_Treasure:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Treasure) and active) end function UITownHome_FunctionEntry:RefreshBagRedPoint(active) UIUtils.SetActive(self.BagRedPoint, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Bag) and active); end function UITownHome_FunctionEntry:RefreshSettingRedPoint(active) self.event_Setting:SetRedPoint(active) end function UITownHome_FunctionEntry:RefreshBagFull() UIUtils.SetActive(self.img_Full, CTL.Bag.IsBagFull()) end function UITownHome_FunctionEntry:RefreshStratagemRp(active) self.event_Stratagem:SetRedPoint(active) end function UITownHome_FunctionEntry:RefreshLibraryRp(active) self.event_illustratedHandbook:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Library) and active) end function UITownHome_FunctionEntry:RefreshAchievementRp() self.event_Achievement:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Achievement) and MDL.Achievement.IsShowEnterRedPoint()) end function UITownHome_FunctionEntry:RefreshResonanceRp() local isCanLevelup, _, _ = MDL.FormationResonance.IsCanLevelupMainResonance() self.event_Resonance:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Resonance) and isCanLevelup) end function UITownHome_FunctionEntry:RefreshGodBeastRp() self.event_MythicalAnimals:SetRedPoint( MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GodBeast) and CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.GodBeast) ) end function UITownHome_FunctionEntry:RefreshPetRp() self.event_Pet:SetRedPoint( MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Pet) and CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Pet) ) end return UITownHome_FunctionEntry