local SettingView = import('.main.ZPSettingView') local PlayerSelfCardInfoView = import('.PlayerSelfCardInfoView') local PlayerCardInfoView = import('.PlayerCardInfoView') local ZPMainView = import('.main.ZPMainView') local GameEvent = import('.FanPaoFa_GameEvent') local FanPaoFa_ResultView = import('.FanPaoFa_ResultView') local PlayerInfoView = import(".EXPlayerInfoView") local M = {} local Fix_Msg_Chat = { '在搞么的,出牌撒', '又掉线哒!', '和你打牌太有味了', '人呢?还搞不搞滴', '哈哈,对不住了', '稍等哈哈,马上就来', '不要走,决战到天亮', '牌打得不错嘛!', '今朝这个方位硬是不好', '不好意思临时有事,申请解散!' } --- Create a new ZZ_MainView function M.new() setmetatable(M, { __index = ZPMainView }) local self = setmetatable({}, { __index = M }) self.class = 'FanPaoFa_MainView' self._full = true self:init() return self end function M:getCardItem(card_1, card_2) if self._room.change_card_display ~= nil then return card_1 .. self._room.change_card_display .. card_2 else return card_1 .. '6_' .. card_2 end end function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat self._flag_fanpaofa = true ViewUtil.PlayMuisc('FanPaoFa_ZP', 'extend/zipai/fanpaofa/sound/bg.mp3') UIPackage.AddPackage('extend/zipai/fanpaofa/ui/Extend_Poker_FanPaoFa') local hx = 0 if _room.room_config.config.hunum == 2 then hx = 6 end if _room.room_config.config.hunum == 1 then hx = 10 end if _room.room_config.config.hunum == 0 then hx = 15 end ZPMainView.InitView(self, 'ui://Main_RunBeard/Main_' .. _room.room_config.people_num, false, false, 1.2, hx) self:PlayerChangeLineState() SettingView.onEXMainCallback = handler(self, self.UpdateCardDisplay) SettingView.onUpdataCardSizeCallback = handler(self, self.UpdateCardSize) for i = 1, #_room.player_list do local p = _room.player_list[i] local head = self._player_info[self:GetPos(p.seat)] if head._tex_score then head._tex_score.visible = true end head:UpdateScore() end if _room.playing or _room.curren_round > 0 then self:ReloadRoom() end self._view:GetController('jushu').selectedIndex = 1 self:setBtn() 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("player_info" .. i) _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end function M:setBtn() local rightpanel = self._view:GetChild('right_panel') local btn_rule = rightpanel:GetChild('btn_log') local gcm_chat = self._view:GetChild('gcm_chat') local _btn_chat = gcm_chat:GetChild('n1') _btn_chat:GetChild('icon').icon = 'ui://Main_RunBeard/chat_img' local btn_record = gcm_chat:GetChild('btn_record') btn_record:GetChild('icon').icon = 'ui://Main_RunBeard/yuyin_img' if btn_rule ~= nil then btn_rule.onClick:Set( function() if self.RuleView == nil or self.RuleView._is_destroy then self.RuleView = RoomInfoView.new(self._room) end self.RuleView:Show() end ) end local btn_setting = self._view:GetChild('btn_setting') btn_setting.onClick:Set( function() local _settingView = self:NewSettingView() _settingView.stateIndex = (self._room.curren_round >= 1 and self._allow_dissmiss) and 2 or 1 _settingView.cd_time = self.dismiss_room_cd_time _settingView:Show() local room = DataManager.CurrenRoom _settingView.onCallback:Add( function(context) local _gamectr = ControllerManager.GetController(GameController) if (room.CurnrenState == StateType.Ready) then _gamectr:LevelRoom( function(response) if (response.ReturnCode == 0) then ViewManager.ChangeView(ViewManager.View_Lobby) GameApplication.Instance:ShowTips('房间已解散!') end end ) else _gamectr:AskDismissRoom( function(res) ViewUtil.ErrorTip(res.ReturnCode, '') end ) end end ) end ) local tex_roomid = rightpanel:GetChild('tex_roomid') tex_roomid.text = self._room.room_id if self._room.room_config.isHidden and self._room.room_config.isHidden == 1 then tex_roomid.text = "000000" end end function M:NewPlayerCardInfoView(view, index) if index == 1 then return PlayerSelfCardInfoView.new(view, self) end return PlayerCardInfoView.new(view, self) end function M:closeTipOnTuoguan() if self._clearingView ~= nil then self._clearingView:Close() end self:__CloseTip() end function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _player_info = self._player_info local _gamectr = self._gamectr _gamectr:AddEventListener(GameEvent.EventXiPai, function(...) self._popEvent = true local arg = { ... } local currentPlayer1 = arg[1] local currentPlayer2 = arg[2] self._player_card_info[1]:HideDaNiao(0) if (currentPlayer1) then local xipaiCB = function() end self:PlayXiPai(xipaiCB) end if (currentPlayer2) then local xipaiCB2 = function() end self:PlayXiPai1(xipaiCB2) end end) _gamectr:AddEventListener(GameEvent.OnDaNiaoTips, function(...) self._popEvent = true local arg = { ... } local niao = arg[1] local reload = arg[2] if reload == 0 then self._leftcard = 1 self._leftcard = 1 local rightpanel = self._view:GetChild('right_panel') local tex_round = rightpanel:GetChild('tex_round') if tex_round ~= nil then tex_round.text = '第 ' .. _room.curren_round .. ' 局' end self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. ' 局 ' self._state.selectedIndex = 1 self:closeTipOnTuoguan() local list = _room.player_list for i = 1, #list do local p = list[i] p.hu_xi = 0 local _info = self._player_card_info[self:GetPos(p.seat)] _info:SetPlayer(p) local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) --info:UpdatePiao(-1) end end self._player_card_info[1]:ShwoDaNiao(niao) end) _gamectr:AddEventListener(GameEvent.OnEventDaNiao, function(...) self._popEvent = true local arg = { ... } local seat = arg[1] local niao = arg[2] if self.seat == seat then self._player_card_info[seat]:HideDaNiao(niao) end local head_info = self._player_info[self:GetPos(seat)] head_info:UpdateNiao(niao) end) _gamectr:AddEventListener( GameEvent.SendCards, function(...) self._popEvent = true self._leftcard = 1 self._leftcard = 1 local rightpanel = self._view:GetChild('right_panel') local tex_round = rightpanel:GetChild('tex_round') if tex_round ~= nil then tex_round.text = '第 ' .. _room.curren_round .. ' 局' end self._view:GetChild('tex_round').text = '第 ' .. _room.curren_round .. ' 局 ' self._state.selectedIndex = 1 self:closeTipOnTuoguan() local list = _room.player_list for i = 1, #list do local p = list[i] p.hu_xi = 0 local _info = self._player_card_info[self:GetPos(p.seat)] _info:SetPlayer(p) local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) --info._view:GetController('huxi').selectedIndex = 1 info._view:GetChild('huxi').text = p.hu_xi info._view:GetController('zhanji').selectedIndex = 1 info._view:GetChild('tex_jifen').text = p.total_score --d2ad(p.total_hp) info._view:GetChild('tex_jifen_text').text = "总胡息" --[[if _room.hpOnOff == 1 or _room:checkHpNonnegative() then if p.total_hp == nil then p.total_hp = 0 end info._view:GetController('zhanji').selectedIndex = 1 info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) info._view:GetChild('tex_jifen_text').text = "总胡息" end]] end local card_info = self._player_card_info[1] card_info:UpdateIsOnClick(false) card_info:InitHandCard(true) card_info:HideDaNiao(0) end ) _gamectr:AddEventListener( GameEvent.GetCard, function(...) local arg = { ... } local seat = arg[1] local card = arg[2] local _leftcard = arg[3] self._left_time = 15 self._tex_LeftCard.text = '剩余 ' .. _leftcard .. ' 张牌' local info = self._player_card_info[self:GetPos(seat)] print("lingmeng GetCard1") info:UpdateOutCardList(card, true, true, self:GetPos(seat)) if card ~= 0 then local p = _room:GetPlayerBySeat(seat) print("lingmeng baopai") -- self:PlaySound(p.self_user.sex, 'F_SaoChuan') self:PlaySound(p.self_user.sex, 'F_' .. card) print("lingmeng GetCard2", os.time()) coroutine.start( function() coroutine.wait(0.5) print("lingmeng GetCard2-1", os.time()) self._popEvent = true end ) else print("lingmeng GetCard3", os.time()) coroutine.start( function() coroutine.wait(0.5) print("lingmeng GetCard3-1", os.time()) self._popEvent = true info:ClearOutCard() end ) end end ) _gamectr:AddEventListener( GameEvent.AddCard, function(...) local arg = { ... } local seat = arg[1] local card = arg[2] local info = self._player_card_info[self:GetPos(seat)] coroutine.start( function() coroutine.wait(0.2) if info._area_outcard_list.numChildren > 0 then local outCard = info._area_outcard_list:GetChildAt(0) outCard:TweenMove(outCard:GlobalToLocal(info:GetFzMove()), 0.35) outCard:TweenScale(Vector2.New(0, 0), 0.35) end end ) coroutine.start( function() coroutine.wait(0.5) if seat == self._room.self_player.seat then info:InitHandCard(false) end info:ClearOutCard() self._popEvent = true end ) end ) _gamectr:AddEventListener( GameEvent.EventTurn, function(...) self._popEvent = true local arg = { ... } local seat = arg[1] local list = _room.player_list local readyNum = 0 for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('time').selectedIndex = 0 end local info = self._player_info[self:GetPos(seat)] info._view:GetController('time').selectedIndex = 1 end ) _gamectr:AddEventListener( GameEvent.OutHint, function(...) self._popEvent = true _room.curren_outcard_seat = _room.self_player.seat --printlog("jefe OutHint view>>>>",card) coroutine.start( function() coroutine.wait(0.5) local info = self._player_card_info[self:GetPos(_room.self_player.seat)] info:ChuPaiTiShi() end ) end ) _gamectr:AddEventListener( GameEvent.FangWei, function(...) self._popEvent = true local arg = { ... } local seat = arg[1] local card = arg[2] --self:__CloseTip() _room.curren_outcard_seat = _room.self_player.seat local _player_card_info = self._player_card_info --printlog("jefe FangWei view>>>>") local p = self._room:GetPlayerBySeat(seat) local info = self._player_card_info[self:GetPos(seat)] local fangwei_msg = MsgWindow.new(self._root_view, '放偎之后这局将不能再吃碰,是否确定', MsgWindow.MsgMode.OkAndCancel) local removeOutcard = self._player_card_info[1] fangwei_msg.onOk:Add( function() local _gamectr = ControllerManager.GetController(GameController) if _gamectr then _gamectr:SendFangPao(card) end end ) fangwei_msg.onCancel:Add( function(...) -- self:__CloseTip() --把牌弄回原位 -- info:ResetCards(card) if seat == self._room.self_player.seat then if seat == self._room.self_player.seat then info.outcard_button.btn_card.touchable = true info.outcard_button.btn_card.sortingOrder = 0 info.outcard_button.btn_card:GetChild("icon").icon = self:getCardItem( "ui://Main_RunBeard/201_", card) info:UpdateHandCardsPos() info:UpdateIsOnClick(true) end end end ) fangwei_msg:Show() end ) _gamectr:AddEventListener( GameEvent.OutCard, function(...) self._popEvent = true self:__CloseTip() self._left_time = 0 local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat local info = self._player_card_info[self:GetPos(seat)] self:PlaySound(p.self_user.sex, 'F_' .. card) if seat == self._room.self_player.seat then _room.curren_outcard_seat = -1 info:DeleteHandCard(card) info:UpdateIsOnClick(true) info:SendChangeCard() info:ChuPaiTiShi() end local list = _room.player_list for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('time').selectedIndex = 0 self._player_info[self:GetPos(p.seat)]._view:GetController("huxi").selectedIndex = 1 end self._view_showPalyerOutCardView = info._area_outcard_list info:UpdateOutCardList(card, true, false, self:GetPos(seat)) if self._leftcard == 1 then self._leftcard = 0 for i = 1, #_room.player_list do local p = _room.player_list[i] local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:UpdateFzList(p.fz_list, false, p.seat) end end end ) _gamectr:AddEventListener( GameEvent.QiCard, function(...) self:__CloseTip() self._left_time = 0 local arg = { ... } local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) local info = self._player_card_info[self:GetPos(seat)] info:PlayingOutCardAnima(card, self:GetPos(seat)) coroutine.start( function() coroutine.wait(0.2) self._popEvent = true info:ClearOutCard() p.DiceCard = 0 info:UpdateQiPai(p.outcard_list, false, seat) end ) end ) _gamectr:AddEventListener( GameEvent.FZTips, function(...) self._popEvent = true local arg = { ... } local _tip = arg[1] local _uid = arg[2] local _fptype = arg[3] self:__FangziTip(_tip, _uid, _fptype) end ) _gamectr:AddEventListener(GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener( GameEvent.ZPHuCard, function(...) self._popEvent = true self._left_time = 0 self:__CloseTip() local arg = { ... } local w = arg[1] local l = arg[2] local cards = arg[3] local info = self._player_card_info[self:GetPos(w)] -- info:UpdateHandCard() local url = 'ui://Extend_Poker_FanPaoFa/别人胡' local pNode = info._mask_liangpai local player = _room:GetPlayerBySeat(w) if w == _room.self_player.seat then url = 'ui://Extend_Poker_FanPaoFa/自己胡牌' pNode = self._view end self:PlaySound(player.self_user.sex, 'F_Hu') local he = UIPackage.CreateObjectFromURL(url) he:GetTransition('t2'):Play() if w == _room.self_player.seat then he:Center() end pNode:AddChild(he) coroutine.start( function() coroutine.wait(0.7) he:Dispose() end ) end ) _gamectr:AddEventListener( GameEvent.ZPResult1, function(...) self._popEvent = true --printlog("ZPResult111ssssssttteessssssttt") self._left_time = 0 local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list local x = {} --printlog("ZPResult111sssssstttee") self._hu_tip:FillData(x) --printlog("ZPResult111ssss6666") self:__CloseTip() --printlog("ZPResult111") if self._clearingView == nil then --printlog("ZPResult11122222") if liuju == true then self._clearingView = FanPaoFa_ResultView.new(self._view, 1) else self._clearingView = FanPaoFa_ResultView.new(self._view) end end coroutine.start( function() coroutine.wait(0.5) -- if self._clearingView._is_destroy then return end --printlog("ZPResult111qqqqqq") self._clearingView:Show() if _room.curren_round ~= _room.room_config.round then for i = 1, #data do local p = _room:GetPlayerBySeat(data[i].seat) local card_info = self._player_card_info[self:GetPos(p.seat)] local info = self._player_info[self:GetPos(p.seat)] p.total_score = data[i].total_score info._view:GetController('zhanji').selectedIndex = 1 info._view:GetChild('tex_jifen').text = p.total_score info._view:GetChild('tex_jifen_text').text = "总胡息" card_info:Clear() info:UpdateScore() end --printlog("ZPResult111sdddddd") local list = _room.player_list for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('time').selectedIndex = 0 end for i = 1, #_room.player_list do _room.self_player.handcard_list = {} _room.player_list[i].DiceCard = nil _room.player_list[i].hand_left_count = 20 _room.player_list[i].fz_list = {} _room.player_list[i].card_list = {} _room.player_list[i].outcard_list = {} _room.player_list[i].hu_xi = 0 end end end ) if _room.curren_round ~= _room.room_config.round then self._clearingView:InitData( 0, _room, result, nil, function(...) self._state.selectedIndex = 2 self._clearingView = nil end ) end end ) _gamectr:AddEventListener( GameEvent.ZPResult2, function(...) self._popEvent = true self._left_time = 0 local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] local data = result.info_list local x = {} self._hu_tip:FillData(x) self:__CloseTip() self:UnmarkSelfTuoguan() self._clearingView = FanPaoFa_ResultView.new() coroutine.start( function() coroutine.wait(0.5) self._clearingView:Show() end ) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end ) _gamectr:AddEventListener( GameEvent.FangPaoOk, function(...) self._popEvent = true self._left_time = 0 local arg = { ... } local seat = arg[1] local card = arg[2] --禁牌 把手上的牌都禁掉 -- local card_info = self._player_card_info[self:GetPos(seat)] -- card_info:banHandCards(self._room.self_player.card_list) end ) end function M:OutCard(card_item) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card_item) end --改变牌队形 function M:ChangeCards(list) local _gamectr = ControllerManager.GetController(GameController) if _gamectr then _gamectr:SendChangeCards(list) end end function M:__FangziTip(tip, _uid, fptype) local _gamectr = self._gamectr local _chipeng_tip = UIPackage.CreateObject('Main_RunBeard', 'Gcm_action_tips') self._chipeng_tip = _chipeng_tip local p = self._room.self_player --printlog("jefe __FangziTip>>>>",_uid) local _lit_fanzi = _chipeng_tip:GetChild('lit_fanzi') _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) local tip_hu = false local tip_fanpao = false local tip_id = 0; local count = #_tlist local zdhu = false local fpao = true for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] if td.type == 8 then tip_hu = true tip_id = td.id --自动放炮 if td.weight == 7 then zdhu = true end end if td.type == 6 and td.weight == 8 then fpao = false end end if fpao and zdhu then self:PlaySound(p.self_user.sex, 'F_DianPao') _gamectr:SendAction(tip_id) _chipeng_tip:Dispose() self._chipeng_tip = nil return end for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = 'ui://Main_RunBeard/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) btn_t.icon = 'ui://Main_RunBeard/newop_' .. td.type btn_t.data = { tip, td, tip_hu } btn_t.onClick:Set(self.__TipAction, self) end if p.hand_left_count ~= 0 then local _btn_pass = _lit_fanzi:AddItemFromPool('ui://Main_RunBeard/Btn_pass_new') _btn_pass.onClick:Set( function() if tip_hu then local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel) guo_msg.onOk:Add( function() _gamectr:SendAction(_uid) _chipeng_tip:Dispose() self._chipeng_tip = nil guo_msg:Close() end ) guo_msg:Show() else _gamectr:SendAction(_uid) _chipeng_tip:Dispose() self._chipeng_tip = nil end end ) end --禁止放跑 if fptype == 1 and tip_hu == false then _gamectr:SendAction(_uid) _chipeng_tip:Dispose() self._chipeng_tip = nil else self._view:AddChild(_chipeng_tip) _chipeng_tip:Center() _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 50 end end function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr local tip = data[1] local td = data[2] local tip_hu = data[3] local list = tip.tip_map_type[td.weight] if (#list > 1) or td.type == 1 then local chiflag = true for key, value in pairs(list) do if value['bi_list'] ~= nil then chiflag = false end end if #list > 1 then chiflag = false end if tip_hu == false and chiflag then _gamectr:SendAction(list[1]["id"]) self:__CloseTip() local info = self._player_card_info[1] info:UpdateIsOnClick(false) return end self:_ChiView( list, tip_hu, function(id) if tip_hu and td.type ~= 8 then local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel) guo_msg.onOk:Add( function() _gamectr:SendAction(id) guo_msg:Close() self:__CloseTip() local info = self._player_card_info[1] info:UpdateIsOnClick(false) end ) guo_msg:Show() else _gamectr:SendAction(id) self:__CloseTip() local info = self._player_card_info[1] info:UpdateIsOnClick(false) end end ) -- self._chipeng_tip.visible = false return end if tip_hu and td.type ~= 8 then local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel) guo_msg.onOk:Add( function() _gamectr:SendAction(td.id) guo_msg:Close() local info = self._player_card_info[1] info:UpdateIsOnClick(false) if (self._chipeng_tip == nil) then return end self._chipeng_tip:Dispose() self._chipeng_tip = nil end ) guo_msg:Show() else _gamectr:SendAction(td.id) local info = self._player_card_info[1] info:UpdateIsOnClick(false) if (self._chipeng_tip == nil) then return end self._chipeng_tip:Dispose() self._chipeng_tip = nil end end function M:_ChiView(tip_list, tip_hu, callback) local _pop_tip_choice = UIPackage.CreateObject('Main_RunBeard', 'Pop_tip_choice') local list_choose = _pop_tip_choice:GetChild('Lst_choose') _pop_tip_choice:GetChild('dibtn').onClick:Add( function() _pop_tip_choice:Dispose() end ) list_choose:RemoveChildrenToPool() for i = 1, #tip_list do if tip_list[i].weight ~= 4 then local item_choose = list_choose:AddItemFromPool() item_choose:GetChild('card' .. 2).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].OpCard[1])) item_choose:GetChild('card' .. 3).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].OpCard[2])) item_choose:GetChild('card' .. 1).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', tip_list[i].card)) item_choose.onClick:Add( function() for k = 1, list_choose.numChildren do list_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 end item_choose:GetController('zhong').selectedIndex = 1 if tip_list[i].bi_list == nil then callback(tip_list[i].id) else self.bilist = {} self._chiid = tip_list[i].id self:CheckRatioCard(tip_list[i].bi_list, 1, tip_list[i].card) end end ) end end list_choose:ResizeToFit(#tip_list) _pop_tip_choice:GetChild('di1').width = list_choose.width + 110 _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, -100) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:CheckRatioCard(_tiplist, index, chicard, _biid, list) if _biid ~= nil then self.bilist = {} self.bilist[#self.bilist + 1] = _biid end if self._pop_tip_choice == nil then -- statements return end self._pop_tip_choice:GetController('bipai').selectedIndex = index local Bilist_choose = self._pop_tip_choice:GetChild('Bi_Lst_choose' .. index) Bilist_choose:RemoveChildrenToPool() for i = 1, #_tiplist do local item = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Comp_choose') local item_choose = Bilist_choose:AddChild(item) item_choose:GetChild('card' .. 2).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', _tiplist[i].opcard[1])) item_choose:GetChild('card' .. 3).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', _tiplist[i].opcard[2])) item_choose:GetChild('card' .. 1).icon = UIPackage.GetItemURL('Main_RunBeard', self:getCardItem('201_', chicard)) item_choose:GetController('zhong').selectedIndex = 0 item_choose.onClick:Add( function() for k = 1, Bilist_choose.numChildren do Bilist_choose:GetChildAt(k - 1):GetController('zhong').selectedIndex = 0 end item_choose:GetController('zhong').selectedIndex = 1 if _tiplist[i].bi_list == nil then if index == 1 then self.bilist = {} end self.bilist[#self.bilist + 1] = i - 1 if tip_hu then local guo_msg = MsgWindow.new(self._root_view, '确定取消胡吗?', MsgWindow.MsgMode.OkAndCancel) guo_msg.onOk:Add( function() self._gamectr:SendAction(self._chiid, self.bilist) guo_msg:Close() self:__CloseTip() local info = self._player_card_info[1] info:UpdateIsOnClick(false) end ) guo_msg:Show() else self._gamectr:SendAction(self._chiid, self.bilist) self:__CloseTip() local info = self._player_card_info[1] info:UpdateIsOnClick(false) end else self:CheckRatioCard(_tiplist[i].bi_list, 2, chicard, i - 1, #_tiplist) end end ) end Bilist_choose:ResizeToFit(#_tiplist) self._pop_tip_choice:GetChild('di' .. index + 1).width = Bilist_choose.width + 110 end -- lua table 深拷贝 function M:deepcopy(object) local lookup_table = {} local function _copy(object) if type(object) ~= 'table' then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for index, value in pairs(object) do new_table[_copy(index)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end return _copy(object) end function M:OnFangziAction(...) local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] local num = arg[3] local flag_pengPao = arg[4] if fz.type == RB_FZType.Peng or fz.type == RB_FZType.Chi or fz.type == RB_FZType.Bi then self:__CloseTip() end if (player == self._room.self_player) then local info = _player_card_info[self:GetPos(player.seat)] info:UpdateIsOnClick(false) end local info = _player_card_info[self:GetPos(player.seat)] -- if fz.type == RB_FZType.Wei or fz.type == RB_FZType.ChouWei then -- coroutine.start( -- function() -- coroutine.wait(1.2) -- info:UpdateFzList(player.fz_list, true, player.seat) -- end) -- else -- info:UpdateFzList(player.fz_list, true, player.seat) --更新放子数组 -- end if (player == self._room.self_player) then if fz.type == RB_FZType.Chi then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end elseif fz.type == RB_FZType.Bi then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end info:DeleteHandCard(fz.card) elseif fz.type == RB_FZType.Peng then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end elseif fz.type == RB_FZType.Kan then if #fz.opcard == 2 then info:InitHandCard(false) end info:UpdateKan(fz.card) elseif fz.type == RB_FZType.Wei then --显示wei 的牌 coroutine.start( function() coroutine.wait(1.2) for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end) elseif fz.type == RB_FZType.ChouWei then --[[ for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end]] coroutine.start( function() coroutine.wait(1.2) for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end) elseif fz.type == RB_FZType.Pao then if num > 0 then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end elseif fz.type == RB_FZType.Ti then if num > 0 then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end end coroutine.start( function() coroutine.wait(0.3) if fz.type ~= RB_FZType.Kan then info:SendChangeCard() end end ) end -- if false then if fz.type ~= RB_FZType.Kan and fz.type ~= RB_FZType.Bi then --printlog("jefe self RB_FZType 2=======") local info = _player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai local effect = UIPackage.CreateObject('Main_RunBeard', 'FzEffect') if fz.type == RB_FZType.Peng then -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "peng") self:PlaySound(player.self_user.sex, 'F_Peng') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'peng') elseif fz.type == RB_FZType.Chi then -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "chi") --printlog("jefe self RB_FZType 3=======") self:PlaySound(player.self_user.sex, 'F_Chi') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'chi') --printlog("jefe self RB_FZType 4=======") elseif fz.type == RB_FZType.Wei then -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "wei") -- self:PlaySound(player.self_user.sex, 'F_' .. fz.card) -- info:UpdateOutCardList(fz.card, true, true, fz.from_seat) -- coroutine.start( -- function() -- coroutine.wait(1.0) -- info:PlayingOutCardAnima() self:PlaySound(player.self_user.sex, 'F_GuoSao') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'wei') effect.touchable = false effect.x, effect.y = -250, -200 effect:GetTransition('t0'):Play() pNode:AddChild(effect) -- end) coroutine.start( function() coroutine.wait(0.7) effect:Dispose() end ) elseif fz.type == RB_FZType.ChouWei then -- self:PlaySound(player.self_user.sex, 'F_' .. fz.card) -- info:UpdateOutCardList(fz.card, true, true, fz.from_seat) -- coroutine.start( -- function() -- coroutine.wait(1.2) -- info:PlayingOutCardAnima() self:PlaySound(player.self_user.sex, 'F_GuoSao') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'wei') effect.touchable = false effect.x, effect.y = -250, -200 effect:GetTransition('t0'):Play() pNode:AddChild(effect) -- end) coroutine.start( function() coroutine.wait(0.7) effect:Dispose() end ) elseif fz.type == RB_FZType.Pao then -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "pao") self:PlaySound(player.self_user.sex, 'F_KaiDuo') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'pao') elseif fz.type == RB_FZType.Ti then -- self:PlaySound(player.self_user.sex, 'F_' .. fz.card) -- info:UpdateOutCardList(fz.card, true, true, fz.from_seat) effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeard', 'ti') effect.touchable = false effect.x, effect.y = -250, -200 effect:GetTransition('t0'):Play() pNode:AddChild(effect) -- coroutine.start( -- function() -- coroutine.wait(1.2) print("lingmeng tiqi") self:PlaySound(player.self_user.sex, 'F_SaoChuan') -- info:PlayingOutCardAnima() -- end) coroutine.start( function() coroutine.wait(2) effect:Dispose() end ) -- effect:GetChild("icon2").icon = UIPackage.GetItemURL("Main_RunBeard", "ti") end if fz.type ~= RB_FZType.Wei and fz.type ~= RB_FZType.ChouWei then effect.touchable = false effect.x, effect.y = -250, -200 effect:GetTransition('t0'):Play() pNode:AddChild(effect) coroutine.start( function() coroutine.wait(0.4) effect:Dispose() end ) end end if (player == self._room.self_player) then coroutine.start( function() coroutine.wait(0.5) local info = _player_card_info[self:GetPos(player.seat)] info:ShowHuTip() end ) end if fz.type ~= RB_FZType.Kan then local time = 0.01 if fz.type == RB_FZType.Wei or fz.type == RB_FZType.ChouWei then time = 0.3 end local removeOutcard = _player_card_info[self:GetPos(fz.from_seat)] coroutine.start( function() coroutine.wait(time) local p = self._room:GetPlayerBySeat(fz.from_seat) if p.DiceCard ~= nil and fz.active_card == p.DiceCard then local outCard if removeOutcard._area_outcard_list.numChildren == 0 then for i = 1, self._room.maxPlayers do if _player_card_info[i]._area_outcard_list.numChildren > 0 then outCard = _player_card_info[i]._area_outcard_list:GetChildAt(0) end end else outCard = removeOutcard._area_outcard_list:GetChildAt(0) end if flag_pengPao then outCard:TweenMove(outCard:GlobalToLocal(info:GetFzMove()) - Vector2.New(outCard.width, 0), 0.25) outCard:TweenScale(Vector2.New(0, 0), 0.25) else outCard:TweenMove(outCard:GlobalToLocal(info:GetFzMove()) - Vector2.New(outCard.width, 0), 0.25) outCard:TweenScale(Vector2.New(0, 0), 0.25) end p.DiceCard = nil end end ) coroutine.start( function() coroutine.wait(0.2 + time) removeOutcard:ClearOutCard() info:UpdateFzList(player.fz_list, true, player.seat, flag_pengPao) --更新放子数组 end ) end local list = self._room.player_list for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info._view:GetChild('huxi').text = p.hu_xi end local time = 0.01 if fz.type ~= RB_FZType.Kan then time = flag_pengPao and 0.3 or 0.7 if fz.type == RB_FZType.Wei or fz.type == RB_FZType.ChouWei then time = time + 0.3 end end coroutine.start( function() print("lingmeng OnFangziAction", time, os.time()) coroutine.wait(time) self._popEvent = true local info = _player_card_info[1] info:UpdateIsOnClick(true) end ) --printlog("seft rbtpe4") end function M:ReloadRoom() local _gamectr = self._gamectr local room = self._room if not room.playing then self._state.selectedIndex = 2 else self._state.selectedIndex = 1 end if room.discard == 0 then self._leftcard = 1 else self._leftcard = 0 end for i = 1, #room.player_list do local p = room.player_list[i] if p.seat == room.banker_seat then local head = self._player_info[self:GetPos(p.seat)] head:MarkBank(true) end if p.ready then self._player_info[self:GetPos(p.seat)]:Ready(true) else self._player_info[self:GetPos(p.seat)]:Ready(false) end if self._state.selectedIndex == 1 then local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('huxi').selectedIndex = 1 info._view:GetChild('huxi').text = p.hu_xi info._view:GetController('zhanji').selectedIndex = 1 info._view:GetChild('tex_jifen').text = p.total_score -- d2ad(p.total_hp) info._view:GetChild('tex_jifen_text').text = "总胡息" end local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:UpdateQiPai(p.outcard_list) card_info:UpdateFzList(p.fz_list, false, p.seat) if p.DiceCard ~= nil and p.DiceCard ~= 0 then card_info:UpdateOutCardList(p.DiceCard) end if DataManager.CurrenRoom.curren_outcard_seat == p.seat then local info = self._player_info[self:GetPos(p.seat)] info._view:GetController('time').selectedIndex = 1 end if p.seat == self._room.self_player.seat then card_info:ChuPaiTiShi() if self._room.self_player.card_list ~= nil and #self._room.self_player.handcard_list == #self._room.self_player.card_list then local _list = self:deepcopy(self._room.self_player.card_list) local cards = {} for i = 1, #_list do cards[#cards + 1] = _list[i].card_item end table.sort(cards, ViewUtil.HandCardSort) table.sort(self._room.self_player.handcard_list, ViewUtil.HandCardSort) local isNot = false for i = 1, #cards do if cards[i] ~= self._room.self_player.handcard_list[i] then isNot = true end end if isNot == true then card_info:InitHandCard(false) else card_info:UpdateHandCards(self._room.self_player.card_list) end else card_info:InitHandCard(false) end -- card_info:ChuPaiTiShi() card_info:ShowHuTip() for i = 1, #p.fz_list do if p.fz_list[i].type == RB_FZType.Kan then card_info:UpdateKan(3, p.fz_list[i].card) end end end end self._tex_LeftCard.text = '剩余 ' .. room.left_count .. ' 张牌' local rightpanel = self._view:GetChild('right_panel') local tex_round = rightpanel:GetChild('tex_round') if tex_round ~= nil then tex_round.text = '第 ' .. room.curren_round .. ' 局' end self._view:GetChild('tex_round').text = '第 ' .. room.curren_round .. ' 局 ' end function M:PlayChatSound(sex, chat_index) local sex_path = ViewUtil.Sex_Chat[sex] local path1 = string.format('extend/zipai/fanpaofa/sound/%s/chat_%s.mp3', sex_path, tostring(chat_index)) ViewUtil.PlaySound('ChangDe_ZP', path1) end function M:PlaySound(sex, path) local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 local sound_path = string.format('extend/zipai/fanpaofa/sound/%s/%s.mp3', sex_path, path) ViewUtil.PlaySound('ChangDe_ZP', sound_path) end function M:__CloseTip() if (self._chipeng_tip) then self._chipeng_tip:Dispose() self._chipeng_tip = nil end if (self._pop_tip_choice) then self._pop_tip_choice:Dispose() self._pop_tip_choice = nil end end function M:Destroy() ZPMainView.Destroy(self) UIPackage.RemovePackage('extend/zipai/fanpaofa/ui/Extend_Poker_FanPaoFa') end return M