2021-05-25 14:51:26 +08:00
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
MonsterCampSingleWave = {}
|
|
|
|
|
|
|
|
|
|
function MonsterCampSingleWave:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = MonsterCampSingleWave })
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function MonsterCampSingleWave:InitComponent(go,_data)
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.Id = Util.GetGameObject(go,"bg/leftLayout/num"):GetComponent("Text")
|
|
|
|
|
self.power = Util.GetGameObject(go,"bg/power/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
self.hero = Util.GetGameObject(go,"bg/Hero")
|
|
|
|
|
self.frame=Util.GetGameObject(self.hero,"Bg1"):GetComponent("Image")
|
|
|
|
|
self.icon=Util.GetGameObject(self.hero, "Mask/icon"):GetComponent("RawImage")
|
|
|
|
|
self.lv = Util.GetGameObject(self.hero, "lv/Text"):GetComponent("Text")
|
|
|
|
|
self.pro = Util.GetGameObject(self.hero, "Pro/Image"):GetComponent("Image")
|
|
|
|
|
self.fg = Util.GetGameObject(self.hero,"Bg2"):GetComponent("Image")
|
|
|
|
|
self.starGrid = Util.GetGameObject(self.hero,"StarGrid")
|
|
|
|
|
self.name=Util.GetGameObject(self.hero,"Name/Text"):GetComponent("Text")
|
2021-09-02 11:19:29 +08:00
|
|
|
|
self.effect = Util.GetGameObject(self.hero,"UI_Effect_jinkuang_KaPai")
|
2021-11-05 11:06:10 +08:00
|
|
|
|
self.pass = Util.GetGameObject(self.hero,"pass")
|
|
|
|
|
Util.GetGameObject(self.hero,"yuanImage"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(self.hero,"hpProgress"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(self.hero,"rageProgress"):SetActive(false)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.reward = Util.GetGameObject(go,"bg/rewardRect")
|
|
|
|
|
self.fight = Util.GetGameObject(go,"bg/fight")
|
|
|
|
|
self.rewardText = Util.GetGameObject(self.reward,"Text"):GetComponent("Text")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fightBtnIcon = Util.GetGameObject(self.fight,"layout/icon"):GetComponent("Image")
|
|
|
|
|
self.fightBtnNum = Util.GetGameObject(self.fight,"layout/num"):GetComponent("Text")
|
|
|
|
|
self.fightBtnText = Util.GetGameObject(self.fight,"layout/Text"):GetComponent("Text")
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.fightBtnMask = Util.GetGameObject(self.fight,"mask"):GetComponent("Image")
|
|
|
|
|
self.bg = Util.GetGameObject(go,"bg"):GetComponent("Image")
|
|
|
|
|
self.rewardGrid = Util.GetGameObject(self.reward,"grid")
|
2021-09-02 11:19:29 +08:00
|
|
|
|
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.btn=Util.GetGameObject(go,"bg/btn")
|
|
|
|
|
self.data = _data
|
|
|
|
|
self.rewardList = {}
|
|
|
|
|
for i = 1, self.rewardGrid.transform.childCount do
|
|
|
|
|
local temp = self:NewItemView(SubUIConfig.ItemView, self.rewardGrid.transform:GetChild(i-1).gameObject)
|
|
|
|
|
table.insert(self.rewardList,temp)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-09-02 11:19:29 +08:00
|
|
|
|
function MonsterCampSingleWave:OnOpen(_sortingOrder)
|
|
|
|
|
self:UpdatePrivilage()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.Id.text = "第"..self.data.Id.."层"
|
|
|
|
|
self.power.text = self.data.Force
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.bg.sprite = self.spLoader:LoadSprite("s_silingshilian_shiliandi")
|
2021-05-25 14:51:26 +08:00
|
|
|
|
local MonsterGroup = ConfigManager.GetConfigData(ConfigName.MonsterGroup,self.data.Monster)
|
|
|
|
|
local monsterConfig = ConfigManager.GetConfigData(ConfigName.MonsterConfig,MonsterGroup.Contents[1][1])
|
|
|
|
|
local herodata = ConfigManager.GetConfigData(ConfigName.HeroConfig,monsterConfig.MonsterId)
|
|
|
|
|
self:SingleHeroDataShow(monsterConfig,herodata)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self:SetIcon()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.rewardData = self.data.RewardShow
|
|
|
|
|
if self.rewardData and #self.rewardData then
|
|
|
|
|
self:InitShowReward()
|
|
|
|
|
self.reward.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
self.reward.gameObject:SetActive(false)
|
2021-09-02 11:19:29 +08:00
|
|
|
|
end
|
|
|
|
|
self.effect.gameObject:SetActive(false)--因为穿透,所以关闭了
|
|
|
|
|
Util.SetParticleSortLayer(self.effect.gameObject, _sortingOrder + 1)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
2021-09-03 18:56:46 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.MonsterXinMo,self.data.Id)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(self.fight, function()
|
|
|
|
|
LogGreen(self.data.Id)
|
|
|
|
|
local x = function()
|
2021-05-25 20:50:23 +08:00
|
|
|
|
NetManager.SweepDemonRequest(self.data.Id,false,function(msg)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.Drop,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BATTLENUM, 1)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.MonsterCamp.UpdatePri)
|
|
|
|
|
self:UpdatePrivilage()
|
2021-05-26 11:48:44 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end)
|
2021-09-02 11:19:29 +08:00
|
|
|
|
end)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
if self.data.Id == MonsterCampManager.monsterWave - 1 then--扫荡
|
|
|
|
|
LogGreen(self.freeTimes..self.buyTimes)
|
|
|
|
|
if self.freeTimes <=0 and self.buyTimes <= 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("今日已无扫荡次数!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
LogGreen(self.itemId.." "..self.costNum)
|
|
|
|
|
if self.freeTimes <= 0 then
|
|
|
|
|
if BagManager.GetItemCountById(self.itemId) < self.costNum then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[self.itemId].Name))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数?",self.costNum,itemConfig[self.itemId].Name),function() end,function()
|
2021-05-25 20:50:23 +08:00
|
|
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,self.storeDataId,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM, 1)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
x()
|
|
|
|
|
end)
|
|
|
|
|
end,"取消","确定")
|
|
|
|
|
else
|
|
|
|
|
x()
|
|
|
|
|
end
|
|
|
|
|
elseif self.data.Id == MonsterCampManager.monsterWave then--挑战
|
|
|
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.MONSTER_CAMP)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if self.data.Id == MonsterCampManager.monsterWave - 1 then
|
|
|
|
|
-- LogGreen(self.freeTimes..self.buyTimes)
|
|
|
|
|
-- if self.freeTimes <=0 and self.buyTimes <= 0 then
|
|
|
|
|
-- PopupTipPanel.ShowTip("今日已无扫荡次数!")
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
-- LogGreen(self.itemId.." "..self.costNum)
|
|
|
|
|
-- if self.freeTimes <= 0 then
|
|
|
|
|
-- if BagManager.GetItemCountById(self.itemId) < self.costNum then
|
|
|
|
|
-- PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[self.itemId].Name))
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
-- MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数?",self.costNum,itemConfig[self.itemId].Name),function() end,function()
|
|
|
|
|
-- ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,self.storeDataId,1,function()
|
|
|
|
|
-- PrivilegeManager.RefreshPrivilegeUsedTimes(self.trailData.buyTimeId, 1)
|
|
|
|
|
-- x()
|
|
|
|
|
-- end)
|
|
|
|
|
-- end,"取消","确定")
|
|
|
|
|
-- else
|
|
|
|
|
-- x()
|
|
|
|
|
-- end
|
|
|
|
|
-- elseif self.data.Id == self.trailData.monsterWave + 1 then
|
|
|
|
|
-- if self.trailData.canFightTime > 0 then
|
2021-09-02 17:29:44 +08:00
|
|
|
|
-- if LengthOfTable(FormationManager.GetWuJinFormationHeroIds(self.trailData.fourElementType + 3000)) > 0 then
|
2021-05-25 14:51:26 +08:00
|
|
|
|
-- MonsterCampManager.ExecuteFightBattle(self.data.Id,0,nil,self.trailData.fourElementType)
|
|
|
|
|
-- else
|
|
|
|
|
-- -- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.FOUR_ELEMENT, self.trailData.fourElementType,self.data.Id)
|
|
|
|
|
-- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.MONSTER_CAMP)
|
|
|
|
|
-- end
|
|
|
|
|
-- else
|
|
|
|
|
-- PopupTipPanel.ShowTip("今日已无可挑战层数!")
|
|
|
|
|
-- end
|
|
|
|
|
-- --UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.FourElementMonster,self.trailData.fourElementType,self.data.Id)
|
|
|
|
|
-- end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
-- 初始化奖励显示
|
|
|
|
|
function MonsterCampSingleWave:InitShowReward()
|
|
|
|
|
for i = 1 ,#self.rewardList do
|
|
|
|
|
self.rewardList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1,#self.rewardData do
|
|
|
|
|
if not self.rewardList[i] then
|
|
|
|
|
self.rewardList[i] = SubUIManager.Open(SubUIConfig.ItemView, self.rewardGrid.transform)
|
|
|
|
|
self.rewardList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-11-01 18:59:11 +08:00
|
|
|
|
self.rewardList[i]:OnOpen(false, {self.rewardData[i][1],self.rewardData[i][2]}, 0.8,false,false,false)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.rewardList[i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置每条英雄数据
|
|
|
|
|
function MonsterCampSingleWave:SingleHeroDataShow(monConfig,heroData)
|
2021-05-28 14:41:58 +08:00
|
|
|
|
self.frame.sprite=self.spLoader:LoadSprite(GetHeroCardStarBg[monConfig.Star])
|
2021-05-25 14:51:26 +08:00
|
|
|
|
local liveName = GetResourcePath(heroData.Live)
|
|
|
|
|
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroData.Id)
|
|
|
|
|
local scale = roleConfig.play_liveScale
|
|
|
|
|
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
2021-05-27 14:06:20 +08:00
|
|
|
|
self.icon.texture = CardRendererManager.GetSpineTexture((self.data.Id%6 == 0 and 12 or (self.data.Id%6) + 6), liveName, Vector3.one * scale, livePos, true)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
self.icon.transform.localScale = Vector3.one
|
|
|
|
|
self.icon.transform.localPosition = Vector3.zero
|
|
|
|
|
self.lv.text = monConfig.Level
|
|
|
|
|
self.pro.sprite= self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
|
|
|
SetCardStars(self.starGrid,monConfig.Star)
|
|
|
|
|
self.fg.sprite = self.spLoader:LoadSprite(GetHeroCardStarFg[monConfig.Star])
|
|
|
|
|
self.name.text = heroData.ReadingName
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function MonsterCampSingleWave:UpdatePrivilage()
|
|
|
|
|
self.storeDataId,self.itemId,self.costNum = MonsterCampManager.MonsterCampGetCost()
|
|
|
|
|
self.freeTimes = MonsterCampManager.GetCanBattleCount()
|
|
|
|
|
self.buyTimes = MonsterCampManager.GetCanBuyBattleCount()
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self:SetIcon()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-25 20:50:23 +08:00
|
|
|
|
function MonsterCampSingleWave:SetIcon()
|
|
|
|
|
Util.SetGray(self.fight,false)
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.hero.transform.localPosition = Vector3.New(0,-33,0)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fight.gameObject:SetActive(false)
|
2021-11-05 11:06:10 +08:00
|
|
|
|
self.pass.gameObject:SetActive(false)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fightBtnIcon.gameObject:SetActive(false)
|
|
|
|
|
self.fightBtnNum.gameObject:SetActive(false)
|
|
|
|
|
self.rewardText.text = "奖励"
|
|
|
|
|
if self.data.Id < MonsterCampManager.monsterWave - 1 then
|
2021-11-05 11:06:10 +08:00
|
|
|
|
self.pass.gameObject:SetActive(true)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
elseif self.data.Id == MonsterCampManager.monsterWave - 1 then--扫荡
|
|
|
|
|
self.fight.gameObject:SetActive(true)
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.hero.transform.localPosition = Vector3.New(0,3,0)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
if self.freeTimes > 0 then
|
|
|
|
|
self.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","免费扫荡")
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.fightBtnMask.sprite = self.spLoader:LoadSprite("r_guji_jihuianniu_02")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
else
|
2021-06-09 20:29:50 +08:00
|
|
|
|
self.fightBtnMask.sprite = self.spLoader:LoadSprite("r_guji_jihuianniu_02")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fightBtnIcon.gameObject:SetActive(true)
|
|
|
|
|
self.fightBtnNum.gameObject:SetActive(true)
|
|
|
|
|
local color = BagManager.GetItemCountById(self.itemId) < self.costNum and "E71515" or "17232A"
|
|
|
|
|
self.fightBtnNum.text =string.format("<color=#%s>%s</color>",color,self.costNum)
|
|
|
|
|
self.fightBtnText.text = string.format("<color=#%s>%s</color>",color,"扫荡")
|
2021-05-28 14:41:58 +08:00
|
|
|
|
self.fightBtnIcon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig[self.itemId].ResourceID))
|
2021-05-25 20:50:23 +08:00
|
|
|
|
if self.buyTimes < 1 then
|
|
|
|
|
Util.SetGray(self.fight,true)
|
2021-09-02 11:19:29 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-05-25 20:50:23 +08:00
|
|
|
|
elseif self.data.Id == MonsterCampManager.monsterWave then--挑战
|
|
|
|
|
self.fight.gameObject:SetActive(true)
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.hero.transform.localPosition = Vector3.New(0,3,0)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fightBtnIcon.gameObject:SetActive(false)
|
|
|
|
|
self.fightBtnNum.gameObject:SetActive(false)
|
2021-06-09 19:48:28 +08:00
|
|
|
|
self.fightBtnMask:GetComponent("Image").sprite = self.spLoader:LoadSprite("s_shouchong_anniu")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
self.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","挑战")
|
|
|
|
|
elseif self.data.Id > MonsterCampManager.monsterWave then
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-05-25 14:51:26 +08:00
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function MonsterCampSingleWave:OnDestroy()
|
|
|
|
|
self.rewardList = {}
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
function MonsterCampSingleWave:NewItemView(config, gameObject, ...)
|
|
|
|
|
local view = reimport(config.script)
|
|
|
|
|
local sub = view:New(gameObject)
|
|
|
|
|
sub.assetName = config.assetName
|
|
|
|
|
if sub.Awake then
|
|
|
|
|
sub:Awake()
|
|
|
|
|
end
|
|
|
|
|
if sub.InitComponent then
|
|
|
|
|
sub:InitComponent()
|
|
|
|
|
end
|
|
|
|
|
if sub.BindEvent then
|
|
|
|
|
sub:BindEvent()
|
|
|
|
|
end
|
|
|
|
|
if sub.AddListener then
|
|
|
|
|
sub:AddListener()
|
|
|
|
|
end
|
|
|
|
|
if sub.Update then
|
|
|
|
|
UpdateBeat:Add(sub.Update, sub)
|
|
|
|
|
end
|
|
|
|
|
if sub.OnOpen then
|
|
|
|
|
sub:OnOpen(...)
|
|
|
|
|
end
|
|
|
|
|
return sub
|
|
|
|
|
end
|
|
|
|
|
return MonsterCampSingleWave
|