146 lines
4.4 KiB
Lua
146 lines
4.4 KiB
Lua
|
local YiJingBaoKu = quick_class("YiJingBaoKu")
|
||
|
local this = YiJingBaoKu
|
||
|
local _itemsList = {}
|
||
|
local _itemsPosList={}
|
||
|
local sortingOrder = 0
|
||
|
local parent
|
||
|
|
||
|
function YiJingBaoKu:ctor(mainPanel, gameObject)
|
||
|
self.mainPanel = mainPanel
|
||
|
self.gameObject = gameObject
|
||
|
YiJingBaoKu:InitComponent(gameObject)
|
||
|
YiJingBaoKu:BindEvent()
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:InitComponent(gameObject)
|
||
|
-- top
|
||
|
this.name = Util.GetGameObject(gameObject, "top/name/Text"):GetComponent("Text")
|
||
|
this.itemFinal = Util.GetGameObject(gameObject, "top/reward/icon")
|
||
|
this.addBtn = Util.GetGameObject(gameObject, "top/reward/add")
|
||
|
this.refrashBtn = Util.GetGameObject(gameObject, "top/reward/refrash")
|
||
|
--leftUp
|
||
|
this.leftTime = Util.GetGameObject(gameObject, "leftUp/time"):GetComponent("Text")
|
||
|
--rightUp
|
||
|
this.helpBtn = Util.GetGameObject(gameObject, "rightUp/helpBtn")
|
||
|
this.rewardPre = Util.GetGameObject(gameObject, "rightUp/rewardPre")
|
||
|
--mid
|
||
|
this.grid = Util.GetGameObject(gameObject, "mid/content/grid")
|
||
|
for i = 1, this.grid.transform.childCount do
|
||
|
_itemsList[i] = this.grid.transform:GetChild(i - 1)
|
||
|
_itemsPosList[i] = _itemsList[i]:GetComponent("RectTransform").localPosition
|
||
|
end
|
||
|
end
|
||
|
|
||
|
--绑定事件(用于子类重写)
|
||
|
function YiJingBaoKu:BindEvent()
|
||
|
Util.AddClick(this.addBtn,function()
|
||
|
LogYellow("选择最终奖励")
|
||
|
end)
|
||
|
|
||
|
Util.AddClick(this.refrashBtn,function()
|
||
|
LogYellow("更换最终奖励")
|
||
|
YiJingBaoKu:FrontToBack()--测试用
|
||
|
end)
|
||
|
|
||
|
Util.AddClick(this.helpBtn,function()
|
||
|
LogYellow("帮助按钮")
|
||
|
end)
|
||
|
|
||
|
Util.AddClick(this.rewardPre,function()
|
||
|
LogYellow("奖励预览")
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
--添加事件监听(用于子类重写)
|
||
|
function YiJingBaoKu:AddListener()
|
||
|
|
||
|
end
|
||
|
|
||
|
--移除事件监听(用于子类重写)
|
||
|
function YiJingBaoKu:RemoveListener()
|
||
|
|
||
|
end
|
||
|
--界面打开时调用(用于子类重写)
|
||
|
function YiJingBaoKu:OnOpen()
|
||
|
|
||
|
end
|
||
|
|
||
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
|
function YiJingBaoKu:OnShow(_sortingOrder,_parent)
|
||
|
|
||
|
sortingOrder = _sortingOrder
|
||
|
parent = _parent
|
||
|
YiJingBaoKu:Refresh()
|
||
|
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:Refresh()
|
||
|
YiJingBaoKu:ResetCard()
|
||
|
YiJingBaoKu:AddBackToFrontClick()
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:AddBackToFrontClick()
|
||
|
for index, value in ipairs(_itemsList) do--单个的 背->正
|
||
|
local cFront = Util.GetGameObject(_itemsList[index], "front")
|
||
|
local cBack = Util.GetGameObject(_itemsList[index], "back")
|
||
|
Util.AddOnceClick(cBack,function()
|
||
|
local thread=coroutine.start(function()
|
||
|
cBack.transform:DORotate(Vector3.New(0, 90, 0), 0.3)
|
||
|
coroutine.wait(0.3)
|
||
|
cFront.transform:DORotate(Vector3.New(0, 0, 0), 0.3)
|
||
|
coroutine.wait(0.2)
|
||
|
--请求奖励
|
||
|
LogYellow("请求奖励!")
|
||
|
end)
|
||
|
end)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:FrontToBack()
|
||
|
local thread=coroutine.start(function()
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
local cFront = Util.GetGameObject(_itemsList[index], "front")
|
||
|
cFront.transform:DORotate(Vector3.New(0, 90, 0), 0.3)
|
||
|
end
|
||
|
coroutine.wait(0.3)
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
local cBack = Util.GetGameObject(_itemsList[index], "back")
|
||
|
cBack.transform:DORotate(Vector3.New(0, 0, 0), 0.3)
|
||
|
end
|
||
|
coroutine.wait(0.3)
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
_itemsList[index].transform:DOLocalMove(Vector3.New(0,0,0), 0.3)
|
||
|
end
|
||
|
coroutine.wait(0.3)
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
_itemsList[index].transform:DOLocalMove(Vector3.New(_itemsPosList[index].x,_itemsPosList[index].y,_itemsPosList[index].z), 0.3)
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:ResetCard()
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
local cFront = Util.GetGameObject(_itemsList[index], "front")
|
||
|
cFront:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0))
|
||
|
end
|
||
|
for index, value in ipairs(_itemsList) do
|
||
|
local cBack = Util.GetGameObject(_itemsList[index], "back")
|
||
|
cBack:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 90, 0))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:OnClose()
|
||
|
|
||
|
end
|
||
|
|
||
|
--界面销毁时调用(用于子类重写)
|
||
|
function YiJingBaoKu:OnDestroy()
|
||
|
|
||
|
end
|
||
|
|
||
|
function YiJingBaoKu:OnHide()
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
return YiJingBaoKu
|