161 lines
5.0 KiB
Lua
161 lines
5.0 KiB
Lua
local TableBG = import('Game.Data.TableBG')
|
||
local PKSettingView = import('.PKSettingView')
|
||
local PKCheckG = import('.PKCheckG')
|
||
local MainRightPanelView = import('Game.View.MainRightPanelView')
|
||
|
||
---
|
||
local M = {}
|
||
|
||
setmetatable(M, { __index = MainView })
|
||
|
||
local pk_default_bg = 1
|
||
local pk_bg_config = {
|
||
{ id = 1, url = 'base/main_poker/bg/bg3', thumb = 'ui://Main_Poker/bg3' },
|
||
{ id = 2, url = 'base/main_poker/bg/bg2', thumb = 'ui://Main_Poker/bg2' },
|
||
{ id = 3, url = 'base/main_poker/bg/bg1', thumb = 'ui://Main_Poker/bg1' }
|
||
}
|
||
|
||
-- settingViewType:1跑得快:显示换牌,隐藏返回和解散 2超级拼十:隐藏解散和换牌 3其他:隐藏换牌,根据是否观战显示解散和返回
|
||
-- ex_defaultbg 自定义默认背景编号
|
||
-- ex_bgconfig 自定义的背景
|
||
function M:InitView(url, isHideIpAdds, settingViewType, ex_defaultbg, ex_bgconfig, isHideJiesan, settingUrl)
|
||
UIPackage.AddPackage('base/main_poker/ui/Main_Poker')
|
||
MainView.InitView(self, url, isHideIpAdds)
|
||
|
||
local default_bg = ex_defaultbg or pk_default_bg
|
||
local bg_config = ex_bgconfig or pk_bg_config
|
||
-- 设置界面初始化方法
|
||
self.NewSettingView = function(self)
|
||
local settingView = PKSettingView.new(self, 0, isHideJiesan, settingUrl,
|
||
handler(self, self.UpdateCardSize))
|
||
return settingView
|
||
end
|
||
|
||
local _view = self._view
|
||
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
|
||
local rightpanel = self._view:GetChild('right_panel')
|
||
if rightpanel then
|
||
self._rightPanelView = MainRightPanelView.new(self, rightpanel)
|
||
end
|
||
self:InitXiPai()
|
||
self:InitXiPai1()
|
||
|
||
local checkG = self._view:GetChild('Btn_Check')
|
||
if checkG then
|
||
checkG.onClick:Set(function()
|
||
local checkG = PKCheckG.new()
|
||
checkG:Show()
|
||
end)
|
||
end
|
||
|
||
self.com_notice = self._view:GetChild("com_notice")
|
||
end
|
||
|
||
function M:InitXiPai()
|
||
self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke")
|
||
self._root_view:AddChild(self._xipaiPanel)
|
||
|
||
local offset = get_offset(self._full_offset)
|
||
|
||
self._xipaiPanel.width = GRoot.inst.width - (offset * 2)
|
||
self._xipaiPanel.height = GRoot.inst.height
|
||
self._xipaiPanel.x = offset
|
||
|
||
self._xipaiPanel.visible = false
|
||
self._handAnimCtr = self._xipaiPanel:GetController("anim")
|
||
self._handAnimCtr.selectedIndex = 0
|
||
--self:PlayXiPai()
|
||
end
|
||
|
||
function M:PlayXiPai(xipaiCallBack)
|
||
if self._xipaiPanel then
|
||
coroutine.start(function()
|
||
self._xipaiPanel.visible = true
|
||
self._xipaiPanel:GetTransition("XiPai"):Play()
|
||
self._handAnimCtr.selectedIndex = 1
|
||
coroutine.wait(3.5)
|
||
self._handAnimCtr.selectedIndex = 0
|
||
self._xipaiPanel.visible = false
|
||
if xipaiCallBack then
|
||
xipaiCallBack()
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
|
||
function M:InitXiPai1()
|
||
self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke02")
|
||
self._root_view:AddChild(self._xipaiPanel1)
|
||
|
||
local offset = get_offset(self._full_offset)
|
||
|
||
self._xipaiPanel1.width = GRoot.inst.width - (offset * 2)
|
||
self._xipaiPanel1.height = GRoot.inst.height
|
||
self._xipaiPanel1.x = offset
|
||
|
||
self._xipaiPanel1.visible = false
|
||
self._handAnimCtr1 = self._xipaiPanel1:GetController("anim")
|
||
self._handAnimCtr1.selectedIndex = 0
|
||
end
|
||
|
||
function M:PlayXiPai1(xipaiCallBack)
|
||
if self._xipaiPanel1 then
|
||
coroutine.start(function()
|
||
self._xipaiPanel1.visible = true
|
||
self._xipaiPanel1:GetTransition("XiPai"):Play()
|
||
self._handAnimCtr1.selectedIndex = 1
|
||
coroutine.wait(3.5)
|
||
self._handAnimCtr1.selectedIndex = 0
|
||
self._xipaiPanel1.visible = false
|
||
if xipaiCallBack then
|
||
xipaiCallBack()
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
|
||
function M:DoNoticeAnimation()
|
||
self.noticeIndex = self.noticeIndex or 1
|
||
if not DataManager.GameNotice or #DataManager.GameNotice == 0 then
|
||
return
|
||
end
|
||
|
||
local text_notice = self.com_notice:GetChild("text_notice")
|
||
text_notice.text = DataManager.GameNotice[self.noticeIndex]
|
||
local speed = 44
|
||
local time = text_notice.width / speed
|
||
|
||
text_notice.x = self.com_notice.width
|
||
|
||
local tween = text_notice:TweenMove(Vector2(-text_notice.width, text_notice.y), time):OnComplete(function()
|
||
self:DoNoticeAnimation()
|
||
end)
|
||
|
||
tween:SetEase(EaseType.Linear)
|
||
|
||
self.noticeIndex = self.noticeIndex + 1
|
||
if self.noticeIndex > #DataManager.GameNotice then
|
||
self.noticeIndex = 1
|
||
end
|
||
end
|
||
|
||
-- 设置界面的换牌回调,需要换牌的玩法settingViewType传1,重写这个方法
|
||
function M:UpdateCard(index)
|
||
end
|
||
|
||
function M:UpdateCardSize(index)
|
||
end
|
||
|
||
function M:Show()
|
||
getmetatable(M).__index.Show(self)
|
||
-- ViewUtil.PlaySound("RunFastNew_PK", "base/main_majiang/sound/game_backmusic.mp3")
|
||
self:DoNoticeAnimation()
|
||
end
|
||
|
||
function M:Destroy()
|
||
UIPackage.RemovePackage('base/main_poker/ui/Main_Poker')
|
||
MainView.Destroy(self)
|
||
end
|
||
|
||
return M
|