2020-12-01 13:51:13 +08:00
|
|
|
local XinJiangLaiXi = quick_class("XinJiangLaiXi")
|
2020-12-02 09:51:17 +08:00
|
|
|
local this=XinJiangLaiXi
|
2020-12-01 15:52:34 +08:00
|
|
|
local allData={}
|
|
|
|
local itemsGrid = {}--item重复利用
|
2020-12-01 13:51:13 +08:00
|
|
|
local sortingOrder = 0
|
2020-12-01 15:52:34 +08:00
|
|
|
local parent = {}
|
2020-12-02 15:42:38 +08:00
|
|
|
|
2020-12-01 15:52:34 +08:00
|
|
|
this.LiveObj = nil
|
2020-12-01 13:51:13 +08:00
|
|
|
function XinJiangLaiXi:ctor(mainPanel, gameObject)
|
2020-12-02 09:51:17 +08:00
|
|
|
this.mainPanel = mainPanel.transform
|
|
|
|
this.gameObject = gameObject
|
|
|
|
this:InitComponent()
|
|
|
|
this:BindEvent()
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
|
2020-12-02 09:51:17 +08:00
|
|
|
function XinJiangLaiXi:InitComponent()
|
|
|
|
this.time = Util.GetGameObject(this.gameObject, "time/times"):GetComponent("Text")
|
|
|
|
this.money = Util.GetGameObject(this.gameObject, "money/times"):GetComponent("Text")
|
|
|
|
this.fightBtn = Util.GetGameObject(this.gameObject, "layout/fightBtn")
|
|
|
|
this.storeBtn = Util.GetGameObject(this.gameObject, "storeBtn")
|
|
|
|
this.helpBtn = Util.GetGameObject(this.gameObject, "helpBtn")
|
2020-12-02 15:42:38 +08:00
|
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
2020-12-02 09:51:17 +08:00
|
|
|
this.scrollItem = Util.GetGameObject(this.gameObject, "scroller/grid")
|
|
|
|
this.liveRoot = Util.GetGameObject(this.gameObject, "bg/liveRoot")
|
|
|
|
this.tip1 = Util.GetGameObject(this.gameObject, "layout/Text1"):GetComponent("Text")
|
|
|
|
this.tip2 = Util.GetGameObject(this.gameObject, "layout/Text2"):GetComponent("Text")
|
|
|
|
this.addBtn = Util.GetGameObject(this.gameObject, "layout/addBtn")
|
2020-12-01 15:52:34 +08:00
|
|
|
|
|
|
|
--shop
|
|
|
|
this.tabList = Util.GetGameObject(this.mainPanel,"bg/tabbox")
|
|
|
|
this.btnBack = Util.GetGameObject(this.mainPanel,"bg/btnBack")
|
|
|
|
this.bottomBar = Util.GetGameObject(this.mainPanel,"bg/bottomBar")
|
|
|
|
|
|
|
|
this.shop = Util.GetGameObject(this.gameObject,"shop")
|
|
|
|
this.shopBack = Util.GetGameObject(this.shop,"shopBack/btnBack")
|
|
|
|
this.content = Util.GetGameObject(this.shop,"content")
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
function XinJiangLaiXi:BindEvent()
|
2020-12-02 15:42:38 +08:00
|
|
|
Util.AddClick(this.helpBtn, function()
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.XinJiangLaiXi,this.helpPosition.x,this.helpPosition.y)
|
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddClick(this.addBtn, function()
|
2020-12-03 15:11:24 +08:00
|
|
|
--购买特权
|
2020-12-02 15:42:38 +08:00
|
|
|
if allData.buyTime > 0 then
|
|
|
|
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10036, 1)
|
|
|
|
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
|
|
|
|
MsgPanel.ShowTwo(string.format( Language[12332],finalNum,itemName), nil, function()
|
|
|
|
--买东西
|
|
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10036,1,function()
|
|
|
|
PopupTipPanel.ShowTip(Language[12328])
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(2013, 1)--更新特权
|
|
|
|
XinJiangLaiXi:Refresh()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
PopupTipPanel.ShowTip("今日已无购买次数~")
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddClick(this.fightBtn,function()
|
2020-12-03 15:11:24 +08:00
|
|
|
--开始战斗
|
2020-12-02 15:42:38 +08:00
|
|
|
if allData.fightTime > 0 then
|
2020-12-02 17:14:52 +08:00
|
|
|
NetManager.NewGeneralAttackRequest(allData.activityId,2012,function(msg)
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(2012, 1)--更新特权
|
|
|
|
local fightData = BattleManager.GetBattleServerData(msg,0)
|
|
|
|
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.XINJIANG,function ()
|
2020-12-03 15:11:24 +08:00
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1,function ()
|
|
|
|
this:Refresh()
|
|
|
|
end)
|
2020-12-02 17:14:52 +08:00
|
|
|
end)
|
|
|
|
end)
|
2020-12-02 15:42:38 +08:00
|
|
|
else
|
2020-12-03 15:11:24 +08:00
|
|
|
--购买特权
|
2020-12-02 15:42:38 +08:00
|
|
|
if allData.buyTime > 0 then
|
|
|
|
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10036, 1)
|
|
|
|
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
|
|
|
|
MsgPanel.ShowTwo(string.format( Language[12332],finalNum,itemName), nil, function()
|
|
|
|
--买东西
|
|
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10036,1,function()
|
|
|
|
PopupTipPanel.ShowTip(Language[12328])
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(2013, 1)--更新特权
|
|
|
|
XinJiangLaiXi:Refresh()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
PopupTipPanel.ShowTip("今日已无挑战次数~")
|
|
|
|
end
|
|
|
|
end
|
2020-12-01 15:52:34 +08:00
|
|
|
end)
|
|
|
|
|
2020-12-02 15:42:38 +08:00
|
|
|
Util.AddClick(this.storeBtn,function()
|
2020-12-01 15:52:34 +08:00
|
|
|
this.shop:SetActive(true)
|
|
|
|
this.btnBack:SetActive(false)
|
|
|
|
this.tabList:SetActive(false)
|
|
|
|
this.bottomBar:SetActive(false)
|
|
|
|
this:StoreShow()--商店
|
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddClick(this.shopBack,function()
|
|
|
|
this.shop:SetActive(false)
|
|
|
|
this.btnBack:SetActive(true)
|
|
|
|
this.tabList:SetActive(true)
|
|
|
|
this.bottomBar:SetActive(true)
|
2020-12-03 18:36:01 +08:00
|
|
|
parent.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
2020-12-01 15:52:34 +08:00
|
|
|
end)
|
|
|
|
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
function XinJiangLaiXi:AddListener()
|
|
|
|
end
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
function XinJiangLaiXi:RemoveListener()
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
function XinJiangLaiXi:OnOpen()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
function XinJiangLaiXi:OnShow(_sortingOrder,_parent)
|
2020-12-01 15:52:34 +08:00
|
|
|
parent = _parent
|
|
|
|
sortingOrder = _sortingOrder
|
2020-12-02 15:42:38 +08:00
|
|
|
XinJiangLaiXi:Refresh()
|
|
|
|
end
|
|
|
|
|
|
|
|
function XinJiangLaiXi:Refresh()
|
2020-12-01 15:52:34 +08:00
|
|
|
allData = DynamicActivityManager.XinJiangBuildData()
|
|
|
|
XinJiangLaiXi:OnShowData()
|
|
|
|
XinJiangLaiXi:SetTime()
|
|
|
|
end
|
2020-12-02 15:42:38 +08:00
|
|
|
|
2020-12-01 15:52:34 +08:00
|
|
|
function XinJiangLaiXi:OnShowData()
|
|
|
|
if not itemsGrid then
|
|
|
|
itemsGrid = {}
|
|
|
|
end
|
|
|
|
for k,v in ipairs(itemsGrid) do
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
end
|
2020-12-02 09:51:17 +08:00
|
|
|
|
|
|
|
for i = 1,#allData.reward do
|
|
|
|
if not itemsGrid[i] then
|
|
|
|
itemsGrid[i] = SubUIManager.Open(SubUIConfig.ItemView,this.scrollItem.transform)
|
2020-12-01 15:52:34 +08:00
|
|
|
end
|
2020-12-02 09:51:17 +08:00
|
|
|
itemsGrid[i].gameObject:SetActive(true)
|
|
|
|
itemsGrid[i]:OnOpen(false, allData.reward[i], 1,false,false,false,sortingOrder)
|
2020-12-01 15:52:34 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
if this.LiveObj then
|
|
|
|
poolManager:UnLoadLive(this.LiveObj.name,this.LiveObj)
|
|
|
|
this.LiveObj = nil
|
|
|
|
end
|
2020-12-02 09:51:17 +08:00
|
|
|
this.LiveObj = poolManager:LoadLive("live2d_c_dj_0008",this.liveRoot.transform, Vector3.one, Vector3.zero)
|
2020-12-01 15:52:34 +08:00
|
|
|
|
2020-12-02 09:51:17 +08:00
|
|
|
this.tip1.text = "剩余挑战次数:".."<color=#6BC74D>"..allData.fightTime.."</color>"
|
|
|
|
this.tip2.text = "剩余购买次数:".."<color=#6BC74D>"..allData.buyTime.."</color>"
|
|
|
|
this.money.text = allData.money
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
|
2020-12-01 15:52:34 +08:00
|
|
|
function XinJiangLaiXi:SetTime()
|
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
|
|
|
local timeDown = allData.endTime - GetTimeStamp()
|
2020-12-02 09:51:17 +08:00
|
|
|
this.time.text = Language[12321]..TimeToFelaxible(timeDown)
|
2020-12-01 15:52:34 +08:00
|
|
|
self.timer = Timer.New(function()
|
|
|
|
timeDown = timeDown - 1
|
|
|
|
if timeDown < 1 then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
parent:ClosePanel()
|
|
|
|
return
|
|
|
|
end
|
2020-12-02 09:51:17 +08:00
|
|
|
this.time.text = Language[12321]..TimeToFelaxible(timeDown)
|
2020-12-01 15:52:34 +08:00
|
|
|
end, 1, -1, true)
|
|
|
|
self.timer:Start()
|
|
|
|
end
|
2020-12-01 13:51:13 +08:00
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
function XinJiangLaiXi:OnOpen()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-12-01 15:52:34 +08:00
|
|
|
--商店
|
2020-12-02 09:51:17 +08:00
|
|
|
function XinJiangLaiXi:StoreShow()
|
2020-12-01 15:52:34 +08:00
|
|
|
if not this.shopView then
|
|
|
|
this.shopView = SubUIManager.Open(SubUIConfig.ShopView, this.content.transform)
|
|
|
|
end
|
2020-12-02 17:14:52 +08:00
|
|
|
this.shopView:ShowShop(SHOP_TYPE.XINJIANG_SHOP,sortingOrder)
|
2020-12-03 18:36:01 +08:00
|
|
|
parent.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.XinJiangLaiXi })
|
2020-12-01 15:52:34 +08:00
|
|
|
end
|
2020-12-01 13:51:13 +08:00
|
|
|
|
|
|
|
function XinJiangLaiXi:OnClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
function XinJiangLaiXi:OnDestroy()
|
2020-12-01 15:52:34 +08:00
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
2020-12-02 15:42:38 +08:00
|
|
|
if this.LiveObj then
|
|
|
|
poolManager:UnLoadLive(this.LiveObj.name,this.LiveObj)
|
|
|
|
this.LiveObj = nil
|
|
|
|
end
|
2020-12-01 15:52:34 +08:00
|
|
|
sortingOrder = 0
|
2020-12-02 15:42:38 +08:00
|
|
|
itemsGrid = {}
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function XinJiangLaiXi:OnHide()
|
2020-12-01 15:52:34 +08:00
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
|
|
|
sortingOrder = 0
|
2020-12-01 13:51:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return XinJiangLaiXi
|