2025-05-07 10:29:37 +08:00
---
--- Created by 谌建军.
--- DateTime: 2017/12/18 9:41
---
2025-05-14 10:59:30 +08:00
local PKMainView = import ( " main.poker2.PKMainView " )
local EXPlayerPokerInfoView = import ( " .EXPlayerPokerInfoView " )
local EXPlayerSelfPokerInfoView = import ( " .EXPlayerSelfPokerInfoView " )
local EXGameEvent = import ( " .EXGameEvent " )
local EXResultView = import ( " .EXResultView " )
local EXRightPanelView = import ( " .EXRightPanelView " )
2025-05-07 10:29:37 +08:00
local PlayerInfoView = import ( " .EXPlayerInfoView " )
local TableBG = import ( ' Game.Data.TableBG ' )
local M = { }
function M . new ( )
setmetatable ( M , { __index = PKMainView } )
local self = setmetatable ( { } , { __index = M } )
2025-05-14 10:59:30 +08:00
self.class = " EXMainView "
2025-05-07 10:29:37 +08:00
self : init ( )
self._gamectr = ControllerManager.GetController ( GameController )
return self
end
local default_bg = 1
local bg_config = {
2025-05-14 10:59:30 +08:00
{ id = 1 , url = ' extend/poker2/suoha/bg/bg1 ' , thumb = ' ui://Extend_Poker_SuoHa/table_bg1 ' } ,
{ id = 2 , url = ' extend/poker2/suoha/bg/bg2 ' , thumb = ' ui://Extend_Poker_SuoHa/table_bg2 ' } ,
{ id = 3 , url = ' extend/poker2/suoha/bg/bg3 ' , thumb = ' ui://Extend_Poker_SuoHa/table_bg3 ' }
2025-05-07 10:29:37 +08:00
}
function M : InitView ( url )
local room = self._room
2025-05-14 10:59:30 +08:00
UIPackage.AddPackage ( " extend/poker2/suoha/ui/Extend_Poker_SuoHa " )
2025-05-14 18:56:50 +08:00
-- UIPackage.AddPackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew")
PKMainView.InitView ( self , " ui://Extend_Poker_SuoHa/Main " , nil , 1 ,
2025-05-07 10:29:37 +08:00
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
2025-05-14 10:59:30 +08:00
self._rightPanelView = EXRightPanelView.new ( self , rightpanel )
2025-05-07 10:29:37 +08:00
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.CloseModalWait ( )
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.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
2025-05-14 18:56:50 +08:00
local tem = self._view : GetChild ( " player_card_info " .. i )
2025-05-07 10:29:37 +08:00
_player_card_info [ i ] = self : NewPlayerCardInfoView ( tem , i )
end
2025-05-14 10:59:30 +08:00
--默认直接展示准备按钮
self._ctr_action . selectedIndex = 1
2025-05-07 10:29:37 +08:00
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 )
local btn_rule = self._view : GetChild ( " right_panel " ) : GetChild ( " btn_log " )
self._view : GetChild ( ' info_text ' ) : GetChild ( ' text ' ) . text = room.room_config : GetDes ( )
if room.room_config . Leaf == 1 then
if room.room_config . people_num == 2 then
self._view : GetChild ( ' wanfa_text ' ) . text = ' 十五张 ' .. ' 二人跑得快 ' .. room.score_times .. ' 倍 '
else
self._view : GetChild ( ' wanfa_text ' ) . text = ' 十五张 ' .. ' 三人跑得快 ' .. room.score_times .. ' 倍 '
end
else
if room.room_config . people_num == 2 then
self._view : GetChild ( ' wanfa_text ' ) . text = ' 十六张 ' .. ' 二人跑得快 ' .. room.score_times .. ' 倍 '
else
self._view : GetChild ( ' wanfa_text ' ) . text = ' 十六张 ' .. ' 三人跑得快 ' .. room.score_times .. ' 倍 '
end
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 : UpdateRound ( 0 )
--按钮功能全部未开放
self._view : GetChild ( ' Btn_Spectator ' ) . onClick : Set ( function ( )
ViewUtil.ErrorMsg ( self._view , " " , " 该功能还未开放 " )
end )
self._view : GetChild ( ' Btn_GamePlay ' ) . onClick : Set ( function ( )
ViewUtil.ErrorMsg ( self._view , " " , " 该功能还未开放 " )
end )
self._view : GetChild ( ' Btn_Check ' ) . onClick : Set ( function ( )
ViewUtil.ErrorMsg ( self._view , " " , " 该功能还未开放 " )
end )
self._view : GetChild ( ' Btn_Message ' ) . onClick : Set ( function ( )
ViewUtil.ErrorMsg ( self._view , " " , " 该功能还未开放 " )
end )
self._view : GetChild ( ' Btn_Invite ' ) . onClick : Set ( function ( )
ViewUtil.ErrorMsg ( self._view , " " , " 该功能还未开放 " )
end )
----------------------------------------------------
2025-05-16 16:33:31 +08:00
-------------梭哈-------------------
self._viewText_allScore = self._view : GetChild ( ' text_AllScore ' )
------------------------------------
2025-05-07 10:29:37 +08:00
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
2025-05-14 10:59:30 +08:00
return EXPlayerSelfPokerInfoView.new ( tem , self )
2025-05-07 10:29:37 +08:00
end
2025-05-14 10:59:30 +08:00
return EXPlayerPokerInfoView.new ( tem , self )
2025-05-07 10:29:37 +08:00
end
function M : OnPlayerEnter ( ... )
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 )
end
function M : OnPlayerReady ( ... )
2025-05-14 19:34:03 +08:00
print ( ' thislingmengOnPlayerReady ' )
2025-05-07 10:29:37 +08:00
local arg = { ... }
local p = arg [ 1 ]
local _room = self._room
local _player_info = self._player_info
2025-05-14 19:34:03 +08:00
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 )
2025-05-07 10:29:37 +08:00
end
function M : OnPlayerLeave ( ... )
MainView.OnPlayerLeave ( self , ... )
local _room = self._room
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
2025-05-14 10:59:30 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnSendCard , function ( ... )
2025-05-07 10:29:37 +08:00
local arg = { ... }
2025-05-15 16:49:18 +08:00
local data = arg [ 1 ]
local round = data.round
local bank_seat = data.bank_seat
self : UpdateRound ( round )
self._state . selectedIndex = 1
2025-05-16 17:56:01 +08:00
local list = _room.player_list
for i = 1 , # list do
2025-05-15 16:49:18 +08:00
local cardList = data [ string.format ( " seat_%d " , i ) ]
pt ( cardList )
local cardInfo = _player_card_info [ self : GetPos ( i ) ]
if cardList then
cardInfo : UpdateHandPoker ( cardList )
end
2025-05-16 17:56:01 +08:00
local playerInfo = _player_info [ self : GetPos ( i ) ]
playerInfo : FillData ( list [ i ] )
playerInfo : Ready ( false )
2025-05-17 15:00:23 +08:00
if i == bank_seat then
playerInfo : MarkBank ( true )
else
playerInfo : MarkBank ( false )
end
2025-05-15 16:49:18 +08:00
end
2025-05-07 10:29:37 +08:00
end )
2025-05-14 10:59:30 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnTipAction , function ( ... )
2025-05-07 10:29:37 +08:00
local arg = { ... }
end )
2025-05-14 10:59:30 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnResult1 , function ( ... )
2025-05-07 10:29:37 +08:00
local arg = { ... }
2025-05-16 17:45:35 +08:00
self.result_view = EXResultView.new ( self._root_view , self._room . player_list , self._room . room_id , 0 , win_seat , 0 ,
remaincards )
self.result_view : InitBackReady ( function ( )
self._state . selectedIndex = 0
2025-05-16 17:56:01 +08:00
self._ctr_action . selectedIndex = 1
2025-05-16 17:45:35 +08:00
end )
self.result_view : Show ( )
2025-05-07 10:29:37 +08:00
end )
2025-05-14 10:59:30 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnResult2 , function ( ... )
2025-05-07 10:29:37 +08:00
local arg = { ... }
2025-05-16 17:56:01 +08:00
ViewManager.ChangeView ( ViewManager.View_Family )
2025-05-07 10:29:37 +08:00
end )
2025-05-16 16:33:31 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnUpdateScore , function ( ... )
local arg = { ... }
local data = arg [ 1 ]
local sidePot = data.sidePot
self._viewText_allScore . text = sidePot
local maxPeopleNum = _room.room_config . people_num
for i = 1 , maxPeopleNum do
local score = data [ string.format ( " seat_%d " , i ) ]
print ( score )
local player = _player_info [ self : GetPos ( i ) ]
if score then
player : UpdateScore ( score )
end
end
end )
2025-05-14 10:59:30 +08:00
_gamectr : AddEventListener ( EXGameEvent.OnTurnAction , function ( ... )
2025-05-16 11:44:16 +08:00
print ( " lingmengOnTurnAction " )
pt ( arg )
2025-05-07 10:29:37 +08:00
local arg = { ... }
2025-05-16 11:13:01 +08:00
local data = arg [ 1 ]
local seat = data.seat
2025-05-16 11:55:28 +08:00
if seat == _room.self_player . seat then
_player_card_info [ 1 ] : ShowTips ( data.actions )
end
2025-05-07 10:29:37 +08:00
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 )
--如果是体力值不可负分模式 则显示当前的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_score ' ) . text = ' + ' .. d2ad ( player.hp_info . total_hp )
else
head_info._view : GetController ( ' text_color ' ) . selectedIndex = 1
head_info._view : GetChild ( ' text_score ' ) . text = d2ad ( player.hp_info . total_hp )
end
else
local rt = 1
if self._room . hpOnOff == 1 then
rt = self._room . score_times
end
head_info : UpdateScore ( player.total_score * rt )
end
head_info : UpdateLineState ( player.line_state )
head_info : UpdatePiao ( player.piao )
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 " ) : GetChild ( " shengyu " ) . text = " 剩 " .. player.hand_count .. " 张 "
end
2025-05-15 16:49:18 +08:00
print ( " lingmengReConnectForStart " )
pt ( player )
-- 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
-- else
-- player_card_info:SetRemainCardNumber(player.hand_count == 1)
-- if player.hand_count == 1 then
-- self.bgm_index = 2
-- end
-- end
player_card_info : UpdateHandPoker ( player.hand_list )
-- if self._room.curren_turn_seat ~= player.seat then
-- -- head_info:MarkBank(false)
-- 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
-- else
-- -- head_info:MarkBank(true)
-- end
2025-05-07 10:29:37 +08:00
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_score ' ) . text = ' + ' .. d2ad ( player.hp_info . total_hp )
else
head_info._view : GetController ( ' text_color ' ) . selectedIndex = 1
head_info._view : GetChild ( ' text_score ' ) . 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 )
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 " ) : GetChild ( " shengyu " ) . text = " 剩 " .. player.hand_count .. " 张 "
end
2025-05-15 18:56:36 +08:00
-- 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
player_card_info : UpdateHandPoker ( player.hand_list )
2025-05-14 19:56:12 +08:00
-- 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
2025-05-07 10:29:37 +08:00
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 )
2025-05-14 10:59:30 +08:00
self.result_view = EXResultView.new ( self._root_view , self._room . player_list , self._room . room_id , 0 ,
2025-05-07 10:29:37 +08:00
win_seat , 0 , remaincards )
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
2025-05-14 10:59:30 +08:00
local poker_item = UIPackage.CreateObject ( " Extend_Poker_SuoHa " , " poker6 " )
2025-05-07 10:29:37 +08:00
--local code = self:ChangeCodeByTo(card_n)
2025-05-14 10:59:30 +08:00
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/" .. card_n)
2025-05-07 10:29:37 +08:00
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2")
local card_code_obj
if DataManager.CurrenRoom . pai == 0 then
2025-05-14 10:59:30 +08:00
card_code_obj = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/ " .. card_n )
2025-05-07 10:29:37 +08:00
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
2025-05-14 10:59:30 +08:00
card_code_obj = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/ " .. card_n .. " _1 " )
2025-05-07 10:29:37 +08:00
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 ( )
2025-05-14 10:59:30 +08:00
self.rank_view = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/rank_eff " )
2025-05-07 10:29:37 +08:00
self._view : AddChild ( self.rank_view )
self.rank_view : Center ( )
self.rank_view : GetTransition ( " t0 " ) : Play ( )
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
2025-05-14 10:59:30 +08:00
local effect = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/eff_ " .. eff_code )
-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/eff2_1")
2025-05-07 10:29:37 +08:00
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
2025-05-14 10:59:30 +08:00
self.eff_feiji = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/eff_feiji " )
2025-05-07 10:29:37 +08:00
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:_Effect(type1, player)
-- if type1 < 7 and type1 ~= 4 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
-- else
-- eff_code = 6
-- end
-- local info = self._player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
2025-05-14 10:59:30 +08:00
-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/MovieClip" .. eff_code)
2025-05-07 10:29:37 +08:00
-- effect.touchable = false
-- --effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2)
-- pNode:AddChild(effect)
-- if type1 == 10 then --顺子
-- effect.x, effect.y = -400, -200
-- elseif type1 == 11 then --炸
-- effect.x, effect.y = -80, -225
-- elseif type1 == 4 then --连对
-- effect.x, effect.y = -400, -200
-- else
-- effect.x, effect.y = -157, -140
-- end
-- coroutine.start(function()
-- if type1== 10 or type1== 11 or type1== 4 then
-- -- body
-- coroutine.wait(2)
-- effect:Dispose()
-- else
-- coroutine.wait(1.2)
-- effect:Dispose()
-- end
-- end)
-- if eff_code ==3 then
-- coroutine.start(function()
-- coroutine.wait(1)
-- effect:Dispose()
-- end)
-- else
-- coroutine.start(function()
-- coroutine.wait(2)
-- effect:Dispose()
-- end)
-- end
-- 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 : 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 : 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 " )
2025-05-14 10:59:30 +08:00
local poker_obj = eff : GetChild ( " poker2 " )
2025-05-07 10:29:37 +08:00
local poker_back = eff : GetChild ( " di " )
poker_back.visible = false
2025-05-14 10:59:30 +08:00
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/" .. card)
2025-05-07 10:29:37 +08:00
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2")
local card_code_obj
if DataManager.CurrenRoom . pai == 0 then
2025-05-14 10:59:30 +08:00
card_code_obj = UIPackage.CreateObjectFromURL ( " ui://Extend_Poker_SuoHa/ " .. card )
2025-05-07 10:29:37 +08:00
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 : PlaySound ( sex , path )
local sex_path = ViewUtil.Sex_Chat [ sex ] -- 1 男 2 女
2025-05-14 10:59:30 +08:00
local sound_path = string.format ( " extend/poker2/suoha/sound/%s/%s.mp3 " , sex_path , path )
ViewUtil.PlaySound ( " SuoHa_PK " , sound_path )
2025-05-07 10:29:37 +08:00
end
function M : ChangeBgmMusic ( bgm_index )
if bgm_index == nil then
bgm_index = self.bgm_index
else
self.bgm_index = bgm_index
end
2025-05-14 10:59:30 +08:00
ViewUtil.PlayMuisc ( " SuoHa_PK " , string.format ( " extend/poker2/suoha/sound/bgm%d.mp3 " , 1 ) )
2025-05-07 10:29:37 +08:00
end
function M : OnPlayerEnter ( ... )
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.CloseModalWait ( )
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
PKMainView.Destroy ( self )
2025-05-14 10:59:30 +08:00
UIPackage.RemovePackage ( " extend/poker2/suoha/ui/Extend_Poker_SuoHa " )
2025-05-07 10:29:37 +08:00
end
return M