miduo_client/Assets/ManagedResources/~Lua/Modules/Main/MainPanel.lua

1431 lines
63 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
require("Modules/Main/View/MainPlayerView")
MainPanel = Inherit(BasePanel)
local this = MainPanel
local endTime = 0
local GlobalActConfig = ConfigManager.GetConfig(ConfigName.GlobalActivity)
local ActGroupsConfig = ConfigManager.GetConfig(ConfigName.ActivityGroups)
--示意图轮回放
local imageList = {}
-- 主界面需要隐藏的功能
this.btnFunHide = {}
this.btnFunGray = {}
this.runHorseData = {}
this.operateIcon = {}
this.multiple = 0 --显示信息次数
this.isOpen = false
this.SystemInfo = ""
local orginLayer
this.patFaceCallList = Stack.New()
local timePressStarted
local curMianTaskData = {}
local canGetMsg = true
local moveTranList
local isFirstOpen = 0
--local isCanDragMsg = true
local supremHadSet = false
local isUpperMonthCardTimeShow = true
local activitys = {}
local activityTabs = {}
local moveSceneList = {
[1] = 0,
[2] = 0.02,
[3] = 0.05,
[4] = 0.432,
[5] = 0.5,
[6] = 0.65,
[7] = 0.84,
}
local lightList = {
[1] = { -475, 185 },
[2] = { -1367, -950 },
[3] = { -2447, -2397 },
}
function this:AddFuncItem(btnGO, pos)
return {go = btnGO, open = Util.GetGameObject(btnGO, "open"), lock = Util.GetGameObject(btnGO, "lock"), pos = pos}
end
function this:InsertNewText(btn)
local xinText = Util.GetGameObject(btn, "new")
return xinText
end
local isRefeshIcon = true
local curNPCList = {}
--初始化组件(用于子类重写)
function this:InitComponent()
orginLayer = 0
self.bg = Util.GetGameObject(self.gameObject, "bg")
self.sceneTran = Util.GetGameObject(self.gameObject, "scene"):GetComponent("RectTransform")
self.lightEffect = Util.GetGameObject(self.gameObject, "scene/effect")
self.lightEffectActive = false
self.bgTran = Util.GetGameObject(self.gameObject, "bg"):GetComponent("RectTransform")
self.mountainTran = Util.GetGameObject(self.gameObject, "front"):GetComponent("RectTransform")
this.npcRoot = Util.GetGameObject(self.gameObject, "bg/npcRoot")
this.decorateRoot = Util.GetGameObject(self.gameObject, "bg/decorate")
self.ctrl = Util.GetGameObject(self.gameObject, "scene/ctrl")
---------------topLeftPart----------------
-- 七日登陆奖励预览入口
this.sgBtn=Util.GetGameObject(self.gameObject,"LeftUp/sevenGift")
this.sgRoot=Util.GetGameObject(this.sgBtn,"root")
this.sgItemView = SubUIManager.Open(SubUIConfig.ItemView,this.sgRoot.transform)
this.sgType=Util.GetGameObject(this.sgBtn,"type"):GetComponent("Text")
this.sgName=Util.GetGameObject(this.sgBtn,"name"):GetComponent("Text")
this.sgInfo=Util.GetGameObject(this.sgBtn,"info"):GetComponent("Text")
this.sgEffect={}
for i = 1, 2 do
this.sgEffect[i]=Util.GetGameObject(this.sgBtn,"effect/effect"..i)
end
effectAdapte(Util.GetGameObject(this.sgEffect[2], "ziti mask (1)"))
--十五日登录
this.fgBtn=Util.GetGameObject(self.gameObject,"LeftUp/FifteenDayGift")
---------------topRightPart----------------
-- 邮件
this.btnYouJian = Util.GetGameObject(self.gameObject, "LeftDown/btnRoot/btnYouJian")
this.mailRedPoint = Util.GetGameObject(this.btnYouJian, "redPoint")
-- 日常
this.btnDailyMission = Util.GetGameObject(self.gameObject, "LeftDown/btnRoot/btnDailyMission")
this.DailyRedPoint = Util.GetGameObject(this.btnDailyMission, "redPoint")
-- 好友
this.btnFriend = Util.GetGameObject(self.gameObject, "LeftDown/btnRoot/btnfriend")
this.friendRed = Util.GetGameObject(this.btnFriend, "redPoint")
-- 排行
this.btnRank = Util.GetGameObject(self.gameObject, "LeftDown/btnRoot/btnRank")
this.rankRed = Util.GetGameObject(this.btnRank, "redPoint")
-- 无尽
this.btnEndLess = Util.GetGameObject(self.gameObject, "LeftDown/btnRoot/btnEndLess")
this.btnEndLess:SetActive(false)
--鸿蒙
this.btnHongMeng=Util.GetGameObject(self.gameObject,"RightDown/btnHongMeng")
this.HongMengRedPoint = Util.GetGameObject(this.btnHongMeng,"redPoint")
-------------------场景中的按钮------------------------
-- 按钮
this.btnMonster = Util.GetGameObject(this.gameObject, "scene/layer2/btnShouchaolaixi")
this.btnExpedition = Util.GetGameObject(this.gameObject, "scene/layer2/btnexpedition")
this.btnJingjichang = Util.GetGameObject(this.gameObject, "scene/layer4/btnJingjichang")
-- this.btnGonghui:SetActive(false)
this.btnFenjie = Util.GetGameObject(this.gameObject, "scene/layer7/btnFenjie")
--this.btnTujian = Util.GetGameObject(this.gameObject, "scene/layer7/btnTujian")
this.btnShangdian = Util.GetGameObject(this.gameObject, "scene/layer7/btnShangdian")
this.btnEquipCompound = Util.GetGameObject(this.gameObject, "scene/layer3/btnEquipCompound")
-- this.btnPaihangbang = Util.GetGameObject(this.gameObject, "scene/layer4/btnPaihangbang")
-- this.btnGuanxing = Util.GetGameObject(this.gameObject, "scene/layer4/btnGuanxing")
this.btnRecruit = Util.GetGameObject(this.gameObject, "scene/layer6/btnRecruit")
this.btnElementDrawCard = Util.GetGameObject(this.gameObject, "scene/layer4/btnElementDrawCard")
this.btnSecretBox = Util.GetGameObject(this.gameObject, "scene/layer4/btnSecretBox")
this.btnYiYao = Util.GetGameObject(this.gameObject, "scene/layer4/btnYiYao")
this.btnPokemon = Util.GetGameObject(this.gameObject, "scene/layer6/btnPokemon")
-- this.btnTianFu = Util.GetGameObject(this.gameObject, "scene/layer6/btnTianFu")
this.btnWaiDi = Util.GetGameObject(this.gameObject, "scene/layer4/btnWaiDi")
this.btnColorfulWorld = Util.GetGameObject(this.gameObject, "scene/layer6/btnColorfulWorld")
this.btnWaiDi:SetActive(false)
this.btnCompoundHero = Util.GetGameObject(this.gameObject, "scene/layer3/btnCompoundHero")
this.btnTianShuMiJuan = Util.GetGameObject(this.gameObject, "scene/layer7/btnTianShuMiJuan")
this.operateIcon = {
[FUNCTION_OPEN_TYPE.SHOP] = this:AddFuncItem(this.btnShangdian, 50),
[FUNCTION_OPEN_TYPE.HERO_RESOLVE] = this:AddFuncItem(this.btnFenjie, -200),
[FUNCTION_OPEN_TYPE.ARENA] = this:AddFuncItem(this.btnJingjichang, -200),
[FUNCTION_OPEN_TYPE.ENDLESS] = this:AddFuncItem(this.btnColorfulWorld, -1500),
[FUNCTION_OPEN_TYPE.COMPOUND] = this:AddFuncItem(this.btnEquipCompound, -200),
[FUNCTION_OPEN_TYPE.RECURITY] = this:AddFuncItem(this.btnRecruit, -56),
[FUNCTION_OPEN_TYPE.ELEMENT_RECURITY] = this:AddFuncItem(this.btnElementDrawCard, 0),
[FUNCTION_OPEN_TYPE.COMPOUND_HERO] = this:AddFuncItem(this.btnCompoundHero, 0),--神将合成、置换
[FUNCTION_OPEN_TYPE.POKEMON] = this:AddFuncItem(this.btnPokemon, -1200),--神将合成、置换
[FUNCTION_OPEN_TYPE.tianshumijuan] = this:AddFuncItem(this.btnTianShuMiJuan, 0),
}
this.operateNewText = {
[FUNCTION_OPEN_TYPE.SHOP] = this:InsertNewText(this.btnShangdian),
[FUNCTION_OPEN_TYPE.HERO_RESOLVE] = this:InsertNewText(this.btnFenjie),
[FUNCTION_OPEN_TYPE.ARENA] = this:InsertNewText(this.btnJingjichang),
[FUNCTION_OPEN_TYPE.ENDLESS] = this:InsertNewText(this.btnColorfulWorld),
[FUNCTION_OPEN_TYPE.COMPOUND] = this:InsertNewText(this.btnEquipCompound),
[FUNCTION_OPEN_TYPE.RECURITY] = this:InsertNewText(this.btnRecruit),
[FUNCTION_OPEN_TYPE.ELEMENT_RECURITY] = this:InsertNewText(this.btnElementDrawCard),
[FUNCTION_OPEN_TYPE.COMPOUND_HERO] = this:InsertNewText(this.btnCompoundHero),--神将合成、置换
[FUNCTION_OPEN_TYPE.POKEMON] = this:InsertNewText(this.btnPokemon),--神将合成、置换
[FUNCTION_OPEN_TYPE.tianshumijuan] = this:InsertNewText(this.btnTianShuMiJuan),
}
-- 红点
this.rpShangdian = Util.GetGameObject(this.btnShangdian, "redPoint")
this.rpJingjichang = Util.GetGameObject(this.btnJingjichang, "redPoint")
this.rpExpedition = Util.GetGameObject(this.btnExpedition, "redPoint")
this.rpRecruit = Util.GetGameObject(this.btnRecruit, "redPoint")
this.rpElementDrawCard = Util.GetGameObject(this.btnElementDrawCard, "redPoint")
this.rpSecretBox = Util.GetGameObject(this.btnSecretBox, "redPoint")
this.rpYiYao = Util.GetGameObject(this.btnYiYao, "redPoint")
this.rpAlien = Util.GetGameObject(this.btnWaiDi, "redPoint")
this.rpColorfulWorld = Util.GetGameObject(this.btnColorfulWorld, "redPoint")
this.rpCompoundHero = Util.GetGameObject(this.btnCompoundHero, "redPoint")--神将合成、置换
this.rpPokemon = Util.GetGameObject(this.btnPokemon, "redPoint")--灵兽
this.rpbtnTianShuMiJuan = Util.GetGameObject(this.btnTianShuMiJuan, "redPoint")--灵兽
if not this.playerInfoView then
this.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, this.transform)
this.playerInfoView:SetPrivilegeShow(true)
end
this.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
this.ChatTipView = SubUIManager.Open(SubUIConfig.ChatTipView, self.transform, 1)
----==================== npc按钮 ========================
-- 云游商人
this.yunyou = Util.GetGameObject(this.npcRoot, "npcYunyou")
this.btnYunyou = Util.GetGameObject(this.yunyou, "button")
this.timeYunyou = Util.GetGameObject(this.btnYunyou, "time"):GetComponent("Text")
this.rpYunyou = Util.GetGameObject(this.btnYunyou, "redPoint")
poolManager:LoadLive("live2d_r_MapEffect_NewEvent_014", Util.GetTransform(this.yunyou, "liveRoot"), Vector3.one, Vector3.zero)
-- 精英怪
this.jingying = Util.GetGameObject(this.npcRoot, "npcJingying")
this.btnJingying = Util.GetGameObject(this.jingying, "button")
this.eliteMonsterTimeText = Util.GetGameObject(this.btnJingying, "time"):GetComponent("Text")
this.rpJingying = Util.GetGameObject(this.btnJingying, "redPoint")
poolManager:LoadLive("live2d_r_Map_NewEvent_015", Util.GetTransform(this.jingying, "liveRoot"), Vector3.one, Vector3.zero)
-- 外敌
this.alienNPC = Util.GetGameObject(this.npcRoot, "npcAlien")
this.btnAlienNPC = Util.GetGameObject(this.alienNPC, "button")
this.timeAlienNPC = Util.GetGameObject(this.alienNPC, "time"):GetComponent("Text")
this.rpAlienNPC = Util.GetGameObject(this.alienNPC, "redPoint")
moveTranList = {}
for i = 1, #moveSceneList do
table.insert(moveTranList, Util.GetGameObject(self.gameObject, "scene/layer" .. i):GetComponent("RectTransform"))
end
this.btnClickMove = Util.GetGameObject(this.bg, "btnClickMove")
this.btnFunHide[FUNCTION_OPEN_TYPE.DAILY_TASK] = this.btnDailyMission
this.btnFunHide[FUNCTION_OPEN_TYPE.PRAY] = this.paryGift
this.btnFunHide[FUNCTION_OPEN_TYPE.EMAIL] = this.btnYouJian
this.btnFunHide[FUNCTION_OPEN_TYPE.GOODFRIEND] = this.btnFriend
this.btnFunHide[FUNCTION_OPEN_TYPE.ALLRANKING] = this.btnRank
this.btnFunHide[FUNCTION_OPEN_TYPE.HongMengZhen] = this.btnHongMeng
this.btnFunHide[FUNCTION_OPEN_TYPE.POKEMON] = this.btnPokemon
this.btnFunHide[FUNCTION_OPEN_TYPE.tianshumijuan] = this.btnTianShuMiJuan
this.animRoot = Util.GetGameObject(self.gameObject, "scene")
--挑战关卡快速升级提示
this.battleUpLvTip = Util.GetGameObject(self.gameObject, "LeftDown/battleUpLvTip")
Util.GetGameObject(self.gameObject, "LeftDown/battleUpLvTip/Text"):GetComponent("Text").text = Language[10610]
this.activityTabPrefab = Util.GetGameObject(self.gameObject, "RightUp/activityTabPrefab")
this.RightUp = Util.GetGameObject(self.gameObject, "RightUp")
this.RightUp.transform.localScale = Vector3.one * UIManager.adapterScale
end
function this:SetPosFunc(v2)
self.bgTran.anchoredPosition = v2
for i = 1, #moveSceneList do
moveTranList[i].anchoredPosition = Vector2.New(v2.x * moveSceneList[i], v2.y)
end
local isShowLight = false
for i = 1, #lightList do
if v2.x >= lightList[i][1] and v2.x <= lightList[i][2] then
isShowLight = true
break
end
end
if self.lightEffectActive ~= isShowLight then
self.lightEffect:SetActive(isShowLight)
self.lightEffectActive = isShowLight
end
self.mountainTran.anchoredPosition = Vector2.New(v2.x * 1.2, v2.y)
end
--绑定事件(用于子类重写)
function this:BindEvent()
self.trigger = Util.GetEventTriggerListener(self.ctrl)
self.moveTween = self.bg:GetComponent(typeof(UITweenSpring))
if not self.moveTween then
self.moveTween = self.bg:AddComponent(typeof(UITweenSpring))
end
self.moveTween.enabled = false
local setPosFunc = function(v2)
local av2 = self.bgTran.anchoredPosition
local dv2 = Vector2.New(math.clamp(v2.x + av2.x, -1600, 150), av2.y)
if v2.x + av2.x < -1600 or v2.x + av2.x > 150 then
self.moveTween:Rebound(1, 0.1)
end
this:SetPosFunc(dv2)
end
self.moveTween.OnUpdate = setPosFunc
self.moveTween.MomentumAmount = 1
self.moveTween.Strength = 1
self.trigger.onBeginDrag = self.trigger.onBeginDrag + function(p, d)
self.moveTween.enabled = true
self.moveTween.Momentum = Vector3.zero
self.moveTween.IsUseCallBack = false
end
self.trigger.onDrag = self.trigger.onDrag + function(p, d)
self.moveTween:LerpMomentum(d.delta)
setPosFunc(d.delta)
end
self.trigger.onEndDrag = self.trigger.onEndDrag + function(p, d)
self.moveTween.IsUseCallBack = true
setPosFunc(d.delta)
end
local btnClickMoveTran = this.btnClickMove:GetComponent("RectTransform")
local rect = btnClickMoveTran.rect
math.randomseed(os.time())
-- for i = 1, 10 do
-- local view = MainPlayerView.New(false, this.btnClickMove, rect, Vector2.New(math.random(rect.xMin, rect.xMax), math.random(rect.yMin, rect.yMax)))
-- view.NameText.text = NameManager.GetLocalRandomName()
-- view:SetAutoMove()
-- end
curNPCList = {}
PlayerManager.GetMainPlayerNPCData(function(NPCList)
for i = 1, #NPCList do
local view = MainPlayerView.New(false, this.btnClickMove, rect, Vector2.New(math.random(rect.xMin, rect.xMax), math.random(rect.yMin, rect.yMax)),NPCList[i])
view.NameText.text = NPCList[i].userName or NPCList[i].name
view:SetAutoMove()
view.leader.transform.name = "MainPlayerView"..i
table.insert(curNPCList,view)
end
end)
--实例化自己
this:OnChangeTitleOrRideOrSkin(rect)
--八日登陆礼预览
Util.AddClick(this.sgBtn,function()
--UIManager.OpenPanel(UIName.PassGiftPopup,true)ActivityTypeDef.SevenDayRegister
--JumpManager.GoJump(15001)
UIManager.OpenPanel(UIName.EightDayGiftPanel)
end)
--十五日登录奖励
Util.AddClick(this.fgBtn,function()
UIManager.OpenPanel(UIName.FifteenDayGiftPanel)
end)
--日常任务
Util.AddClick(this.btnDailyMission, function()
UIManager.OpenPanel(UIName.MissionDailyPanel)
end)
--邮件
Util.AddClick(this.btnYouJian, function()
UIManager.OpenPanel(UIName.MailMainPanel)
end)
-- 精英怪
Util.AddClick(this.btnJingying, function()
if not EliteMonsterManager.HasEliteMonster() then
PopupTipPanel.ShowTip(Language[10529])
return
end
UIManager.OpenPanel(UIName.EliteMonsterPanel, 1)
end)
Util.AddClick(this.paryGift, function()
UIManager.OpenPanel(UIName.PrayMainPanel)
end)
--群英招募
Util.AddClick(this.btnRecruit, function()
--UIManager.OpenPanel(UIName.RecruitPanel)
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.RECURITY, function ()
UIManager.OpenPanel(UIName.RecruitPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.RECURITY)
end)
--元素招募
Util.AddClick(this.btnElementDrawCard, function()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.ELEMENT_RECURITY, function ()
UIManager.OpenPanel(UIName.ElementDrawCardPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.ELEMENT_RECURITY)
end)
--秘盒
Util.AddClick(this.btnSecretBox, function()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.SECRETBOX, function ()
UIManager.OpenPanel(UIName.SecretBoxPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.SECRETBOX)
end)
-- 给他一个点击事件吧,不然说个不停
Util.AddClick(this.btnYunyou, function()
UIManager.OpenPanel(UIName.MainShopPanel, SHOP_TYPE.ROAM_SHOP)
end)
-- 打开怪兽来袭界面t
Util.AddClick(this.btnMonster, function()
JumpManager.GoJump(1011)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.MONSTER_COMING)
end)
Util.AddClick(this.btnJingjichang, function()
-- JumpManager.GoJump(8001)
if (ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ARENA)) then
UIManager.OpenPanel(UIName.ArenaTypePanel)
else
local tip = ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.ARENA)
PopupTipPanel.ShowTip(tip)
end
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.ARENA)
end)
Util.AddClick(this.btnColorfulWorld, function()
if ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.ENDLESS) then
PlayerManager.carbonType = 2
UIManager.OpenPanel(UIName.CarbonTypePanelV2)
else
local config = ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,FUNCTION_OPEN_TYPE.ENDLESS)
PopupTipPanel.ShowTip(string.format(Language[10279],config.OpenRules[2]))
end
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.ENDLESS)
end)
Util.AddClick(this.btnFenjie, function()
JumpManager.GoJump(24001)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.HERO_RESOLVE)
end)
Util.AddClick(this.btnShangdian, function()
JumpManager.GoJump(20003)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.SHOP)
end)
Util.AddClick(this.btnEquipCompound, function()
--JumpManager.GoJump(20003)
--this.ScenceBtnClick(FUNCTION_OPEN_TYPE.SHOP)
if ActTimeCtrlManager.IsQualifiled(66) then
UIManager.OpenPanel(UIName.CompoundPanel)
end
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.COMPOUND)
end)
Util.AddClick(this.btnRank, function()
if (ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ALLRANKING)) then
local types = {}
local activiteIds = {}
for i = 1, #rankKingList do
if rankKingList[i].isRankingMainPanelShow then
table.insert(types,rankKingList[i].rankType)
table.insert(activiteIds,rankKingList[i].activiteId)
end
end
NetManager.RankFirstRequest(types,activiteIds,function (msg)
UIManager.OpenPanel(UIName.RankingListMainPanel,msg)
end)
else
local tip = ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.ALLRANKING)
PopupTipPanel.ShowTip(tip)
end
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.ALLRANKING)
end)
-- 好友
Util.AddClick(this.btnFriend, function()
UIManager.OpenPanel(UIName.GoodFriendMainPanel)
end)
-- 外敌(NPC按钮)
Util.AddClick(this.btnAlienNPC, function()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.FIGHT_ALIEN, function ()
-- 外敌展示界面
local list = AdventureManager.GetAdventureEnemyList()
if not list or #list <= 0 or GetTimeStamp() > list[1].levelTime then
PopupTipPanel.ShowTip(Language[10701])
return
end
UIManager.OpenPanel(UIName.MonsterShowPanel, list[1].bossGroupId, function()
UIManager.OpenPanel(UIName.FormationPanel, FORMATION_TYPE.ADVENTURE_BOSS, list[1])
end, function()end, true, 4)
end)
end)
-- 场景中的外敌
Util.AddClick(this.btnWaiDi, function ()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.FIGHT_ALIEN, function ()
UIManager.OpenPanel(UIName.AlienMainPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.FIGHT_ALIEN)
end)
-- 异妖
Util.AddClick(this.btnYiYao, function ()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.DIFFER_DEMONS, function ()
UIManager.OpenPanel(UIName.DiffMonsterPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.DIFFER_DEMONS)
end)
Util.AddClick(this.btnPokemon, function ()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.POKEMON, function ()
UIManager.OpenPanel(UIName.PokemonMainPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.POKEMON)
end)
--神将合成、神将置换
Util.AddClick(this.btnCompoundHero, function()
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.COMPOUND_HERO) then
JumpManager.GoJump(750001)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.COMPOUND_HERO)
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.COMPOUND_HERO))
end
end)
Util.AddClick(this.btnHongMeng,function()
NetManager.HongMengInfoResponse(function ()
-- body
print(Language[12211]..HarmonyManager:HongMengTowerUpLimit())
if HarmonyManager:HongMengTowerUpLimit() > 0 then
-- body
UIManager.OpenPanel(UIName.HongMengEnvoyPanel)
else
UIManager.OpenPanel(UIName.HongMengPanel)
end
end)
end)
Util.AddClick(this.btnTianShuMiJuan,function()
UIManager.OpenPanel(UIName.TianShuMiJuan,1)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.tianshumijuan)
end)
this.BindRedPoint()
end
--点击时检测功能
function this.FunctionClickEvent(funcId, callback)
if not funcId or funcId == 0 or not callback then return end
local isOpen = ActTimeCtrlManager.SingleFuncState(funcId)
if isOpen then
if callback then callback() end
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(funcId))
end
end
-- 所有按钮的额外点击事件
function this.ScenceBtnClick(funcId)
if ActTimeCtrlManager.IsQualifiled(funcId) then
if funcId == FUNCTION_OPEN_TYPE.GUILD then
this.operateNewText[FUNCTION_OPEN_TYPE.GUILD]:SetActive(false)
this.BtView:CheckMainCityNew()
end
end
FunctionOpenMananger.CleadNewText(funcId)
end
-- 设置图标动画
function this.SetAnim()
local isOpen = FunctionOpenMananger.GetRootState(PanelTypeView.MainCity)
if isOpen then
PlayUIAnim(this.animRoot)
else
PlayUIAnimBack(this.animRoot)
end
end
-- 绑定红点
function this.BindRedPoint()
BindRedPointObject(RedPointType.Mail, this.mailRedPoint)
BindRedPointObject(RedPointType.DailyTaskMain, this.DailyRedPoint)
BindRedPointObject(RedPointType.Shop, this.rpShangdian)
BindRedPointObject(RedPointType.Shop_Roam_Check, this.rpYunyou)
BindRedPointObject(RedPointType.Arena, this.rpJingjichang)
BindRedPointObject(RedPointType.Friend, this.friendRed)
BindRedPointObject(RedPointType.RankingSort, this.rankRed)
BindRedPointObject(RedPointType.Recruit, this.rpRecruit)
BindRedPointObject(RedPointType.SecretBox, this.rpSecretBox)
BindRedPointObject(RedPointType.Alien, this.rpAlien)
BindRedPointObject(RedPointType.DiffMonster, this.rpYiYao)
BindRedPointObject(RedPointType.Vientiane, this.rpColorfulWorld)
BindRedPointObject(RedPointType.PokemonMainCity, this.rpPokemon)
BindRedPointObject(RedPointType.HongMeng,this.HongMengRedPoint)
BindRedPointObject(RedPointType.TianShuMiJuan,this.rpbtnTianShuMiJuan)
end
-- 绑定红点
function this.ClearRedPoint()
ClearRedPointObject(RedPointType.Mail, this.mailRedPoint)
ClearRedPointObject(RedPointType.DailyTaskMain, this.DailyRedPoint)
ClearRedPointObject(RedPointType.Shop, this.rpShangdian)
ClearRedPointObject(RedPointType.Shop_Roam_Check, this.rpYunyou)
ClearRedPointObject(RedPointType.Arena, this.rpJingjichang)
ClearRedPointObject(RedPointType.Friend, this.friendRed)
ClearRedPointObject(RedPointType.RankingSort, this.rankRed)
ClearRedPointObject(RedPointType.Recruit, this.rpRecruit)
ClearRedPointObject(RedPointType.SecretBox, this.rpSecretBox)
ClearRedPointObject(RedPointType.Alien, this.rpAlien)
ClearRedPointObject(RedPointType.DiffMonster, this.rpYiYao)
ClearRedPointObject(RedPointType.Vientiane, this.rpColorfulWorld)
ClearRedPointObject(RedPointType.PokemonMainCity, this.rpPokemon)
ClearRedPointObject(RedPointType.TianShuMiJuan,this.rpbtnTianShuMiJuan)
end
--添加事件监听(用于子类重写)
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Player.OnChangeName, this.RefreshChangeName)
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.InitFuncShow)
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.InitFuncShow)
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose, this.RefreshActivityBtn)
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnPatFaceRedRefresh, this.RefreshShowPatPaceActivity)
Game.GlobalEvent:AddEvent(GameEvent.Adventure.OnEnemyListChanged, this.OnAlienListChanged)
Game.GlobalEvent:AddEvent(GameEvent.EightDay.GetRewardSuccess, this.RefreshEightGiftPreview)
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshEightGiftPreview)
Game.GlobalEvent:AddEvent(GameEvent.FindFairy.RefreshBuyOpenState, this.RefreshGiftBtnShow)
Game.GlobalEvent:AddEvent(GameEvent.Player.OnShowBattleUpLvTip, this.RefreshBattleUpLvTip)
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnChangeName, this.RefreshChangeName)
Game.GlobalEvent:RemoveEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.InitFuncShow)
Game.GlobalEvent:RemoveEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.InitFuncShow)
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose, this.RefreshActivityBtn)
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnPatFaceRedRefresh, this.RefreshShowPatPaceActivity)
Game.GlobalEvent:RemoveEvent(GameEvent.Adventure.OnEnemyListChanged, this.OnAlienListChanged)
Game.GlobalEvent:RemoveEvent(GameEvent.EightDay.GetRewardSuccess, this.RefreshEightGiftPreview)
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshEightGiftPreview)
Game.GlobalEvent:RemoveEvent(GameEvent.FindFairy.RefreshBuyOpenState, this.RefreshGiftBtnShow)
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnShowBattleUpLvTip, this.RefreshBattleUpLvTip)
end
function this:OnSortingOrderChange()
self.sceneTran.gameObject:GetComponent("Canvas").sortingOrder = self.sortingOrder - 4
Util.GetGameObject(self.sceneTran.gameObject, "layer7"):GetComponent("Canvas").sortingOrder = self.sortingOrder - 3
this.npcRoot:GetComponent("Canvas").sortingOrder = self.sortingOrder - 2
this.decorateRoot:GetComponent("Canvas").sortingOrder = self.sortingOrder - 1
Util.AddParticleSortLayer(this.btnClickMove, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.sceneTran.gameObject, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.mountainTran.gameObject, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(Util.GetGameObject(this.decorateRoot, "effect"), self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.sgEffect[1], self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.sgEffect[2], self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
this.BtView:SetOrderStatus({ sortOrder = self.sortingOrder })
if this.playerInfoView then
this.playerInfoView:SetLayer(self.sortingOrder)
end
end
function this:OnOpen()
activitys = DynamicActivityManager.GetActivityTableDataByPageInde(0)
this.CreatActivity()
end
function this.CreatActivity()
for k,v in ipairs(activitys) do
if not activityTabs[k] then
activityTabs[k] = {}
activityTabs[k].go = newObjToParent(this.activityTabPrefab,this.RightUp)
activityTabs[k].go.gameObject.name = "tab"..v.Id
activityTabs[k].img = Util.GetGameObject(activityTabs[k].go, "icon"):GetComponent("Image")
activityTabs[k].timeImg = Util.GetGameObject(activityTabs[k].go, "Image_1")
activityTabs[k].timeText = Util.GetGameObject(activityTabs[k].timeImg, "time"):GetComponent("Text")
activityTabs[k].redpot = Util.GetGameObject(activityTabs[k].go, "redPoint")
end
activityTabs[k].go.gameObject:SetActive(false)
if v.ShowTime == 0 then
activityTabs[k].timeImg.gameObject:SetActive(false)
else
activityTabs[k].timeImg.gameObject:SetActive(true)
end
if v.RpType > 0 then
--绑定新的红点
BindRedPointObject(v.RpType,activityTabs[k].redpot)
end
if v.ActiveType > 0 then
local activityId = ActivityGiftManager.IsActivityTypeOpen(v.ActiveType)
if activityId and activityId > 0 and ActivityGiftManager.IsQualifiled(v.ActiveType) and v.ActiveType ~= 42 then
local tempConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.ActivityGroups,"ActId",activityId,"PageType",0)
if tempConfig then
activityTabs[k].img.sprite = Util.LoadSprite(tempConfig.Icon[1])
else
activityTabs[k].img.sprite = Util.LoadSprite(v.Icon[1])
end
else
activityTabs[k].img.sprite = Util.LoadSprite(v.Icon[1])
end
else
activityTabs[k].img.sprite = Util.LoadSprite(v.Icon[1])
end
--开发用
-- LogGreen("v.ActiveType:"..v.ActiveType)
-- if v.ActiveType == 62 then
-- local activityId = ActivityGiftManager.IsActivityTypeOpen(v.ActiveType)
-- LogRed("activityId:"..tostring(activityId))
-- LogRed("IsQualifiled:"..tostring(ActivityGiftManager.IsQualifiled(v.ActiveType)))
-- local tempConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.ActivityGroups,"ActId",activityId,"PageType",0)
-- local imageName = ""
-- if activityId and activityId > 0 and tempConfig then
-- imageName = tempConfig.Icon[1]
-- else
-- imageName = v.Icon[1]
-- end
-- LogRed("imageName:"..tostring(imageName))
-- end
activityTabs[k].img:SetNativeSize()
Util.AddOnceClick(activityTabs[k].go,function()
if v.ActiveType > 0 then
this:TabBtnAction(v.ActiveType,1,v)
elseif v.FunType > 0 then
this:TabBtnAction(v.FunType,2,v)
else
this:TabBtnAction(v.ActId,0,v)
end
end)
end
end
function this:TabBtnAction(id,actType,data)
if actType == 1 then
if id == ActivityTypeDef.FirstRecharge then
UIManager.OpenPanel(UIName.FirstRechargePanel)
elseif id == ActivityTypeDef.SevenDayCarnival then
UIManager.OpenPanel(UIName.SevenDayCarnivalPanelV2,SevenDayCarnivalManager.GetPriorityDayNumber())
elseif id == ActivityTypeDef.WarPowerSort then
UIManager.OpenPanel(UIName.WarPowerSortPanel)
elseif id == ActivityTypeDef.DailyRecharge then
UIManager.OpenPanel(UIName.DailyRechargePanel)
elseif id == ActivityTypeDef.Pray then
UIManager.OpenPanel(UIName.PrayMainPanel)
elseif id == ActivityTypeDef.DemonSlayer then
UIManager.OpenPanel(UIName.DemonSlayerPanel)
elseif id == ActivityTypeDef.TreasureOfSomeBody then
UIManager.OpenPanel(UIName.MissionDailyPanel,2,1)
elseif id == ActivityTypeDef.TreasureStore then
UIManager.OpenPanel(UIName.TreasureStorePopup)
elseif id == ActivityTypeDef.DynamicAct then
local dynamicAct = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.DynamicAct)
local curindex = 1
if dynamicAct then
curindex = GlobalActConfig[dynamicAct].ShowArt
end
-- LogBlue("当前选中页签0"..curindex)
UIManager.OpenPanel(UIName.DynamicActivityPanel)
elseif id == ActivityTypeDef.SupremeHero then
UIManager.OpenPanel(UIName.SupremeHeroPopup)
elseif id == ActivityTypeDef.NiuZhuan then
UIManager.OpenPanel(UIName.NiuZhuanQianKunPanel)
elseif id == ActivityTypeDef.NiuQi then
UIManager.OpenPanel(UIName.NiuQiChongTianPanel)
elseif id == ActivityTypeDef.FuXingGaoZhao then
UIManager.OpenPanel(UIName.FuXingGaoZhaoPanel)
end
elseif actType == 2 then
if id == FUNCTION_OPEN_TYPE.SERVER_START_GIFT then
UIManager.OpenPanel(UIName.CourtesyDressPanel)
elseif id == 36 then
UIManager.OpenPanel(UIName.ActivityMainPanel,id)
elseif id == FUNCTION_OPEN_TYPE.EXPERT then
UIManager.OpenPanel(UIName.ExpertPanel)
elseif id == 40 then
UIManager.OpenPanel(UIName.ActivityMainPanel,id)
elseif id == FUNCTION_OPEN_TYPE.LUCKYTURN then
UIManager.OpenPanel(UIName.LuckyTurnTablePanel)
elseif id == FUNCTION_OPEN_TYPE.Achiecement then
UIManager.OpenPanel(UIName.AchievementPanel)
elseif id == 72 then
JumpManager.GoJump(75001)
elseif id == FUNCTION_OPEN_TYPE.ARENA then
UIManager.OpenPanel(UIName.ArenaTopMatchPanel)
end
else
if id == 666 then
UIManager.OpenPanel(UIName.UpGradePackagePanel)
elseif id == 668 then
UIManager.OpenPanel(UIName.ActivityMainPanel,id)
elseif id == 667 then
UIManager.OpenPanel(UIName.TimeLimitSkinPanel)
end
end
end
--界面打开时调用(用于子类重写)
function this:OnShow()
-- 音效
if isFirstOpen >= 2 then
-- PlaySoundWithoutClick(SoundConfig.Sound_interface)
end
isFirstOpen = isFirstOpen + 1
isRefeshIcon = true
timePressStarted = Time.realtimeSinceStartup
SoundManager.PlayMusic(SoundConfig.BGM_Main)
--刷新主城npc
this:OnChangeTitleOrRideOrSkin()
Log(string.format("---------------------%s", BagManager.GetItemCountById(14)))
this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
this.BtView:OnOpen({ sortOrder = self.sortingOrder, panelType = PanelTypeView.MainCity })
-- 刷新功能显示
this.InitFuncShow()
this.RefreshActivityShow()
this.RefreshFuncNewText()
this.RefreshGiftBtnShow()
-- 刷新一次编队战斗力
FormationManager.RefreshMainFormationPower()
-- 主界面time创建
endTime = ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.SupremeHero)
this.TimeFormat()
if not this._TimeCounter then
this._TimeCounter = Timer.New(this.TimeFormat, 1, -1, true)
this._TimeCounter:Start()
end
--
if (AdventureManager.drop ~= nil and AdventureManager.offlineTime ~= 0) then
if AdventureManager.isFirstEnterGetReward and #AdventureManager.drop.itemlist > 0 then
UIManager.OpenPanel(UIName.AdventureProgressPopup)
AdventureManager.isFirstEnterGetReward = false
end
end
-- 开始定时刷新聊天数据
this.ChatTipView:StartCheck()
-- 刷新拍脸
local patFaceAllData = PatFaceManager.GetPatFaceAllDataTabs()
if patFaceAllData and #patFaceAllData <= 0 and not UIManager.IsOpen(UIName.PatFacePanel) then
if FirstRechargeManager.IsShowFirstChatge() then
FirstRechargeManager.PlayerPrefsSetStrItemId(1)
--发送埋点数据
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.FirstRecharge,0)
UIManager.OpenPanel(UIName.FirstRechargePanel,nil,function()
AdventureManager.GetIsMaxTime()
end)
else
AdventureManager.GetIsMaxTime()
end
end
--主城调了两边 所以做特殊判断
if not UIManager.IsOpen(UIName.PatFacePanel) then
this.RefreshShowPatPaceActivity()
end
-- 设置主城小人名字
if self.playerView then
self.playerView:SetName()
end
-- 检测公会tip
GuildManager.CheckGuildTip()
CheckRedPointStatus(RedPointType.RankingSort)
if PlayerManager.IsGetFiveStarHero then --and OperatingManager.IsShowFiveStarPatch then
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.GrowGift, 5)
PlayerManager.IsGetFiveStarHero = false
end
PlayerManager.StarBattleUpLvTipTime(1)
this.battleUpLvTip:SetActive(false)
--检测灵兽红点
PokemonManager.CheckRedPointStatusPokemonMainCityRed()
--检测鸿蒙碑红点
HarmonyManager.CheckRedPoinStatusUpTowerMainCityRed()
FixedUpdateBeat:Add(this.OnUpdate, self)--长按方法注册
end
--
function this.OnUpdate()
--主城人物层级处理
this.OnMainPlayerNPCRefresh()
end
-- 刷新功能显示
function this.InitFuncShow(funcType)
-- 需要显示隐藏的功能检测
if funcType then
if this.btnFunHide[funcType] then
ActTimeCtrlManager.SetFuncLockState(this.btnFunHide[funcType], funcType, false)
return
end
else
for i, v in pairs(this.btnFunHide) do
ActTimeCtrlManager.SetFuncLockState(v, i, false)
end
end
--(百宝斋,点将台,锻器阁,化虚坛,竞技场,四元阵,灵兽山,送神祠,万象境)
if funcType then
if this.operateIcon[funcType] then
local isOpen = ActTimeCtrlManager.SingleFuncState(funcType)
if funcType == FUNCTION_OPEN_TYPE.ENDLESS then
isOpen = ActTimeCtrlManager.IsQualifiled(funcType)
end
Util.SetColor(this.operateIcon[funcType].lock, Color.New(1, 1, 1, 0.59))
this.operateIcon[funcType].lock:SetActive(not isOpen)
this.operateIcon[funcType].open:SetActive(isOpen)
return
end
else
for i, v in pairs(this.operateIcon) do
local isOpen = ActTimeCtrlManager.SingleFuncState(i)
if i == FUNCTION_OPEN_TYPE.ENDLESS then
isOpen = ActTimeCtrlManager.IsQualifiled(i)
end
v.lock:SetActive(not isOpen)
Util.SetColor(v.lock, Color.New(1, 1, 1, 0.59))
v.open:SetActive(isOpen)
end
end
-- 精英怪按钮显隐设置
this.jingying:SetActive(EliteMonsterManager.HasEliteMonster())
this.yunyou:SetActive(ShopManager.IsActive(SHOP_TYPE.ROAM_SHOP))
this.RefreshFuncNewText()
this.SetAnim()
end
function this.RefreshFuncNewText()
for i, v in pairs(this.operateNewText) do
--Log("当前ID是 === " .. i)
v:SetActive(FunctionOpenMananger.GetModuleOpen(i))
end
end
-- 时间格式化
function this.TimeFormat()
-- 如果逮到一个云游商人
local isRoamActive = ShopManager.IsActive(SHOP_TYPE.ROAM_SHOP)
this.yunyou:SetActive(isRoamActive)
if isRoamActive then
local closeTime = ShopManager.GetShopCloseTime(SHOP_TYPE.ROAM_SHOP)
if closeTime >= 0 then
this.timeYunyou.text = TimeToMS(closeTime)
end
end
-- 刷新精英怪
if this.jingying.activeSelf then
local leftTime = EliteMonsterManager.GetLeftTime()
this.eliteMonsterTimeText.text = TimeToMS(leftTime)
if leftTime <= 0 then
this.jingying:SetActive(false)
end
end
for k,v in pairs(activitys) do
local ishow = DynamicActivityManager.IsQualifiled(v.Id)
if ishow then
if v.ActId == 666 then
local giftList = {}
giftList = OperatingManager.GetInfoList()
if #giftList > 0 then
local time = giftList[1].endTime - GetTimeStamp()
if time < 1 then
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, giftList[1].goodsId)
activityTabs[k].go.gameObject:SetActive(false)
else
activityTabs[k].go.gameObject:SetActive(true)
activityTabs[k].timeText.text = TimeToHMS(time)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.ActId == 668 then
-- 加入对月卡的判断
local isMonthCardActive = OperatingManager.IsMonthCardActive()
local isOpen_128 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_128)
local isOpen_328 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_328)
activityTabs[k].go.gameObject:SetActive(isMonthCardActive and (isOpen_128 or isOpen_328))
if isMonthCardActive then
local cardType = nil
if isOpen_328 then
cardType = GoodsTypeDef.MONTHCARD_328
end
if not cardType and isOpen_128 then
cardType = GoodsTypeDef.MONTHCARD_128
end
if cardType then
local data = OperatingManager.GetGiftGoodsInfo(cardType)
if data then
local time = data.endTime - PlayerManager.serverTime
if time < 1 then
activityTabs[k].go.gameObject:SetActive(false)
else
activityTabs[k].go.gameObject:SetActive(true)
if time >= 86400 then
activityTabs[k].timeText.text = TimeToDH(time)
else
activityTabs[k].timeText.text = TimeToHMS(time)
end
end
end
end
end
elseif v.ActId == 667 then
local limitSkinGift = OperatingManager.GetTimeLimitSkinInfoList()
if not limitSkinGift then
activityTabs[k].go.gameObject:SetActive(false)
else
local time = limitSkinGift.endTime - GetTimeStamp()
if time > 0 then
activityTabs[k].go.gameObject:SetActive(true)
activityTabs[k].timeText.text = TimeToFelaxible(time)
local canGet = BagManager.GetTotalItemNum(1221) > 0 and BagManager.GetTotalItemNum(1222) > 0 and
BagManager.GetTotalItemNum(1223) > 0 and BagManager.GetTotalItemNum(1224) > 0
activityTabs[k].redpot:SetActive(canGet)
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
elseif v.ActId == 6301 then
local ActData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.FuXingGaoZhao)
if ActData then
activityTabs[k].timeText.transform.parent.gameObject:SetActive(ActData.value == 0)
activityTabs[k].go.gameObject:SetActive(ActData.value ~= 2)
if ActData.value == 0 then
local data = string.split(ConfigManager.GetConfigDataByKey(ConfigName.SpecialConfig,"Id",109).Value,"#")
local time = ActData.startTime + tonumber(data[1])*86400 - GetTimeStamp()
activityTabs[k].timeText.text = TimeToFelaxible(time)
if time <= 0 then
activityTabs[k].go.gameObject:SetActive(false)
end
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.ShowTime == 1 and activityTabs[k].go.gameObject.activeSelf then
if v.ActiveType > 0 then
local QingLong = ActivityGiftManager.IsActivityTypeOpen(v.ActiveType)
if QingLong and QingLong > 0 and ActivityGiftManager.IsQualifiled(v.ActiveType) then
if v.ActiveType == 42 then
if ActivityGiftManager.GetRewardState(42)~=3 then
local endTime = ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.SupremeHero)
if endTime - PlayerManager.serverTime > 0 then
local time = endTime - PlayerManager.serverTime
if time>= 86400 then
activityTabs[k].timeText.text = TimeToDH(time)
else
activityTabs[k].timeText.text = TimeToHMS(time)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(false)
supremHadSet = true
end
elseif v.FunType and v.FunType == 41 then
activityTabs[k].go.gameObject:SetActive(DailyRechargeManager.GetDailyRechargeExist())
else
local info = ActivityGiftManager.GetActivityTypeInfo(v.ActiveType)
local extraTime = 0
if ConfigManager.GetConfigDataByKey(ConfigName.GlobalActivity,"Type",v.ActiveType).GapTime and ConfigManager.GetConfigDataByKey(ConfigName.GlobalActivity,"Type",v.ActiveType).GapTime > 0 then
extraTime = ConfigManager.GetConfigDataByKey(ConfigName.GlobalActivity,"Type",v.ActiveType).GapTime*86400
end
local tempTime = info.endTime - GetTimeStamp() - extraTime
if tempTime > 86400 then
activityTabs[k].timeText.text = TimeToDH(tempTime)
elseif tempTime > 0 then
activityTabs[k].timeText.text = TimeToHMS(tempTime)
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.FunType == FUNCTION_OPEN_TYPE.ARENA then
local isOpen = ActTimeCtrlManager.SingleFuncState(v.FunType)
local baseInfo = ArenaTopMatchManager.GetBaseData()
if not isOpen or not baseInfo or not baseInfo.battleStage or baseInfo.battleStage == TOP_MATCH_STAGE.OVER then
activityTabs[k].go.gameObject:SetActive(false)
elseif baseInfo.battleStage == TOP_MATCH_STAGE.CLOSE then
local startTime = ArenaTopMatchManager.GetTopMatchTime()
local tempTime = startTime - PlayerManager.serverTime
-- 当日五点开始显示
if tempTime > 0 and tempTime < 16 * 60 * 60 then
activityTabs[k].go.gameObject:SetActive(true)
activityTabs[k].timeText.text = "距开始\n"..TimeToHMS(tempTime)
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(true)
activityTabs[k].timeText.text = "鏖战中"
end
elseif v.FunType == 72 then
local status = DeathPosManager.GetStatus()
local endTime = DeathPosManager.GetOverTime()
if not status or status == DeathPosStatus.Close or status == DeathPosStatus.Belated or status == DeathPosStatus.Reward then
activityTabs[k].go.gameObject:SetActive(false)
else
if endTime then
local tempTime = endTime - PlayerManager.serverTime
if tempTime and tempTime > 0 then
activityTabs[k].timeText.text = "距闯阵结束\n"..TimeToHMS(tempTime)
activityTabs[k].go.gameObject:SetActive(true)
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
end
end
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
PlayerManager.StopBattleUpLvTipTime()
this.ChatTipView:StopCheck()
PatFaceManager.isLogin = false
FixedUpdateBeat:Remove(this.OnUpdate, self)
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
for k,v in ipairs(activitys) do
if v.RpType > 0 then
ClearRedPointObject(v.RpType,activityTabs[k].redpot)
activityTabs[k].go.gameObject:SetActive(false)
end
end
activitys = {}
activityTabs = {}
SubUIManager.Close(this.UpView)
SubUIManager.Close(this.BtView)
SubUIManager.Close(this.ChatTipView)
SubUIManager.Close(this.playerInfoView)
this.playerInfoView = nil
-- 清楚红点
this.ClearRedPoint()
-- 计时器
if this._TimeCounter then
this._TimeCounter:Stop()
this._TimeCounter = nil
end
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
--更改姓名刷新
function this.RefreshChangeName()
if (NameManager.GetRoleName() ~= "") then
PlayerManager.nickName = NameManager.GetRoleName()
end
end
-- 刷新一些购买活动的按钮限时
function this.RefreshGiftBtnShow()
for k,v in pairs(activitys) do
local ishow = DynamicActivityManager.IsQualifiled(v.Id)
if v.ActId == 668 and ishow then
-- 加入对月卡的判断
local isMonthCardActive = OperatingManager.IsMonthCardActive()
local isOpen_128 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_128)
local isOpen_328 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_328)
activityTabs[k].go.gameObject:SetActive(isMonthCardActive and (isOpen_128 or isOpen_328))
end
end
end
--后台推送
function this.RefreshActivityBtn(context)
LogGreen("context.type1 " .. context.type .. " " .. context.status)
for k,v in ipairs(activitys) do
if v.ActiveType > 0 and v.ActiveType == context.type then
local activityId = ActivityGiftManager.IsActivityTypeOpen(v.ActiveType)
if activityId and activityId > 0 and ActivityGiftManager.IsQualifiled(v.ActiveType) then
if v.FunType and v.FunType == 41 then
activityTabs[k].go.gameObject:SetActive(DailyRechargeManager.GetDailyRechargeExist())
else
activityTabs[k].go.gameObject:SetActive(context.status == 1)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.FunType > 0 and v.FunType == context.type then
if ActTimeCtrlManager.SingleFuncState(v.FunType) then
if v.FunType and v.FunType == 41 then
activityTabs[k].go.gameObject:SetActive(DailyRechargeManager.GetDailyRechargeExist())
else
activityTabs[k].go.gameObject:SetActive(context.status == 1)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
end
isRefeshIcon = true
end
--客户端自己Show刷新
function this.RefreshActivityShow()
--八日登陆
this.RefreshEightGiftPreview()
for k,v in ipairs(activitys) do
local ishow = DynamicActivityManager.IsQualifiled(v.Id)
if ishow then
if v.ActiveType < 1 and v.FunType < 1 then
if v.ActId == 666 then
--限时折扣
local giftList = {}
giftList = OperatingManager.GetInfoList()
if #giftList > 0 then
local time = giftList[1].endTime - GetTimeStamp()
if time < 1 then
OperatingManager.RemoveItemInfoByType(GoodsTypeDef.DirectPurchaseGift, giftList[1].goodsId)
activityTabs[k].go.gameObject:SetActive(false)
else
activityTabs[k].go.gameObject:SetActive(true)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.ActId == 668 then
--超值基金
-- 加入对月卡的判断
local isMonthCardActive = OperatingManager.IsMonthCardActive()
local isOpen_128 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_128)
local isOpen_328 = OperatingManager.IsBaseOpen(GoodsTypeDef.MONTHCARD_328)
activityTabs[k].go.gameObject:SetActive(isMonthCardActive and (isOpen_128 or isOpen_328))
if isMonthCardActive then
local cardType = nil
if isOpen_328 then
cardType = GoodsTypeDef.MONTHCARD_328
end
if not cardType and isOpen_128 then
cardType = GoodsTypeDef.MONTHCARD_328
end
if cardType then
local data = OperatingManager.GetGiftGoodsInfo(cardType)
if data then
local time = data.endTime - PlayerManager.serverTime
if time < 1 then
activityTabs[k].go.gameObject:SetActive(false)
else
activityTabs[k].go.gameObject:SetActive(true)
end
end
end
end
end
elseif v.ActiveType > 0 then
local activityId = ActivityGiftManager.IsActivityTypeOpen(v.ActiveType)
if activityId and activityId > 0 and ActivityGiftManager.IsQualifiled(v.ActiveType) then
if v.ActiveType == 42 then
if ActivityGiftManager.GetRewardState(42) ~= 3 then
local endTime = ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.SupremeHero)
if endTime - PlayerManager.serverTime > 0 then
activityTabs[k].go.gameObject:SetActive(true)
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.FunType and v.FunType == 41 then
activityTabs[k].go.gameObject:SetActive(DailyRechargeManager.GetDailyRechargeExist())
else
activityTabs[k].go.gameObject:SetActive(true)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
elseif v.FunType > 0 then
if ActTimeCtrlManager.SingleFuncState(v.FunType) then
activityTabs[k].go.gameObject:SetActive(true)
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
else
activityTabs[k].go.gameObject:SetActive(false)
end
end
end
function this.RefreshShowPatPaceActivity()
local patFaceAllData = PatFaceManager.GetPatFaceAllDataTabs()
if patFaceAllData and not GuideManager.IsFunctionGuideExist() then
Log("#patFaceAllData " .. #patFaceAllData)
if #patFaceAllData > 0 then
this.patFaceCallList:Clear()
this.patFaceCallList:Push(function()
Log("结束了!!!")
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSendFinish)
AdventureManager.GetIsMaxTime()
end)
for i = #patFaceAllData, 1, -1 do
this.patFaceCallList:Push(function()
PatFaceManager.SetisFirstLogVal(1, { patFaceAllData[i] })
UIManager.OpenPanel(UIName.PatFacePanel, patFaceAllData[i], function()
local time2 = Timer.New(function()
this.patFaceCallList:Pop()()
end, 0.5)
time2:Start()
end)
end)
end
this.patFaceCallList:Pop()()
else
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSendFinish)
end
end
end
-- 外敌数据变化检测主界面npc显示状态
function this.OnAlienListChanged()
this.InitFuncShow(FUNCTION_OPEN_TYPE.FIGHT_ALIEN)
end
--八日登录奖励预览
function this.RefreshEightGiftPreview()
local state = false
local getRewardState = ActivityGiftManager.sevenDayGetRewardState
for i, v in pairs(getRewardState) do
if (v == 0) then
state = true
end
end
if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.EightDayGift) and state then
this.RefreshSevenGiftPreview()
this.sgBtn:SetActive(true)
else
this.sgBtn:SetActive(false)
end
end
-- 七日登陆奖励预览
function this.RefreshSevenGiftPreview()
--判断今日是否有可领取
local isHaveGift = ActivityGiftManager.CheckSevenDayRed()
local curDay = math.ceil((CalculateSecondsNowTo_N_OClock(0) + GetTimeStamp() - PlayerManager.userCreateTime)/86400)
local itemId=0
if isHaveGift then
local haveGiftList=nil
for j = 1, #ActivityGiftManager.sevenDayGetRewardState do
if ActivityGiftManager.sevenDayGetRewardState[j]==0 and j<=curDay then
if haveGiftList==nil then
haveGiftList=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ActivityRewardConfig,"ActivityId",56,"Sort",j)
end
end
end
itemId=haveGiftList.Reward[1][1]
local Gift = ConfigManager.GetConfigDataByKey(ConfigName.ItemConfig,"Id",itemId)
this.sgType.text=GetLanguageStrById(Gift.Name)
this.sgInfo.text=Language[11214]
this.sgEffect[1].gameObject:SetActive(false)
this.sgEffect[2].gameObject:SetActive(true)
else
if (ActivityGiftManager.canRewardDay+1)>=9 then
return
end
for i, v in pairs(ActivityGiftManager.sevenDayData) do
if v.Id==curDay+1 then
itemId= v.Reward[1][1]
local Gift = ConfigManager.GetConfigDataByKey(ConfigName.ItemConfig,"Id",itemId)
this.sgType.text=GetLanguageStrById(Gift.Name)
break
end
end
this.sgInfo.text=Language[11215]
this.sgEffect[1].gameObject:SetActive(true)
this.sgEffect[2].gameObject:SetActive(false)
end
this.sgItemView:OnOpen(false,{itemId,0},0.73)
this.sgName.text=ConfigManager.GetConfigData(ConfigName.ItemConfig,itemId).Name
end
function this.RefreshBattleUpLvTip()
this.battleUpLvTip:GetComponent("Canvas").sortingOrder = orginLayer + 10
this.battleUpLvTip:SetActive(true)
end
local roleRefreshNum = 0
function this.OnMainPlayerNPCRefresh()
if roleRefreshNum < 60 then
roleRefreshNum = roleRefreshNum + 1
elseif roleRefreshNum >= 60 and PlayerManager.MainPanelRoleMonveState then
roleRefreshNum = 0
-- LogRed("PlayerManager.MainPanelRoleMonveState "..tostring(PlayerManager.MainPanelRoleMonveState))
if curNPCList and #curNPCList > 0 then
table.sort(curNPCList,function(a,b)
return a.leader.transform.localPosition.y > b.leader.transform.localPosition.y
end)
for i = 1, #curNPCList do
if curNPCList[i] then
curNPCList[i].leader.transform:SetSiblingIndex(i)
end
end
PlayerManager.MainPanelRoleMonveState = false
end
end
end
function this:OnChangeTitleOrRideOrSkin()
local curisRefreshMainPanelNpc = PlayerManager.GetisRefreshMainPanelNpc()
-- LogBlue("sssssssssssssssssssssssssssssssssssss "..tostring(curisRefreshMainPanelNpc))
if not curisRefreshMainPanelNpc then return end
local btnClickMoveTran = this.btnClickMove:GetComponent("RectTransform")
local rect = btnClickMoveTran.rect
if self.playerView then
for key, value in pairs(curNPCList) do
if value == self.playerView then
-- LogBlue("移除旧的 self.playerView")
table.remove(curNPCList,key)
end
end
-- LogBlue(":OnClose() :OnClose()")
if self.playerView.NpcGO then
self.playerView.NpcGO:OnClose()
end
if self.playerView then
poolManager:UnLoadAsset("UI_MainPlayer",self.playerView.leader, PoolManager.AssetType.GameObject)
self.playerView = nil
end
end
self.playerView = MainPlayerView.New(true, this.btnClickMove, rect, Vector2.New(-1210, 0))
table.insert(curNPCList,self.playerView)
--角色点击行走
self.trigger.onPointerClick = self.trigger.onPointerClick + function(p, d)
local x, v2 = RectTransformUtility.ScreenPointToLocalPointInRectangle(btnClickMoveTran, Input.mousePosition, UIManager.camera, nil)
if not self.moveTween.enabled then
local b1 = v2.x < rect.xMax and v2.x > rect.xMin and v2.y < rect.yMax and v2.y > rect.yMin
if b1 then
self.playerView:SetRolePos(v2)
end
end
end
PlayerManager.SetisRefreshMainPanelNpc(false)
end
return MainPanel