1557 lines
57 KiB
Lua
1557 lines
57 KiB
Lua
---
|
|
--- Created by 谌建军.
|
|
--- DateTime: 2017/12/18 9:41
|
|
---
|
|
local PKMainView = import("main.poker.PKMainView")
|
|
local RunFast_PlayerPokerInfoView = import(".RunFast_PlayerPokerInfoView")
|
|
local RunFast_PlayerSelfPokerInfoView = import(".RunFast_PlayerSelfPokerInfoView")
|
|
local RunFast_GameEvent = import(".RunFast_GameEvent")
|
|
local RunFast_ResultView = import(".RunFast_ResultView")
|
|
local RunFast_RightPanelView = import(".RunFast_RightPanelView")
|
|
local PlayerInfoView = import(".EXPlayerInfoView")
|
|
local TableBG = import('Game.Data.TableBG')
|
|
local M = {}
|
|
function M.new()
|
|
setmetatable(M, { __index = PKMainView })
|
|
local self = setmetatable({}, { __index = M })
|
|
self.class = "RunFast_MainView"
|
|
self._full = true
|
|
self:init()
|
|
self._gamectr = ControllerManager.GetController(GameController)
|
|
return self
|
|
end
|
|
|
|
local default_bg = 1
|
|
local bg_config = {
|
|
{ id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1' },
|
|
{ id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2' },
|
|
{ id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3' }
|
|
}
|
|
|
|
function M:InitView(url)
|
|
local room = self._room
|
|
UIPackage.AddPackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew")
|
|
PKMainView.InitView(self, "ui://Extend_Poker_RunFastNew/RunFast_Main_" .. room.room_config.people_num, nil, 1,
|
|
default_bg, bg_config, nil, "ui://Extend_Poker_RunFastNew/SettingWindow1")
|
|
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 = RunFast_RightPanelView.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.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
|
|
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("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
|
|
|
|
--打鸟
|
|
if self._view:GetChild('btn_daNiao') then
|
|
self._view:GetChild('btn_daNiao').onClick:Set(function()
|
|
self._gamectr:SendDaNiaoAction(1)
|
|
self._ctr_action.selectedIndex = 0
|
|
end)
|
|
end
|
|
if self._view:GetChild('btn_buDaNiao') then
|
|
self._view:GetChild('btn_buDaNiao').onClick:Set(function()
|
|
self._gamectr:SendDaNiaoAction(0)
|
|
self._ctr_action.selectedIndex = 0
|
|
end)
|
|
end
|
|
|
|
self._view:GetChild('btn_leave_lobby').onClick:Set(function()
|
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|
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 RunFast_PlayerSelfPokerInfoView.new(tem, self)
|
|
end
|
|
return RunFast_PlayerPokerInfoView.new(tem, self)
|
|
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)
|
|
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(...)
|
|
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(...)
|
|
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(RunFast_GameEvent.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"):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.CloseModalWait()
|
|
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(RunFast_GameEvent.OnMingCard, function(...)
|
|
local arg = { ... }
|
|
local card = arg[1]
|
|
self.ctr_state.selectedIndex = 1
|
|
self.ctr_card_eff.selectedIndex = 1
|
|
self:PlayCardEff(card)
|
|
end)
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.OnInitCard, function(...)
|
|
local arg = { ... }
|
|
local round = arg[1]
|
|
local cardlist = arg[2]
|
|
|
|
|
|
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:UpdateRound(round)
|
|
ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/runfast/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"):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)
|
|
|
|
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, true, 1)
|
|
else
|
|
card_info:InitPoker(cardlist, true)
|
|
end
|
|
else
|
|
--card_info:UpdateHandPoker(#cardlist,true,false) --todo
|
|
--card_info:UpdateRemainCard(#cardlist,true)
|
|
end
|
|
end
|
|
end)
|
|
|
|
|
|
-- _gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.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]
|
|
card_info:SetOutCardInfo(nil, false)
|
|
-- if self.MypokerList ~= nil then
|
|
-- -- body
|
|
-- card_info:Clear()
|
|
-- card_info:InitPoker(self.MypokerList, false)
|
|
-- self.MypokerList = nil
|
|
-- end
|
|
end
|
|
self._left_time = 20
|
|
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
|
|
end)
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.OnPlaySucc, function(...)
|
|
local arg = { ... }
|
|
local p = arg[1]
|
|
local card_number = arg[2]
|
|
local cardstype = arg[3]
|
|
local num = arg[4]
|
|
local otherList = arg[5]
|
|
local length = arg[6]
|
|
self.ctr_time.selectedIndex = 0
|
|
|
|
local index = self:GetPos(p.seat)
|
|
if index == 1 then
|
|
self.caozuo = 0
|
|
end
|
|
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"):GetChild("shengyu").text = "剩" .. card_number .. "张"
|
|
end
|
|
end
|
|
local card_info = self._player_card_info[index]
|
|
card_info:SetOutCardInfo(p.out_card_list, false, true)
|
|
for i = 1, #otherList do
|
|
local other_seat = otherList[i]
|
|
local other_card_info = self._player_card_info[self:GetPos(other_seat)]
|
|
other_card_info:SetOutCardBlack()
|
|
end
|
|
|
|
if index == 1 then
|
|
card_info:DeleteHandCards(p.out_card_list)
|
|
else
|
|
card_info:SetRemainCardNumber(card_number == 1)
|
|
--card_info:UpdateHandPoker(card_number,false,false) -- todo
|
|
end
|
|
if self._room.is_new_bout == true then
|
|
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)]
|
|
if p.seat ~= player.seat then
|
|
card_info_i:SetOutCardInfo(nil, false)
|
|
end
|
|
end
|
|
-- card_info:PlayCardTypeEff(cardstype)
|
|
-- if cardstype~=12 then
|
|
-- -- body
|
|
|
|
|
|
-- if cardstype==10 and length>=6 then
|
|
-- -- card_info_i
|
|
-- local chuan = UIPackage.CreateObject("Extend_Poker_RunFast", "chuan1")
|
|
-- local card_info_i = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
-- card_info_i._mask_liangpai:AddChild(chuan)
|
|
-- chuan:GetChild("n0").asMovieClip.playing = true
|
|
-- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/sunzi.mp3")
|
|
-- coroutine.start(function()
|
|
-- coroutine.wait(1.5)
|
|
-- if chuan~=nil then
|
|
-- -- body
|
|
-- chuan:Dispose()
|
|
-- end
|
|
|
|
-- end)
|
|
|
|
-- else
|
|
-- self:_Effect(cardstype, p)
|
|
-- end
|
|
-- end
|
|
self:_Effect(cardstype, p)
|
|
else
|
|
if cardstype == 11 and cardstype ~= 12 then
|
|
self:_Effect(cardstype, p)
|
|
end
|
|
end
|
|
self:PlaySound(p.self_user.sex, self:GetSoundFileName(cardstype, num, self._room.is_new_bout))
|
|
if card_number == 1 then
|
|
--self:ChangeBgmMusic(2)
|
|
self:ChangeBgmMusic(1)
|
|
if self._cor_sound ~= nil then
|
|
coroutine.stop(self._cor_sound)
|
|
end
|
|
self._cor_sound = nil
|
|
self._cor_sound = coroutine.start(function()
|
|
coroutine.wait(1)
|
|
self:PlaySound(p.self_user.sex, "card_1")
|
|
end)
|
|
end
|
|
end)
|
|
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.OnPassSucc, function(...)
|
|
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
|
|
card_info:SetOutCardInfo(nil, true)
|
|
self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4))
|
|
end)
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.OnErrorTip, function(...)
|
|
local arg = { ... }
|
|
local error_str = arg[1]
|
|
self._player_card_info[1]:ErrorTip(error_str)
|
|
-- self._player_card_info[1]:ResetPoker()
|
|
end)
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.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(RunFast_GameEvent.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 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]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts)
|
|
end)
|
|
-- 托管
|
|
_gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.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")
|
|
|
|
if self.MypokerList ~= nil then
|
|
-- body
|
|
local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)]
|
|
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 remaincards then
|
|
-- body
|
|
local newremaincards = _gamectr:ChangeCodeByFrom(remaincards, true)
|
|
table.sort(remaincards)
|
|
for i = #newremaincards, 1, -1 do
|
|
coroutine.start(function()
|
|
coroutine.wait(0.01)
|
|
|
|
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_RunFastNew", "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 = nil
|
|
if DataManager.CurrenRoom.pai == 0 then
|
|
if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
|
|
-- body
|
|
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n ..
|
|
"_1")
|
|
else
|
|
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n)
|
|
end
|
|
else
|
|
if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
|
|
-- body
|
|
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n ..
|
|
"_2")
|
|
else
|
|
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2")
|
|
end
|
|
end
|
|
if card_code_obj ~= nil then
|
|
card_code_obj:SetScale(0.6, 0.6)
|
|
if poker_item ~= nil then
|
|
poker_item:AddChild(card_code_obj)
|
|
otherpoker_list:AddChild(poker_item)
|
|
end
|
|
end
|
|
end)
|
|
end
|
|
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()
|
|
-- 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_RunFastNew/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("RunFastNew_PK", "base/common/sound/win new.mp3")
|
|
end
|
|
-- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_RunFastNew/Spring" or "ui://Extend_Poker_RunFastNew/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_RunFastNew/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)]
|
|
local card_info = self._player_card_info[self:GetPos(player.seat)]
|
|
if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then
|
|
p.hp_info = player.hp_info
|
|
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
|
|
card_info:PlayScore(d2ad(player.hp_info.round_actual_hp), false, win_seat == player.seat)
|
|
else
|
|
local rt = 1
|
|
if self._room.hpOnOff == 1 then
|
|
rt = self._room.score_times
|
|
end
|
|
if over == 1 and self._room.hpOnOff == 1 then
|
|
head_info:UpdateScore(player.score / 10) --不可负分
|
|
else
|
|
head_info:UpdateScore(player.score * rt)
|
|
end
|
|
card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat)
|
|
end
|
|
|
|
|
|
if player.seat ~= self._room.self_player.seat then
|
|
card_info:UpdateHandPoker(player.cards, false, true)
|
|
card_info:SetRemainCardNumber(false)
|
|
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
|
|
|
|
self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0,
|
|
remaincards)
|
|
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
|
|
|
|
-- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow")
|
|
-- _actionView.icon = "ui://Common/btn_comfirm"
|
|
-- _actionView.onClick:Set(function ()
|
|
-- --local _gamectr = ControllerManager.GetController(GameController)
|
|
-- _gamectr:ConformToNextGame()
|
|
-- _actionView:Dispose()
|
|
-- end)
|
|
-- _actionView.xy = Vector2(900, 625)
|
|
-- self._view:AddChild(_actionView)
|
|
-- else
|
|
-- coroutine.wait(4)
|
|
-- self.result_view = RunFast_ResultView.new(self._root_view,info,self._room.room_id)
|
|
-- self.result_view:Show()
|
|
-- end
|
|
end)
|
|
if over == 1 then
|
|
-- body
|
|
self:UnmarkSelfTuoguan()
|
|
ControllerManager.ChangeController(LoddyController)
|
|
end
|
|
end)
|
|
|
|
_gamectr:AddEventListener(RunFast_GameEvent.OnResultByDissolve, function(...)
|
|
local arg = { ... }
|
|
local over = arg[1]
|
|
local info = arg[2]
|
|
local winseat = arg[3]
|
|
local dissolve = arg[4]
|
|
|
|
self.result_view = RunFast_ResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, nil)
|
|
self.result_view:Show()
|
|
ControllerManager.ChangeController(LoddyController)
|
|
self:UnmarkSelfTuoguan()
|
|
end)
|
|
|
|
-- 确定开始下一局 成功
|
|
_gamectr:AddEventListener(RunFast_GameEvent.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(RunFast_GameEvent.OnDaNiao, function(...)
|
|
local arg = { ... }
|
|
-- local seat = arg[1]
|
|
-- local piao = arg[2]
|
|
-- local head_info = self._player_info[self:GetPos(1)]
|
|
self._ctr_action.selectedIndex = 3
|
|
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)
|
|
|
|
self:UpdateRound(self._room.curren_round)
|
|
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_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
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
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
|
|
|
|
|
|
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 = RunFast_ResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0,
|
|
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
|
|
local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "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_RunFastNew/" .. 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 == 1 then
|
|
-- body
|
|
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. 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_RunFastNew/rank_eff")
|
|
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
|
|
local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_" .. eff_code)
|
|
-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/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_RunFastNew/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:_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
|
|
-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code)
|
|
|
|
-- 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)
|
|
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")
|
|
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_RunFastNew/" .. 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:PlaySound(sex, path)
|
|
local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女
|
|
local sound_path = string.format("extend/poker/runfast/sound/%s/%s.mp3", sex_path, path)
|
|
ViewUtil.PlaySound("RunFastNew_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("RunFastNew_PK", string.format("extend/poker/runfast/sound/bgm%d.mp3", 1))
|
|
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)
|
|
UIPackage.RemovePackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew")
|
|
end
|
|
|
|
return M
|