1631 lines
60 KiB
Lua
1631 lines
60 KiB
Lua
---
|
||
--- Created by 谌建军.
|
||
--- DateTime: 2017/12/18 9:41
|
||
---
|
||
local PKMainView = import("main.poker.PKMainView")
|
||
local EXPlayerPokerInfoView = import(".EXPlayerPokerInfoView")
|
||
local EXPlayerSelfPokerInfoView = import(".EXPlayerSelfPokerInfoView")
|
||
local EXGameEvent = import(".EXGameEvent")
|
||
local EXResultView = import(".EXResultView")
|
||
local EXRightPanelView = import(".EXRightPanelView")
|
||
local PlayerInfoView = import(".EXPlayerInfoView")
|
||
local TableBG = import('Game.Data.TableBG')
|
||
local EXCardCheck = import(".CardCheck")
|
||
local M = {}
|
||
function M.new()
|
||
setmetatable(M, { __index = PKMainView })
|
||
local self = setmetatable({}, { __index = M })
|
||
self.class = "EXMainView"
|
||
self:init()
|
||
self._gamectr = ControllerManager.GetController(GameController)
|
||
return self
|
||
end
|
||
|
||
local default_bg = 1
|
||
local bg_config = {
|
||
{ id = 1, url = 'extend/poker/duoduo/bg/bg1', thumb = 'ui://Extend_Poker_DuoDuo/table_bg1' },
|
||
{ id = 2, url = 'extend/poker/duoduo/bg/bg2', thumb = 'ui://Extend_Poker_DuoDuo/table_bg2' },
|
||
{ id = 3, url = 'extend/poker/duoduo/bg/bg3', thumb = 'ui://Extend_Poker_DuoDuo/table_bg3' }
|
||
}
|
||
|
||
function M:InitView(url)
|
||
local room = self._room
|
||
self._full = true
|
||
UIPackage.AddPackage("extend/poker/duoduo/ui/Extend_Poker_DuoDuo")
|
||
PKMainView.InitView(self, "ui://Extend_Poker_DuoDuo/EXMain_New_" .. room.room_config.people_num, nil, 1,
|
||
default_bg, bg_config, nil)
|
||
local _room = DataManager.CurrenRoom
|
||
local user_id = DataManager.SelfUser.account_id
|
||
local json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "pai")
|
||
if json_data == nil then
|
||
local _gamectr = self._gamectr
|
||
self._room.pai = 0
|
||
else
|
||
local _data = json.decode(json_data)
|
||
local pai = _data["pai"]
|
||
self._room.pai = pai
|
||
end
|
||
|
||
json_data = Utils.LoadLocalFile(user_id .. _room.game_id .. "cardsize")
|
||
if json_data == nil then
|
||
local _gamectr = self._gamectr
|
||
self._room.cardsize = 1
|
||
else
|
||
local _data = json.decode(json_data)
|
||
local cardsize = _data["cardsize"]
|
||
self._room.cardsize = cardsize
|
||
end
|
||
|
||
|
||
self._player_info = {}
|
||
local _player_info = self._player_info
|
||
for i = 1, self._room.room_config.people_num do
|
||
local tem = self._view:GetChild("player_info" .. i)
|
||
_player_info[i] = PlayerInfoView.new(tem, self)
|
||
tem.visible = false
|
||
end
|
||
local list = self._room.player_list
|
||
for i = 1, #list do
|
||
local p = list[i]
|
||
local info = _player_info[self:GetPos(p.seat)]
|
||
info._view.visible = true
|
||
info:FillData(p)
|
||
end
|
||
|
||
|
||
local rightpanel = self._view:GetChild("right_panel")
|
||
if self._rightPanelView ~= nil then
|
||
self._rightPanelView:Destroy()
|
||
end
|
||
|
||
self._rightPanelView = EXRightPanelView.new(self, rightpanel)
|
||
for i = 1, #self._room.player_list do
|
||
if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then
|
||
-- body
|
||
local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip")
|
||
local _action = self._view:AddChild(ErrorMsgTip)
|
||
_action.xy = Vector2((self._view.width - _action.width) / 4, self._view.height / 4)
|
||
local text = _action:GetChild("tex_message")
|
||
local btn1 = _action:GetChild("btn_connect")
|
||
local btn2 = _action:GetChild("btn_back")
|
||
text.text = "您来晚了,座位有人,请重新进牌桌"
|
||
btn1.visible = false
|
||
btn2:Center()
|
||
btn2.y = btn2.y + 50
|
||
btn2.onClick:Set(function()
|
||
-- body
|
||
ErrorMsgTip:Destroy()
|
||
ErrorMsgTip = nil
|
||
self._gamectr:LevelRoom(function(res)
|
||
ViewUtil.CloseModalWait2()
|
||
NetResetConnectWindow.CloseNetReset()
|
||
ControllerManager.ChangeController(LoddyController)
|
||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
||
end)
|
||
end)
|
||
end
|
||
end
|
||
|
||
-- if self._room.hpOnOff == 1 and self._room.score_times ~= 1 then
|
||
-- -- body
|
||
-- self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = self._room.score_times .. "倍"
|
||
-- else
|
||
-- self._view:GetChild("roominfo_panel1"):GetChild("tex_beishu").text = ""
|
||
-- end
|
||
|
||
self._view_click = self._view:GetChild('click')
|
||
if self._view_click then
|
||
self._view_click.onClick:Set(function()
|
||
self._gamectr:SendCheckCard()
|
||
end)
|
||
end
|
||
|
||
self.ctr_state = self._view:GetController("state")
|
||
self._ctr_action = self._view:GetController("action")
|
||
-- self._tex_leftTime = self._view:GetChild("time"):GetChild("title")
|
||
self.ctr_time = self._view:GetController("time")
|
||
self._text_round = self._view:GetChild("round")
|
||
self.ctr_card_eff = self._view:GetController("card_eff")
|
||
self._player_card_info = {}
|
||
|
||
local _player_card_info = self._player_card_info
|
||
for i = 1, room.room_config.people_num do
|
||
local tem = self._view:GetChild("player_card_info_" .. i)
|
||
_player_card_info[i] = self:NewPlayerCardInfoView(tem, i)
|
||
end
|
||
|
||
local list = room.player_list
|
||
if not room.self_player.ready then
|
||
local round = DataManager.CurrenRoom.room_config.config.times or 1
|
||
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
|
||
if xpconfig then
|
||
if round > 1 then
|
||
self._ctr_action.selectedIndex = 1
|
||
else
|
||
self._ctr_action.selectedIndex = 2
|
||
end
|
||
else
|
||
self._ctr_action.selectedIndex = 1
|
||
end
|
||
else
|
||
self._ctr_action.selectedIndex = 0
|
||
end
|
||
self._left_time = 0
|
||
self.bgm_index = 1
|
||
local state = self._room.CurnrenState
|
||
|
||
if room.CurnrenState ~= StateType.PalyingWait then
|
||
self._state.selectedIndex = state
|
||
if room.CurnrenState == StateType.Palying then
|
||
self:ReConnectForStart()
|
||
end
|
||
else
|
||
self._state.selectedIndex = StateType.Palying
|
||
self:ReconnectForClearing()
|
||
end
|
||
|
||
self._view:GetChild("btn_back_jiesan").onClick:Set(function()
|
||
if self.dismiss_room_cd_time > 0 then
|
||
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
|
||
else
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:AskDismissRoom()
|
||
end
|
||
end)
|
||
--local tempdsaf=self._view:GetChild("btn_back_jiesan")
|
||
--tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false)
|
||
--self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false)
|
||
|
||
self:ChangeBgmMusic()
|
||
self:EventInit()
|
||
|
||
self._view:GetChild("bg_mask").onClick:Set(function()
|
||
-- self:ResetPoker()
|
||
end)
|
||
|
||
--剩余弄在头像上,三人就会有两个剩余
|
||
-- if self._view:GetChild("shengyu") ~= nil then
|
||
-- -- body
|
||
|
||
-- if room.room_config.Leaf == 1 then
|
||
-- -- body
|
||
-- self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余15张"
|
||
-- else
|
||
-- self._view:GetChild("shengyu"):GetChild("shengyu").text = "剩余16张"
|
||
-- end
|
||
-- end
|
||
------------------lingmeng--------------------------
|
||
|
||
-- self._tex_leftTime = self._view:GetChild('Comp_Clock'):GetChild('time') -- 重写
|
||
self._text_currenRound = self._view:GetChild('Text_CurrenRound')
|
||
self._text_maxRound = self._view:GetChild('Text_MaxMaxRound')
|
||
|
||
self._cardCheck = EXCardCheck:InitFlag()
|
||
self._gamectr._cardCheck = self._cardCheck
|
||
self:UpdateRound(self._room.curren_round or 0)
|
||
|
||
self._view:GetChild('text_roomId').text = self._room.room_id
|
||
self._ctr_inClear = self._view:GetController('Inclear')
|
||
self._view:GetChild('btn_ready_inClear').onClick:Set(function()
|
||
if self.result_view and self.result_view._view then
|
||
self._ctr_inClear.selectedIndex = 0
|
||
self.result_view:ClearReady()
|
||
else
|
||
self.result_view = nil
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:ConformToNextGame()
|
||
self:ClearOk()
|
||
end
|
||
end)
|
||
----------------------------------------------------
|
||
--闹钟倒计时报时
|
||
self._leftTime_xiangling = 5
|
||
self._leftTime_bianhong = true
|
||
|
||
local btn_witness = self._view:GetChild('btn_pangGuang')
|
||
if btn_witness then
|
||
btn_witness.onClick:Set(function()
|
||
self._view:GetController('witness').selectedIndex = 1
|
||
end)
|
||
end
|
||
----------屏幕大小发生变化
|
||
GRoot.inst.onSizeChanged:Set(function()
|
||
for _, player in ipairs(self._room.player_list) do
|
||
local player_card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
|
||
if player.seat == self._room.self_player.seat then
|
||
player_card_info:InitPoker(player.hand_list, false)
|
||
else
|
||
end
|
||
end
|
||
end)
|
||
end
|
||
|
||
function M:UpdateCard(index)
|
||
self._room.pai = index
|
||
local card_info = self._player_card_info[1]
|
||
-- for i=1,#self._room.player_list do
|
||
-- -- print(i)
|
||
-- end
|
||
card_info:updatePoker()
|
||
for _, player in ipairs(self._room.player_list) do
|
||
local player_card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
|
||
if self._room.curren_turn_seat ~= player.seat then
|
||
if player.out_card_list[1] == 0 then
|
||
player_card_info:SetOutCardInfo(nil, true)
|
||
else
|
||
player_card_info:SetOutCardInfo(player.out_card_list, false)
|
||
end
|
||
end
|
||
end
|
||
if self.caozuo == 1 then
|
||
local ctr_number = self.pass == nil and 2 or 1
|
||
local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat)
|
||
local cardType, cardNum, cardLength = self._gamectr:GetCardListInfo(lastCardList)
|
||
local m = false
|
||
local next_seat = self._room.self_player.seat + 1
|
||
if next_seat > self._room.room_config.people_num then
|
||
next_seat = next_seat - self._room.room_config.people_num
|
||
end
|
||
if self._room:GetPlayerBySeat(next_seat).hand_count == 1 and self._room.room_config.WillBeOut == 1 then
|
||
m = true
|
||
end
|
||
local zdts = self._view:GetController("zidongtishi").selectedIndex
|
||
self._player_card_info[1]:ShowOutCardOption(ctr_number, cardType, cardNum, cardLength, m)
|
||
end
|
||
end
|
||
|
||
function M:UpdateCardSize(index)
|
||
self._room.cardsize = index
|
||
local card_info = self._player_card_info[1]
|
||
card_info:updatePoker()
|
||
end
|
||
|
||
function M:NewPlayerCardInfoView(tem, index)
|
||
if index == 1 then
|
||
return EXPlayerSelfPokerInfoView.new(tem, self)
|
||
end
|
||
return EXPlayerPokerInfoView.new(tem, self)
|
||
end
|
||
|
||
function M:OnPlayerEnter(...)
|
||
ViewUtil.PlaySound("DuoDuo_PK", "base/main_majiang/sound/user_enter.mp3")
|
||
MainView.OnPlayerEnter(self, ...)
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
local index = self:GetPos(p.seat)
|
||
local info = self._player_info[index]
|
||
local selecet_seat = self._view:GetChild("seat_" .. index)
|
||
if selecet_seat ~= nil then
|
||
selecet_seat.visible = true
|
||
end
|
||
info:FillData(p)
|
||
if self._room.banker_seat == self._room.self_player.seat and self._room.self_player.ready then
|
||
self._ctr_action.selectedIndex = 0
|
||
end
|
||
end
|
||
|
||
function M:OnPlayerReady(...)
|
||
ViewUtil.PlaySound("DuoDuo_PK", "base/main_majiang/sound/user_ready.mp3")
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
local _room = self._room
|
||
local _player_info = self._player_info
|
||
if p.seat == _room.self_player.seat then
|
||
self._ctr_action.selectedIndex = 0
|
||
end
|
||
local info = _player_info[self:GetPos(p.seat)]
|
||
info:Ready(true)
|
||
--local readyNum = 0
|
||
--for i = 1, #_room.player_list do
|
||
-- local player = _room.player_list[i]
|
||
-- if player.ready then readyNum = readyNum + 1 end
|
||
--end
|
||
--if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then
|
||
-- if self._state.selectedIndex == 2 then
|
||
-- local _gamectr = ControllerManager.GetController(GameController)
|
||
-- _gamectr:StartGame()
|
||
-- end
|
||
-- --self._ctr_action.selectedIndex = 2
|
||
--end
|
||
end
|
||
|
||
function M:OnPlayerLeave(...)
|
||
ViewUtil.PlaySound("DuoDuo_PK", "base/main_majiang/sound/user_leave.mp3")
|
||
MainView.OnPlayerLeave(self, ...)
|
||
local _room = self._room
|
||
if not _room.self_player.ready then
|
||
--self._ctr_action.selectedIndex = 1
|
||
local round = DataManager.CurrenRoom.room_config.config.times or 1
|
||
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
|
||
if xpconfig then
|
||
if round > 1 then
|
||
self._ctr_action.selectedIndex = 1
|
||
else
|
||
self._ctr_action.selectedIndex = 2
|
||
end
|
||
else
|
||
self._ctr_action.selectedIndex = 1
|
||
end
|
||
else
|
||
self._ctr_action.selectedIndex = 0
|
||
end
|
||
end
|
||
|
||
function M:EventInit()
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
MainView.EventInit(self)
|
||
local _player_info = self._player_info
|
||
local _player_card_info = self._player_card_info
|
||
local _room = self._room
|
||
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.EventXiPai, function(...)
|
||
if self.result_view ~= nil then
|
||
self.result_view:Destroy()
|
||
self.result_view = nil
|
||
end
|
||
|
||
self._player_card_info[1]:HidePiao()
|
||
|
||
if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then
|
||
-- body
|
||
self.MypokerList = cardlist
|
||
end
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list.visible = false
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
end
|
||
self.ctr_state.selectedIndex = 1
|
||
self.ctr_card_eff.selectedIndex = 0
|
||
if self.rank_view ~= nil then
|
||
self.rank_view:Dispose()
|
||
self.rank_view = nil
|
||
end
|
||
|
||
local list = _room.player_list
|
||
for i = 1, #list do
|
||
local p = list[i]
|
||
local head_info = self._player_info[self:GetPos(p.seat)]
|
||
if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then
|
||
-- body
|
||
|
||
if self._room.room_config.showlength == 1 then
|
||
-- body
|
||
head_info._view:GetController("shengyu").selectedIndex = 1
|
||
else
|
||
head_info._view:GetController("shengyu").selectedIndex = 0
|
||
end
|
||
|
||
-- body
|
||
head_info._view:GetChild("shengyu").text = p.hand_count
|
||
end
|
||
p:Clear()
|
||
head_info:FillData(p)
|
||
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
||
card_info:Clear()
|
||
head_info:Ready(false)
|
||
end
|
||
|
||
|
||
--[[if ( currentPlayer ) then
|
||
self._popEvent = false
|
||
local xipaiCB=function ()
|
||
self._popEvent = true
|
||
end
|
||
self:PlayXiPai(xipaiCB)
|
||
else
|
||
ViewUtil.ShowModalWait(self._root_view,"等待其它玩家洗牌...")
|
||
coroutine.start(function()
|
||
coroutine.wait(3)
|
||
ViewUtil.CloseModalWait2()
|
||
end)
|
||
|
||
|
||
end--]]
|
||
|
||
|
||
local arg = { ... }
|
||
local currentPlayer1 = arg[1]
|
||
local currentPlayer2 = arg[2]
|
||
self._popEvent = false
|
||
if (currentPlayer1) then
|
||
local xipaiCB = function()
|
||
self._popEvent = true
|
||
end
|
||
self:PlayXiPai(xipaiCB)
|
||
end
|
||
|
||
|
||
if (currentPlayer2) then
|
||
--self._popEvent = false
|
||
local xipaiCB2 = function()
|
||
self._popEvent = true
|
||
end
|
||
self:PlayXiPai1(xipaiCB2)
|
||
end
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnMingCard, function(...)
|
||
local arg = { ... }
|
||
local card = arg[1]
|
||
self.ctr_state.selectedIndex = 1
|
||
-- self.ctr_card_eff.selectedIndex = 1
|
||
-- if self._room.room_config.people_num == 3 then
|
||
-- self:PlayCardEff(403)
|
||
-- end
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnInitCard, function(...)
|
||
local arg = { ... }
|
||
local round = arg[1]
|
||
local cardlist = arg[2]
|
||
self._popEvent = false
|
||
|
||
if self.destory_win ~= nil then
|
||
coroutine.stop(self.destory_win)
|
||
end
|
||
if self.result_view ~= nil then
|
||
self.result_view:Destroy()
|
||
self.result_view = nil
|
||
end
|
||
|
||
self._player_card_info[1]:HidePiao()
|
||
|
||
if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then
|
||
-- body
|
||
self.MypokerList = cardlist
|
||
end
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list.visible = false
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
end
|
||
self.ctr_state.selectedIndex = 1
|
||
self.ctr_card_eff.selectedIndex = 0
|
||
if self.rank_view ~= nil then
|
||
self.rank_view:Dispose()
|
||
self.rank_view = nil
|
||
end
|
||
self._ctr_inClear.selectedIndex = 0
|
||
self:UpdateRound(round)
|
||
-- ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/fapai.mp3")
|
||
local list = _room.player_list
|
||
for i = 1, #list do
|
||
local p = list[i]
|
||
local head_info = self._player_info[self:GetPos(p.seat)]
|
||
if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then
|
||
-- body
|
||
|
||
if self._room.room_config.showlength == 1 then
|
||
-- body
|
||
head_info._view:GetController("shengyu").selectedIndex = 1
|
||
else
|
||
head_info._view:GetController("shengyu").selectedIndex = 0
|
||
end
|
||
|
||
-- body
|
||
head_info._view:GetChild("shengyu").text = p.hand_count
|
||
end
|
||
-- p:Clear()
|
||
head_info:MarkBank(p.seat == _room.banker_seat)
|
||
head_info:FillData(p)
|
||
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
||
card_info:Clear()
|
||
head_info:Ready(false)
|
||
|
||
|
||
if p.seat == self._room.self_player.seat then
|
||
if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then
|
||
-- body
|
||
card_info:InitPoker(cardlist, false, 1)
|
||
else
|
||
card_info:InitPoker(cardlist, false)
|
||
end
|
||
else
|
||
--card_info:UpdateHandPoker(#cardlist,true,false) --todo
|
||
--card_info:UpdateRemainCard(#cardlist,true)
|
||
end
|
||
end
|
||
|
||
if self._room.room_config.people_num == 3 and round == 1 then
|
||
local effect = self._view:GetTransition(string.format('to_%s', self:GetPos(self._room.banker_seat)))
|
||
effect:Play(1, 0, function()
|
||
self._popEvent = true
|
||
end)
|
||
else
|
||
self._popEvent = true
|
||
end
|
||
end)
|
||
|
||
|
||
-- _gamectr:AddEventListener(EXGameEvent.Oener,function ( ... )
|
||
-- local arg = {...}
|
||
-- local seat = arg[1]
|
||
-- local head_info = self._player_info[self:GetPos(seat)]
|
||
-- head_info._view:GetController("Oener").selectedIndex=1
|
||
-- end)
|
||
_gamectr:AddEventListener(EXGameEvent.OnIndexMove, function(...)
|
||
local arg = { ... }
|
||
local seat = arg[1]
|
||
local isNewBout = arg[2]
|
||
local index = self:GetPos(seat)
|
||
|
||
|
||
self.ctr_time.selectedIndex = index
|
||
-- for i = 1, #self._player_info do
|
||
-- if index == i then
|
||
-- -- body
|
||
-- local head_info = self._player_info[index]
|
||
-- head_info:MarkBank(true)
|
||
-- else
|
||
-- local head_info = self._player_info[i]
|
||
-- head_info:MarkBank(false)
|
||
-- end
|
||
-- end
|
||
|
||
-- if index == 1 then
|
||
local card_info = self._player_card_info[index]
|
||
-- if self.MypokerList ~= nil then
|
||
-- -- body
|
||
-- card_info:Clear()
|
||
-- card_info:InitPoker(self.MypokerList, false)
|
||
-- self.MypokerList = nil
|
||
-- end
|
||
-- end
|
||
self._leftClock_continue = coroutine.start(function()
|
||
coroutine.wait(0.02)
|
||
card_info:SetOutCardInfo(nil, false)
|
||
for i = 1, #self._player_card_info do
|
||
local card_info = self._player_card_info[i]
|
||
if i == index then
|
||
card_info._ctr_time_clock.selectedIndex = 1
|
||
self._tex_leftTime = card_info._view_comp_clock
|
||
else
|
||
card_info._ctr_time_clock.selectedIndex = 0
|
||
end
|
||
-- if self._room.is_new_bout then
|
||
-- card_info.ctr_outpoker.selectedIndex = 0
|
||
-- end
|
||
end
|
||
if self._left_time and self._left_time < 15 then
|
||
self._left_time = 15
|
||
end
|
||
end)
|
||
|
||
|
||
-- if self._room.ming_card ~= nil then
|
||
-- self._view:GetTransition("t" .. index):Play()
|
||
-- self._room.ming_card = nil
|
||
-- if self.tween ~= nil then
|
||
-- TweenUtils.Kill(self.tween)
|
||
-- self.tween = nil
|
||
-- end
|
||
-- end
|
||
|
||
--出牌权和前端出牌提示挪到转向协议
|
||
local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat)
|
||
if index == 1 then
|
||
card_info:ShowOutCardOption2(lastCardList, 1)
|
||
end
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnBombScore, function(...)
|
||
local arg = { ... }
|
||
local scoreList = arg[1]
|
||
-- for i = 1, #scoreList do
|
||
-- local player = self._room:GetPlayerBySeat(i)
|
||
-- local card_info = self._player_card_info[self:GetPos(i)]
|
||
-- local head_info = self._player_info[self:GetPos(i)]
|
||
-- card_info:PlayScore(scoreList[i], true)
|
||
-- head_info:UpdateScore(player.total_score)
|
||
-- end
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnPlaySucc, function(...)
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/playcard_chup.mp3")
|
||
-- self._popEvent = false
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
local card_number = arg[2]
|
||
self.ctr_time.selectedIndex = 0
|
||
local index = self:GetPos(p.seat)
|
||
if index == 1 then
|
||
self.caozuo = 0
|
||
end
|
||
coroutine.stop(self._leftClock_continue)
|
||
|
||
local head_info = self._player_info[index]
|
||
if head_info._view:GetChild("shengyu") ~= nil then
|
||
-- body
|
||
-- body
|
||
if card_number ~= nil then
|
||
-- body
|
||
head_info._view:GetChild("shengyu").text = card_number
|
||
end
|
||
end
|
||
local card_info = self._player_card_info[index]
|
||
card_info:SetOutCardInfo(p.out_card_list, false, true)
|
||
card_info._ctr_time_clock.selectedIndex = 0
|
||
|
||
if index == 1 then
|
||
card_info:DeleteHandCards(p.out_card_list)
|
||
end
|
||
end)
|
||
_gamectr:AddEventListener(EXGameEvent.OnCheckCard, function(...)
|
||
local arg = { ... }
|
||
local evt_data = arg[1]
|
||
local list = self._view:GetChild('comp_checkCard'):GetChild('list')
|
||
list:RemoveChildrenToPool()
|
||
for k, v in pairs(evt_data) do
|
||
local obj = list:AddItemFromPool()
|
||
table.sort(v, function(a, b)
|
||
if a % 100 == b % 100 then
|
||
return math.floor(a / 100) > math.floor(b / 100)
|
||
else
|
||
return a % 100 > b % 100
|
||
end
|
||
end)
|
||
local titleText = ""
|
||
if k == "first" then
|
||
titleText = "手牌1:"
|
||
elseif k == "second" then
|
||
titleText = "手牌2:"
|
||
elseif k == "three" then
|
||
titleText = "手牌3:"
|
||
end
|
||
obj.text = titleText
|
||
obj:GetChild('click').onClick:Set(function()
|
||
evt_data.choic = k
|
||
self._gamectr:SendCheckCardSend(evt_data)
|
||
self._view:GetController('check').selectedIndex = 0
|
||
end)
|
||
obj:GetChild('List_Out').itemRenderer = function(index, obj)
|
||
local code = v[index + 1]
|
||
if code % 100 == 15 then
|
||
code = math.floor(code / 100) * 100 + 2
|
||
end
|
||
obj:GetChild('icon').url = string.format("ui://Main_Poker/%s", code)
|
||
end
|
||
obj:GetChild('List_Out').numItems = #v
|
||
end
|
||
self._view:GetController('check').selectedIndex = 1
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnPassSuccCheckCard, function(...)
|
||
self._popEvent = false
|
||
local arg = { ... }
|
||
local seat = arg[1]
|
||
local cards = arg[2]
|
||
--self.MypokerList=cards
|
||
self.ctr_time.selectedIndex = 0
|
||
local card_info = self._player_card_info[self:GetPos(seat)]
|
||
if seat == self._room.self_player.seat then
|
||
card_info:ClearCheck()
|
||
card_info:InitPoker(cards, false)
|
||
|
||
--local player=self._room:GetPlayerBySeat(seat)
|
||
--if player.out_card_list[1] == 0 then
|
||
-- player_card_info:SetOutCardInfo(nil, true)
|
||
--else
|
||
--player:SetOutCardInfo({207}, false)
|
||
-- end
|
||
end
|
||
|
||
self._popEvent = true
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnPassSucc, function(...)
|
||
self._popEvent = false
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
|
||
self.ctr_time.selectedIndex = 0
|
||
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
||
|
||
--card_info:SetOutCardInfo(nil, false)
|
||
if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then
|
||
-- body
|
||
card_info:Clear()
|
||
card_info:InitPoker(self.MypokerList, false)
|
||
self.MypokerList = nil
|
||
end
|
||
coroutine.stop(self._leftClock_continue)
|
||
card_info._ctr_time_clock.selectedIndex = 0
|
||
card_info:SetOutCardInfo(nil, true)
|
||
self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4))
|
||
coroutine.start(function()
|
||
coroutine.wait(1)
|
||
self._popEvent = true
|
||
end)
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnErrorTip, function(...)
|
||
local arg = { ... }
|
||
local error_str = arg[1]
|
||
self._player_card_info[1]:ErrorTip(error_str)
|
||
self._player_card_info[1]:UpdateHandCardsPos()
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnPiaoTips, function(...)
|
||
local arg = { ... }
|
||
local piao = arg[1]
|
||
local reload = arg[2]
|
||
if reload == 0 then
|
||
if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then
|
||
-- body
|
||
self.MypokerList = cardlist
|
||
end
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list.visible = false
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
end
|
||
self.ctr_state.selectedIndex = 1
|
||
self.ctr_card_eff.selectedIndex = 0
|
||
if self.rank_view ~= nil then
|
||
self.rank_view:Dispose()
|
||
self.rank_view = nil
|
||
end
|
||
self:UpdateRound(self._room.curren_round)
|
||
|
||
local list = _room.player_list
|
||
for i = 1, #list do
|
||
local p = list[i]
|
||
local head_info = self._player_info[self:GetPos(p.seat)]
|
||
|
||
p:Clear()
|
||
head_info:FillData(p)
|
||
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
||
card_info:Clear()
|
||
head_info:Ready(false)
|
||
head_info:UpdatePiao(-1)
|
||
end
|
||
end
|
||
|
||
self._player_card_info[1]:ShowPiao(piao)
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnPiaoAction, function(...)
|
||
local arg = { ... }
|
||
local seat = arg[1]
|
||
local piao = arg[2]
|
||
local head_info = self._player_info[self:GetPos(seat)]
|
||
head_info:UpdatePiao(piao)
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnOptions, function(...)
|
||
-- local arg = { ... }
|
||
-- local play = arg[1]
|
||
-- local pass = arg[5]
|
||
-- local card_type = arg[2]
|
||
-- local card_number = arg[3]
|
||
-- local card_length = arg[4]
|
||
-- local lastCardList = arg[6]
|
||
-- local ctr_number = pass == nil and 2 or 1
|
||
-- self.caozuo = 1 --记录是否是自己出牌的阶段
|
||
-- self.pass = pass
|
||
-- local m = false
|
||
-- local next_seat = self._room.self_player.seat + 1
|
||
-- local card_info = self._player_card_info[1]
|
||
-- card_info:SetOutCardInfo(nil, false)
|
||
-- if self.MypokerList ~= nil then
|
||
-- -- body
|
||
-- card_info:Clear()
|
||
-- card_info:InitPoker(self.MypokerList, false)
|
||
-- self.MypokerList = nil
|
||
-- end
|
||
-- if next_seat > self._room.room_config.people_num then
|
||
-- next_seat = next_seat - self._room.room_config.people_num
|
||
-- end
|
||
-- if self._room:GetPlayerBySeat(next_seat).hand_count == 1 and self._room.room_config.WillBeOut == 1 then
|
||
-- m = true
|
||
-- end
|
||
-- local zdts = self._view:GetController("zidongtishi").selectedIndex
|
||
-- -- self._player_card_info[1]._cardCheck:InitLastCard(lastCardList)
|
||
-- -- self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts)
|
||
-- card_info:ShowOutCardOption2(lastCardList, ctr_number, m)
|
||
end)
|
||
-- 托管
|
||
_gamectr:AddEventListener(EXGameEvent.Game_TuoGuan, function(...)
|
||
local arg = { ... }
|
||
local tuoguan = arg[1]
|
||
local seat = arg[2]
|
||
|
||
local tuoguanzhong = self._view:GetChild("tuoguanzhong")
|
||
local zhezhao = self._view:GetChild("n109")
|
||
local head_info = self._player_info[self:GetPos(seat)]
|
||
if (tuoguan == 1) then
|
||
if (seat == self._room.self_player.seat) then
|
||
tuoguanzhong.visible = true
|
||
-- tuoguanzhong.sortingOrder = 2
|
||
zhezhao.visible = true
|
||
zhezhao.onClick:Set(function()
|
||
_gamectr:TuoGuan(0)
|
||
end)
|
||
else
|
||
head_info._view:GetController("tuoguan").selectedIndex = 1
|
||
end
|
||
-- if self.ispanguangzhe == true then
|
||
-- -- body
|
||
-- zhezhao.visible = false
|
||
-- end
|
||
else
|
||
if (seat == self._room.self_player.seat) then
|
||
tuoguanzhong.visible = false
|
||
zhezhao.visible = false
|
||
-- local btn_tuoguan = self._view:GetChild("n107")
|
||
-- btn_tuoguan.onClick:Set(function()
|
||
-- _gamectr:TuoGuan(1)
|
||
-- -- self:ZhiNengtuoguan()
|
||
-- end)
|
||
else
|
||
head_info._view:GetController("tuoguan").selectedIndex = 0
|
||
end
|
||
end
|
||
end)
|
||
_gamectr:AddEventListener(EXGameEvent.OnResult, function(...)
|
||
local arg = { ... }
|
||
local over = arg[1]
|
||
local info = arg[2]
|
||
local win_seat = arg[3]
|
||
local remaincards = arg[4]
|
||
-- local energyTab = arg[5]
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)]
|
||
if self.dismissWin ~= nil then
|
||
self.dismissWin:Destroy()
|
||
end
|
||
self.dismissWin = nil
|
||
if self.MypokerList ~= nil then
|
||
-- body
|
||
card_info:Clear()
|
||
card_info:InitPoker(self.MypokerList, false)
|
||
self.MypokerList = nil
|
||
end
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
otherpoker_list.visible = true
|
||
end
|
||
|
||
if self._cor_sound ~= nil then
|
||
coroutine.stop(self._cor_sound)
|
||
self._cor_sound = nil
|
||
end
|
||
|
||
if self.destory_win ~= nil then
|
||
coroutine.stop(self.destory_win)
|
||
end
|
||
|
||
self.destory_win = nil
|
||
self.destory_win = coroutine.start(function()
|
||
if win_seat == self._room.self_player.seat then
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/end_music.mp3")
|
||
else
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/lose_music.mp3")
|
||
end
|
||
coroutine.stop(self._leftClock_continue)
|
||
for i = 1, #self._player_card_info do
|
||
local card_info = self._player_card_info[i]
|
||
card_info._ctr_time_clock.selectedIndex = 0
|
||
self._left_time = 0
|
||
end
|
||
-- -- print("11111111111111")
|
||
-- coroutine.wait(1)
|
||
-- if self._room.self_player.seat == win_seat then
|
||
-- local sprint_seat_list = self:GetSpringSeats(info)
|
||
-- if #sprint_seat_list > 0 then
|
||
-- local url = "ui://Extend_Poker_DuoDuo/Spring"
|
||
-- self.WinItem_view = UIPackage.CreateObjectFromURL(url)
|
||
-- self._view:AddChild(self.WinItem_view)
|
||
-- self.WinItem_view:Center()
|
||
-- self.WinItem_view:GetTransition("t0"):Play()
|
||
-- ViewUtil.PlaySound("DuoDuo_PK", "base/common/sound/win new.mp3")
|
||
-- end
|
||
-- -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_DuoDuo/Spring" or "ui://Extend_Poker_DuoDuo/Win_Mine"
|
||
-- else
|
||
-- local beigang = false
|
||
-- if #self:GetSpringSeats(info) > 0 then
|
||
-- for i = 1, #self:GetSpringSeats(info) do
|
||
-- if self:GetSpringSeats(info)[i] == self._room.self_player.seat then
|
||
-- local url = "ui://Extend_Poker_DuoDuo/spring2"
|
||
-- self.WinItem_view = UIPackage.CreateObjectFromURL(url)
|
||
-- self._view:AddChild(self.WinItem_view)
|
||
-- self.WinItem_view:Center()
|
||
-- self.WinItem_view:GetTransition("t0"):Play()
|
||
-- beigang = true
|
||
-- end
|
||
-- end
|
||
-- end
|
||
-- -- if beigang == false then
|
||
-- -- self:CreateRankEff()
|
||
-- -- end
|
||
-- end
|
||
|
||
for i = 1, #info do
|
||
local player = info[i]
|
||
local p = self._room:GetPlayerBySeat(player.seat)
|
||
local head_info = self._player_info[self:GetPos(player.seat)]
|
||
head_info:SetBaoDan(false)
|
||
|
||
head_info._view:GetChild('text_jifen').text = player.score
|
||
-- head_info:PlayScore(player.winscore, win_seat == player.seat)
|
||
head_info:PlayScore(player.card_score, win_seat == player.seat)
|
||
end
|
||
|
||
for i = 1, #info do
|
||
local player = info[i]
|
||
local p = self._room:GetPlayerBySeat(player.seat)
|
||
local head_info = self._player_info[self:GetPos(player.seat)]
|
||
local card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
|
||
if player.seat ~= win_seat then
|
||
card_info.ctr_outpoker.selectedIndex = 0
|
||
end
|
||
if player.seat ~= self._room.self_player.seat then
|
||
local oneTime = 7 / 60
|
||
|
||
-- card_info:UpdateHandPoker(player.cards, false, true)
|
||
|
||
card_info._view_resultOut:RemoveChildrenToPool()
|
||
card_info._ctr_resultOut.selectedIndex = 1
|
||
for i = 1, #player.handCards do
|
||
local child_card = card_info._view_resultOut:AddItemFromPool()
|
||
card_info:FillPoker(child_card, "", nil, player.handCards[i])
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/fanCard.mp3")
|
||
printlog("lingmeng oneTime", oneTime)
|
||
coroutine.wait(oneTime)
|
||
end
|
||
end
|
||
end
|
||
self:ChangeBgmMusic(1)
|
||
-- if over == 0 then
|
||
-- if #self:GetSpringSeats(info) > 0 then
|
||
-- -- -- print("222222222222222222")
|
||
-- coroutine.wait(1)
|
||
-- else
|
||
-- -- -- print("333333333333333333")
|
||
-- -- coroutine.wait(2)
|
||
-- end
|
||
coroutine.wait(2)
|
||
|
||
self.result_view = EXResultView.new(self, info, self._room.room_id, over, win_seat, 0,
|
||
remaincards)
|
||
self.result_view:SetDestroryCallback(function()
|
||
for i = 1, #self._player_card_info do
|
||
local card_info = self._player_card_info[i]
|
||
card_info.ctr_outpoker.selectedIndex = 0
|
||
if card_info._ctr_resultOut then
|
||
card_info._ctr_resultOut.selectedIndex = 0
|
||
end
|
||
end
|
||
end)
|
||
self.result_view:Show()
|
||
if self.WinItem_view ~= nil then
|
||
self.WinItem_view:Dispose()
|
||
self.WinItem_view = nil
|
||
end
|
||
if self.rank_view ~= nil then
|
||
self.rank_view:Dispose()
|
||
self.rank_view = nil
|
||
end
|
||
|
||
if self._room.self_player.entrust == true then
|
||
local btn_confirm = self.result_view._view:GetChild("btn_confirm")
|
||
btn_confirm.onClick:Call()
|
||
end
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/end_music.mp3")
|
||
end)
|
||
if over == 1 then
|
||
-- body
|
||
self:UnmarkSelfTuoguan()
|
||
ControllerManager.ChangeController(LoddyController)
|
||
end
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnResultByDissolve, function(...)
|
||
local arg = { ... }
|
||
local over = arg[1]
|
||
local info = arg[2]
|
||
local winseat = arg[3]
|
||
local dissolve = arg[4]
|
||
if self.dismissWin ~= nil then
|
||
self.dismissWin:Destroy()
|
||
end
|
||
self.dismissWin = nil
|
||
if _room.curren_round > 0 then
|
||
ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/end_music.mp3")
|
||
end
|
||
for i = 1, #self._player_card_info do
|
||
local card_info = self._player_card_info[i]
|
||
card_info._ctr_time_clock.selectedIndex = 0
|
||
end
|
||
self.result_view = EXResultView.new(self, info, self._room.room_id, over, winseat, dissolve, nil)
|
||
self.result_view:Show()
|
||
ControllerManager.ChangeController(LoddyController)
|
||
self:UnmarkSelfTuoguan()
|
||
end)
|
||
|
||
-- 确定开始下一局 成功
|
||
_gamectr:AddEventListener(EXGameEvent.OnConfrimToNextGameSucc, function(...)
|
||
local arg = { ... }
|
||
local aid = arg[1]
|
||
local p = self._room:GetPlayerById(aid)
|
||
if p.seat == self._room.self_player.seat then
|
||
if self.rank_view ~= nil then
|
||
self.rank_view:Dispose()
|
||
self.rank_view = nil
|
||
end
|
||
if self.destory_win ~= nil then
|
||
coroutine.stop(self.destory_win)
|
||
self.destory_win = nil
|
||
end
|
||
for _, player in ipairs(self._room.player_list) do
|
||
local player_card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
local player_head = self._player_info[self:GetPos(player.seat)]
|
||
player_card_info:Clear()
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list.visible = false
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
end
|
||
--player_head._view:GetController("Oener").selectedIndex=0
|
||
end
|
||
end
|
||
local player_info = self._player_info[self:GetPos(p.seat)]
|
||
player_info:Ready(true)
|
||
end)
|
||
|
||
_gamectr:AddEventListener(EXGameEvent.OnBompScoreNew, function(...)
|
||
local arg = { ... }
|
||
self._popEvent = false
|
||
local scoreList = arg[1]
|
||
for i = 1, #scoreList do
|
||
local score = scoreList[i].pomSore
|
||
local player = self._room:GetPlayerBySeat(scoreList[i].seat)
|
||
local head_info = self._player_info[self:GetPos(scoreList[i].seat)]
|
||
head_info:PlayScore(score, true)
|
||
head_info:UpdateScore(player.total_score)
|
||
end
|
||
coroutine.start(function()
|
||
coroutine.wait(1)
|
||
self._popEvent = true
|
||
end)
|
||
end)
|
||
|
||
_gamectr:AddEventListener(
|
||
GameEvent.PlayerState,
|
||
function(...)
|
||
printlog("lingmeng OnEventOnlineState")
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
local info = self._player_info[self:GetPos(p.seat)]
|
||
info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0
|
||
end
|
||
)
|
||
end
|
||
|
||
function M:ReConnectForStart()
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat)
|
||
self._state.selectedIndex = 1
|
||
self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat)
|
||
|
||
for _, player in ipairs(self._room.player_list) do
|
||
local player_card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
local head_info = self._player_info[self:GetPos(player.seat)]
|
||
head_info:Ready(false)
|
||
|
||
head_info:UpdateScore(player.total_score)
|
||
head_info:UpdateLineState(player.line_state)
|
||
head_info:UpdatePiao(player.piao)
|
||
head_info:SetBaoDan(player.hand_count == 1)
|
||
head_info:MarkBank(player.seat == self._room.banker_seat)
|
||
|
||
if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then
|
||
-- body
|
||
|
||
|
||
if self._room.room_config.showlength == 1 then
|
||
-- body
|
||
head_info._view:GetController("shengyu").selectedIndex = 1
|
||
else
|
||
head_info._view:GetController("shengyu").selectedIndex = 0
|
||
end
|
||
|
||
-- body
|
||
head_info._view:GetChild("shengyu").text = player.hand_count
|
||
end
|
||
|
||
if player.seat == self._room.self_player.seat then
|
||
if player.open ~= nil and player.open == 0 and self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then
|
||
-- body
|
||
self.MypokerList = player.hand_list
|
||
player_card_info:InitPoker(player.hand_list, false, 1)
|
||
else
|
||
player_card_info:InitPoker(player.hand_list, false)
|
||
end
|
||
if not player.out_card_list or #player.out_card_list == 0 or player.out_card_list[1] == 0 then
|
||
player_card_info:SetOutCardInfo(nil, false)
|
||
else
|
||
player_card_info:SetOutCardInfo(player.out_card_list, false)
|
||
end
|
||
else
|
||
if not player.out_card_list or #player.out_card_list == 0 or player.out_card_list[1] == 0 then
|
||
player_card_info:SetOutCardInfo(nil, true)
|
||
else
|
||
player_card_info:SetOutCardInfo(player.out_card_list, false)
|
||
end
|
||
end
|
||
if self._room.curren_turn_seat == player.seat then
|
||
-- head_info:MarkBank(false)
|
||
player_card_info._ctr_time_clock.selectedIndex = 1
|
||
self._tex_leftTime = player_card_info._view_comp_clock
|
||
self._left_time = 15
|
||
player_card_info:SetOutCardInfo(nil, false)
|
||
if player.seat == self._room.self_player.seat then
|
||
local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat)
|
||
player_card_info:ShowOutCardOption2(lastCardList, 1)
|
||
end
|
||
else
|
||
-- head_info:MarkBank(true)
|
||
end
|
||
end
|
||
end
|
||
|
||
function M:ReconnectForClearing()
|
||
self:UpdateRound(self._room.curren_round)
|
||
local win_seat = 0
|
||
--self.rank_view = self:CreateRankEff(self._room.winseat)
|
||
for _, player in ipairs(self._room.player_list) do
|
||
local head_info = self._player_info[self:GetPos(player.seat)]
|
||
local player_card_info = self._player_card_info[self:GetPos(player.seat)]
|
||
|
||
--如果是体力值不可负分模式 则显示当前的hp值
|
||
if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then
|
||
head_info:UpdateScore(d2ad(player.hp_info.cur_hp))
|
||
head_info._view:GetChild('zhanji').visible = true
|
||
local num = player.hp_info.total_hp
|
||
if num > 0 then
|
||
head_info._view:GetController('text_color').selectedIndex = 0
|
||
head_info._view:GetChild('text_jifen').text = '+' .. d2ad(player.hp_info.total_hp)
|
||
else
|
||
head_info._view:GetController('text_color').selectedIndex = 1
|
||
head_info._view:GetChild('text_jifen').text = d2ad(player.hp_info.total_hp)
|
||
end
|
||
-- player_card_info:PlayScore(d2ad(player.hp_info.round_actual_hp))
|
||
else
|
||
local rt = 1
|
||
if self._room.hpOnOff == 1 then
|
||
rt = self._room.score_times
|
||
end
|
||
head_info:UpdateScore(player.total_score * rt)
|
||
-- player_card_info:PlayScore(player.winscore * rt, false, self._room.winseat)
|
||
end
|
||
|
||
head_info:UpdateLineState(player.line_state)
|
||
--head_info._view:GetController("Oener").selectedIndex=0
|
||
head_info:UpdatePiao(player.piao)
|
||
head_info:MarkBank(player.seat == self._room.banker_seat)
|
||
if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then
|
||
-- body
|
||
|
||
if self._room.room_config.showlength == 1 then
|
||
-- body
|
||
head_info._view:GetController("shengyu").selectedIndex = 1
|
||
else
|
||
head_info._view:GetController("shengyu").selectedIndex = 0
|
||
end
|
||
|
||
-- body
|
||
head_info._view:GetChild("shengyu").text = player.hand_count
|
||
end
|
||
|
||
|
||
if player.seat == self._room.self_player.seat then
|
||
player_card_info:InitPoker(player.hand_list, false)
|
||
else
|
||
-- player_card_info:UpdateHandPoker(player.hand_list, false, true)
|
||
end
|
||
if player.out_card_list[1] == 0 then
|
||
player_card_info:SetOutCardInfo(nil, false)
|
||
else
|
||
player_card_info:SetOutCardInfo(player.out_card_list, false)
|
||
end
|
||
end
|
||
win_seat = self._room.winseat
|
||
self._room.winseat = nil
|
||
|
||
local remaincards = self._room.remaincards
|
||
if self._room.game_status == 1 then
|
||
-- body
|
||
coroutine.start(function()
|
||
coroutine.wait(0.3)
|
||
|
||
self.result_view = EXResultView.new(self, self._room.player_list, self._room.room_id, 0,
|
||
win_seat, 0, remaincards)
|
||
self.result_view:SetDestroryCallback(function()
|
||
for i = 1, #self._player_card_info do
|
||
local card_info = self._player_card_info[i]
|
||
card_info.ctr_outpoker.selectedIndex = 0
|
||
if card_info._ctr_resultOut then
|
||
card_info._ctr_resultOut.selectedIndex = 0
|
||
end
|
||
end
|
||
end)
|
||
self.result_view:Show()
|
||
local card_info = self._player_card_info[1]
|
||
card_info._view:GetChild("out_card_list").visible = true
|
||
end)
|
||
if remaincards then
|
||
local newremaincards = self._gamectr:ChangeCodeByFrom(remaincards, true)
|
||
|
||
-- body
|
||
local otherpoker_list = self._view:GetChild("otherpoker_list")
|
||
|
||
if otherpoker_list ~= nil then
|
||
-- body
|
||
otherpoker_list:RemoveChildrenToPool()
|
||
otherpoker_list.visible = true
|
||
end
|
||
|
||
for i = #newremaincards, 1, -1 do
|
||
coroutine.start(function()
|
||
coroutine.wait(0.1 * (15 - i))
|
||
|
||
|
||
local flow = newremaincards[i] % 10
|
||
local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10
|
||
local card_n = flow * 100 + num
|
||
local poker_item = UIPackage.CreateObject("Extend_Poker_DuoDuo", "poker6")
|
||
|
||
--local code = self:ChangeCodeByTo(card_n)
|
||
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n)
|
||
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2")
|
||
local card_code_obj
|
||
if DataManager.CurrenRoom.pai == 0 then
|
||
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. card_n)
|
||
else
|
||
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2")
|
||
end
|
||
if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then
|
||
-- body
|
||
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. card_n .. "_1")
|
||
end
|
||
card_code_obj:SetScale(0.6, 0.6)
|
||
poker_item:AddChild(card_code_obj)
|
||
otherpoker_list:AddChild(poker_item)
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
function M:CreateRankEff()
|
||
self.rank_view = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/rank_eff")
|
||
self._view:AddChild(self.rank_view)
|
||
self.rank_view:Center()
|
||
self.rank_view:GetTransition("t0"):Play()
|
||
end
|
||
|
||
function M:_Effect(type1, player)
|
||
if type1 == 1 or type1 == 3 or type1 == 7 then
|
||
self._popEvent = true
|
||
return
|
||
end
|
||
local info = self._player_card_info[self:GetPos(player.seat)]
|
||
info:PlayEffect(type1, function()
|
||
self._popEvent = true
|
||
end)
|
||
end
|
||
|
||
-- function M:_Effect(type1, player)
|
||
-- -- body
|
||
|
||
-- if type1 < 7 and type1 ~= 4 and type1 ~= 5 then
|
||
-- return
|
||
-- end
|
||
-- local eff_code = 0
|
||
-- if type1 == 10 then
|
||
-- eff_code = 2
|
||
-- elseif type1 == 11 then
|
||
-- eff_code = 3
|
||
-- elseif type1 == 4 then
|
||
-- eff_code = 4
|
||
-- elseif type1 == 12 then
|
||
-- return
|
||
-- elseif type1 == 5 then
|
||
-- eff_code = 5
|
||
-- else
|
||
-- eff_code = 1
|
||
-- end
|
||
-- local info = self._player_card_info[self:GetPos(player.seat)]
|
||
-- local pNode = info._mask_liangpai
|
||
-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/eff_" .. eff_code)
|
||
-- -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/eff2_1")
|
||
-- effect.touchable = false
|
||
-- effect:GetTransition("t0"):Play()
|
||
-- -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2)
|
||
-- if eff_code == 3 then
|
||
-- self._view:AddChild(effect)
|
||
-- else
|
||
-- pNode:AddChild(effect)
|
||
-- end
|
||
|
||
|
||
-- if eff_code == 1 then
|
||
-- self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/eff_feiji")
|
||
-- self._view:AddChild(self.eff_feiji)
|
||
-- self.eff_feiji:Center()
|
||
-- self.eff_feiji:GetTransition("t0"):Play()
|
||
-- end
|
||
-- if eff_code == 3 then
|
||
-- effect:Center()
|
||
-- else
|
||
-- if self:GetPos(player.seat) == 1 then
|
||
-- effect.x, effect.y = 0, 24
|
||
-- else
|
||
-- effect.x, effect.y = 24, 67
|
||
-- end
|
||
-- end
|
||
|
||
|
||
-- -- effect:Center()
|
||
-- -- if eff_code ==3 then
|
||
-- -- coroutine.start(function()
|
||
-- -- coroutine.wait(1)
|
||
-- -- effect:Dispose()
|
||
-- -- end)
|
||
-- -- else
|
||
-- coroutine.start(function()
|
||
-- coroutine.wait(1)
|
||
-- if self.eff_feiji ~= nil then
|
||
-- self.eff_feiji:Dispose()
|
||
-- end
|
||
-- effect:Dispose()
|
||
-- end)
|
||
-- -- end
|
||
-- end
|
||
|
||
function M:OnTupGuanOpen(...)
|
||
---- print("刷新托管数据=====")
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
local player_card_info = self._player_card_info[self:GetPos(p.seat)]
|
||
self._tex_leftTime = player_card_info._view_comp_clock
|
||
self._left_time = tonumber(arg[3]) or 0
|
||
end
|
||
|
||
function M:UpdateRound(round)
|
||
local total_round = self._room.room_config.Times
|
||
-- self._text_round.text = string.format("%d / %d 局", round, total_round)
|
||
if not self._text_currenRound then
|
||
self._text_currenRound = self._view:GetChild('Text_CurrenRound')
|
||
end
|
||
if not self._text_maxRound then
|
||
self._text_maxRound = self._view:GetChild('Text_MaxMaxRound')
|
||
end
|
||
self._text_currenRound.text = round
|
||
self._text_maxRound.text = string.format("/%s局", total_round)
|
||
end
|
||
|
||
-- function M:InitPlayerInfoView()
|
||
-- self._player_info = {}
|
||
-- local _player_info = self._player_info
|
||
-- for i = 1, self._room.room_config.people_num do
|
||
-- local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
|
||
-- _player_info[i] = PlayerInfoView.new(tem, self)
|
||
-- tem.visible = false
|
||
-- end
|
||
-- end
|
||
|
||
-- function M:GetSoundFileName(type, num, isNewBout)
|
||
-- local fileName
|
||
-- if isNewBout then
|
||
-- if type > 6 or type == 4 then
|
||
-- if type == 8 or type == 9 then
|
||
-- type = 7
|
||
-- end
|
||
-- fileName = tostring(type)
|
||
-- elseif type > 2 then
|
||
-- fileName = string.format("3_%d", num)
|
||
-- else
|
||
-- fileName = string.format("%d_%d", type, num)
|
||
-- end
|
||
-- else
|
||
-- math.randomseed(os.time())
|
||
-- if type > 2 and type ~= 11 then
|
||
-- local r = math.random(1, 3)
|
||
-- fileName = "dani_" .. r
|
||
-- elseif type == 11 then
|
||
-- fileName = tostring(type)
|
||
-- else
|
||
-- fileName = string.format("%d_%d", type, num)
|
||
-- end
|
||
-- end
|
||
-- return fileName
|
||
-- end
|
||
|
||
function M:GetSoundFileName(type, num, isNewBout)
|
||
local fileName
|
||
if type == 1 or type == 3 or type == 7 then
|
||
local num = self._cardCheck.lastMinCard
|
||
if type == 1 then
|
||
fileName = string.format("1_%d", num)
|
||
elseif type == 3 then
|
||
fileName = string.format("2_%d", num)
|
||
elseif type == 7 then
|
||
fileName = string.format("3_%d", num)
|
||
end
|
||
else
|
||
if not isNewBout and type ~= 6 then
|
||
local r = math.random(1, 3)
|
||
fileName = "dani_" .. r
|
||
else
|
||
if type == 8 or type == 12 then
|
||
fileName = 5
|
||
else
|
||
fileName = type
|
||
end
|
||
end
|
||
end
|
||
|
||
return fileName
|
||
end
|
||
|
||
function M:GetSpringSeats(player_info)
|
||
local seat_list = {}
|
||
local card_max_length = self._room.room_config.Leaf + 14
|
||
for i = 1, #player_info do
|
||
local player = player_info[i]
|
||
if #player.cards == card_max_length then
|
||
seat_list[#seat_list + 1] = player.seat
|
||
end
|
||
end
|
||
return seat_list
|
||
end
|
||
|
||
function M:PlayCardEff(card)
|
||
if self.cor_card_eff ~= nil then
|
||
coroutine.stop(self.cor_card_eff)
|
||
end
|
||
self.cor_card_eff = nil
|
||
local cor_time = 0.1
|
||
self.cor_card_eff = coroutine.start(function()
|
||
self._popEvent = false
|
||
local eff = self._view:GetChild("poker_eff")
|
||
local poker_obj = eff:GetChild("poker")
|
||
local poker_back = eff:GetChild("di")
|
||
poker_back.visible = false
|
||
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card)
|
||
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2")
|
||
local card_code_obj
|
||
if DataManager.CurrenRoom.pai == 0 then
|
||
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. card)
|
||
else
|
||
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2")
|
||
end
|
||
if card_code_obj then
|
||
card_code_obj:SetScale(1, 1)
|
||
poker_obj:AddChild(card_code_obj)
|
||
card_code_obj.visible = true
|
||
end
|
||
|
||
self.tween = TweenUtils.TweenFloat(0, 2340, cor_time, function(x)
|
||
poker_back.rotationY = x
|
||
poker_obj.rotationY = -180 + x
|
||
local x_1 = x % 360
|
||
if (x_1 > 90 and x_1 < 270) then
|
||
poker_obj.visible = true
|
||
poker_back.visible = false
|
||
else
|
||
poker_obj.visible = false
|
||
poker_back.visible = true
|
||
end
|
||
end)
|
||
coroutine.wait(1)
|
||
self._popEvent = true
|
||
end)
|
||
end
|
||
|
||
function M:ResetPoker()
|
||
-- if self._room.curren_turn_seat == self._room.self_player.seat then
|
||
-- self._player_card_info[1]:ResetPoker()
|
||
-- end
|
||
self._player_card_info[1]:ResetPoker()
|
||
end
|
||
|
||
----结算准备时清理桌面
|
||
function M:ClearOk()
|
||
for i = 1, #self._player_card_info do
|
||
self._player_card_info[i]:Clear()
|
||
end
|
||
end
|
||
|
||
function M:PlaySound(sex, path)
|
||
local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女
|
||
local sound_path = string.format("extend/poker/duoduo/sound/%s/%s.mp3", sex_path, path)
|
||
ViewUtil.PlaySound("DuoDuo_PK", sound_path)
|
||
end
|
||
|
||
function M:ChangeBgmMusic(bgm_index)
|
||
if bgm_index == nil then
|
||
bgm_index = self.bgm_index
|
||
else
|
||
self.bgm_index = bgm_index
|
||
end
|
||
ViewUtil.PlayMuisc("DuoDuo_PK", string.format("extend/poker/duoduo/sound/bgm%d.mp3", 1))
|
||
end
|
||
|
||
function M:OnPlayerEnter(...)
|
||
ViewUtil.PlaySound("DuoDuo_PK", "base/main_majiang/sound/user_enter.mp3")
|
||
local arg = { ... }
|
||
local p = arg[1]
|
||
for i = 1, #self._room.player_list do
|
||
if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then
|
||
-- body
|
||
local ErrorMsgTip = UIPackage.CreateObject("Common", "Win_ConnectTip")
|
||
local _action = self._view:AddChild(ErrorMsgTip)
|
||
_action.xy = Vector2((self._view.width - _action.width) / 4, self._view.height / 4)
|
||
local text = _action:GetChild("tex_message")
|
||
local btn1 = _action:GetChild("btn_connect")
|
||
local btn2 = _action:GetChild("btn_back")
|
||
text.text = "您来晚了,座位有人,请重新进牌桌"
|
||
btn1.visible = false
|
||
btn2:Center()
|
||
btn2.y = btn2.y + 50
|
||
btn2.onClick:Set(function()
|
||
-- body
|
||
ErrorMsgTip:Destroy()
|
||
ErrorMsgTip = nil
|
||
self._gamectr:LevelRoom(function(res)
|
||
ViewUtil.CloseModalWait2()
|
||
NetResetConnectWindow.CloseNetReset()
|
||
ControllerManager.ChangeController(LoddyController)
|
||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
||
end)
|
||
end)
|
||
end
|
||
end
|
||
-- if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then
|
||
-- if self.distance_view then
|
||
-- self.distance_view:Destroy()
|
||
-- end
|
||
-- self.distance_view = PlayerDistanceView.new(true)
|
||
-- self.distance_view:Show()
|
||
-- end
|
||
-- local info = self._player_info[self:GetPos(p.seat)]
|
||
-- info:FillData(p)
|
||
-- info._view.visible = true
|
||
MainView.OnPlayerEnter(self, ...)
|
||
end
|
||
|
||
function M:Destroy()
|
||
for i = 1, #self._room.player_list do
|
||
local player = self._room.player_list[i]
|
||
local card_info_i = self._player_card_info[self:GetPos(player.seat)]
|
||
|
||
card_info_i:Destroy()
|
||
if card_info_i ~= nil and card_info_i.cor_init_poker ~= nil then
|
||
coroutine.stop(card_info_i.cor_init_poker)
|
||
end
|
||
end
|
||
GRoot.inst.onSizeChanged:Set(function()
|
||
|
||
end)
|
||
PKMainView.Destroy(self)
|
||
UIPackage.RemovePackage("extend/poker/duoduo/ui/Extend_Poker_DuoDuo")
|
||
end
|
||
|
||
return M
|