local SettingView = import('.main.ZPSettingView') local PlayerSelfCardInfoView = import('.PlayerSelfCardInfoView') local PlayerCardInfoView = import('.PlayerCardInfoView') local ZPMainView = import('.main.ZPMainView') local GameEvent = import('.RunBeard_GameEvent') local RunBeard_ResultView = import('.RunBeard_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 = 'RunBeard_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 .. '1_' .. card_2 end end function M:InitView(url) local _room = self._room self.Fix_Msg_Chat = Fix_Msg_Chat ViewUtil.PlayMuisc('FuLuShou_ZP', 'extend/zipai/fulushou/sound/bgMain.mp3') UIPackage.AddPackage('extend/zipai/fulushou/ui/Extend_Poker_FuLuShou') ZPMainView.InitView(self, 'ui://Main_RunBeardMaJiang/Main_' .. _room.room_config.people_num, false, false, 1.2, 8) 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)] 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: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_RunBeardMaJiang/chat_img' local btn_record = gcm_chat:GetChild('btn_record') btn_record:GetChild('icon').icon = 'ui://Main_RunBeardMaJiang/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: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: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.TuoGuanTipsEvt,function( ... ) local arg = {...} local isOpen=arg[1] local self_Player=_player_info[self:GetPos( _room.self_player.seat)] --local entrust_time=DataManager.CurrenRoom.entrust_time --printlog("11111111111111",entrust_time) if self_Player then local btn_TG=self_Player._view:GetChild("Btn_tuoguan") if btn_TG then local tempTG=self_Player._view:GetController("tuoguan") if tempTG then if isOpen then tempTG.selectedIndex=1 else tempTG.selectedIndex=0 end end btn_TG.onClick:Set( function() local tuoguan_msg = MsgWindow.new(self._root_view, '确定托管吗?', MsgWindow.MsgMode.OkAndCancel) tuoguan_msg.onOk:Add( function() self._gamectr:OnEvtOpenGameHuTuoGtips(true) tuoguan_msg:Close() tempTG.selectedIndex=0 end ) tuoguan_msg:Show() end) end end end) _gamectr:AddEventListener(GameEvent.EventXiPai,function( ... ) local arg = {...} local currentPlayer1=arg[1] local currentPlayer2=arg[2] if self._player_card_info[1].HidePiao then self._player_card_info[1]:HidePiao() end 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(GameEvent.OnPiaoTips, function(...) local arg = {...} local piao = arg[1] local reload = arg[2] local last_piao = arg[3] local last_winer = arg[4] if piao >0 and piao <3 then piao=1 end if reload==0 then --self._popEvent = false 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 .. '/' .. _room.room_config.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) info._view:GetController('huxi').selectedIndex = 1 info._view:GetChild('huxi').text ="" --p.hu_xi info._view:GetController('zhanji').selectedIndex = 0 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) end end end --local card_info = self._player_card_info[1] --card_info:UpdateIsOnClick(false) --card_info:InitHandCard(true) printlog("飘分提示==>>>") if last_winer==1 then self._player_card_info[1]:ShowSpecialPiao(piao,last_piao) else self._player_card_info[1]:ShowPiao(piao) end end) _gamectr:AddEventListener(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( GameEvent.SendCards, function(...) self._popEvent = false 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 .. '/' .. _room.room_config.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 = 0 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) end end local card_info = self._player_card_info[1] card_info:UpdateIsOnClick(false) card_info:InitHandCard(true) end ) _gamectr:AddEventListener( GameEvent.GetCard, function(...) self._popEvent = false 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)] info:UpdateOutCardList(card, true, true, self:GetPos(seat)) if card ~= 0 then local p = _room:GetPlayerBySeat(seat) --self:PlaySound(p.self_user.sex, 'F_' .. card) self._popEvent = false coroutine.start( function() coroutine.wait(0.2) if seat == self._room.self_player.seat then info:InitHandCard(false) info:ChuPaiTiShi() end self._popEvent = true info:ClearOutCard() end ) end end ) _gamectr:AddEventListener( GameEvent.ShowremainCard, function(...) local arg = {...} local seat = arg[1] local _leftcard = arg[2] self._tex_LeftCard.text = '剩余 ' .. _leftcard .. ' 张牌' end ) _gamectr:AddEventListener( GameEvent.AddCard, function(...) local arg = {...} local seat = arg[1] local card = arg[2] self._popEvent = false local info = self._player_card_info[self:GetPos(seat)] 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(...) 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(...) _room.curren_outcard_seat = _room.self_player.seat 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.OutCard, function(...) self._popEvent = false 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:InitHandCard(false) 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 end 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 ------ --if(not p.outcard_list) then p.outcard_list = {} end --p.outcard_list[#p.outcard_list+1] = card coroutine.start( function() coroutine.wait(0.5) local info = self._player_card_info[self:GetPos(seat)] info:PlayingOutCardAnima(p.DiceCard) p.DiceCard = 0 info:UpdateQiPai(p.outcard_list, true, seat) self._popEvent = true end ) end ) _gamectr:AddEventListener( GameEvent.QiCard, function(...) self:__CloseTip() self._popEvent = false self._left_time = 0 local arg = {...} local seat = arg[1] local card = arg[2] local p = _room:GetPlayerBySeat(seat) --p.DiceCard=card local info = self._player_card_info[self:GetPos(seat)] info:PlayingOutCardAnima(p.DiceCard) p.DiceCard = 0 info:UpdateQiPai(p.outcard_list, true, seat) self._popEvent = true end ) _gamectr:AddEventListener( GameEvent.FZTips, function(...) local arg = {...} local _tip = arg[1] --local _uid = arg[2] self:__FangziTip(_tip) end ) _gamectr:AddEventListener(GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener( GameEvent.ZPHuCard, function(...) self._left_time = 0 self:__CloseTip() self._popEvent = false 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_FuLuShou/别人胡' local pNode = info._mask_liangpai local player = _room:GetPlayerBySeat(w) if w == _room.self_player.seat then url = 'ui://Extend_Poker_FuLuShou/自己胡牌' 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() self._popEvent = true end ) end ) _gamectr:AddEventListener( GameEvent.ZPResult1, function(...) self._popEvent = false self._left_time = 0 local arg = {...} local result = arg[1] local liuju = result.liuju local data = result.info_list local x = {} self._hu_tip:FillData(x) self:__CloseTip() if self._clearingView == nil then if liuju == true then self._clearingView = RunBeard_ResultView.new(self._view, 1) else self._clearingView = RunBeard_ResultView.new(self._view) end end coroutine.start( function() coroutine.wait(0.5) -- if self._clearingView._is_destroy then return end 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 p.cur_hp = data[i]['cur_hp'] or 0 p.total_hp = data[i]['total_hp'] or 0 if data[i]['hp_info'] then p.cur_hp = data[i].hp_info.cur_hp p.total_hp = data[i].hp_info.total_hp == nil and 0 or data[i].hp_info.total_hp info._view:GetController('zhanji').selectedIndex = 0 if _room.hpOnOff == 1 or _room:checkHpNonnegative() then info._view:GetController('zhanji').selectedIndex = 1 info._view:GetChild('tex_jifen').text = d2ad(p.total_hp) end end card_info:Clear() info:UpdateScore() 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 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 self._popEvent = true 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._left_time = 0 local arg = {...} local total_result = arg[2] local result = arg[1] local over = arg[3] local x = {} self._hu_tip:FillData(x) self:__CloseTip() self:UnmarkSelfTuoguan() self._clearingView = RunBeard_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 ) 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) _gamectr:SendChangeCards(list) end function M:__FangziTip(tip) printlog("进入放子提示流程===>>>") --pt(tip) self._popEvent=false local _gamectr = self._gamectr local _chipeng_tip = UIPackage.CreateObject('Main_RunBeardMaJiang', 'Gcm_action_tips') --printlog("Gcm_action_tips===>>>",_chipeng_tip) self._chipeng_tip = _chipeng_tip local p = self._room.self_player local _lit_fanzi = _chipeng_tip:GetChild('lit_fanzi') _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) pt(_tlist) local tip_hu = false local count = #_tlist for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] if td.type == 7 then tip_hu = true end end for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] --printlog("td==",td) local url = 'ui://Main_RunBeardMaJiang/Btn_fztip' local btn_t = _lit_fanzi:AddItemFromPool(url) printlog("td.type==",td.type) --printlog("btn_t==",btn_t) --if td.type==6 then btn_t:GetChild("hupai").icon="ui://Main_RunBeardMaJiang/201_1_" .. td.card btn_t:GetController("hupai").selectedIndex=1 --end btn_t.icon = 'ui://Main_RunBeardMaJiang/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_RunBeardMaJiang/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(0) _chipeng_tip:Dispose() self._chipeng_tip = nil guo_msg:Close() end ) guo_msg:Show() else _gamectr:SendAction(0) _chipeng_tip:Dispose() self._chipeng_tip = nil end end ) end self._view:AddChild(_chipeng_tip) _chipeng_tip:Center() _chipeng_tip.x = _chipeng_tip.x + 200 _chipeng_tip.y = _chipeng_tip.y - 130 self._popEvent=true 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] --printlog("__TipAction==>>>",td.type) --pt(list) if #list > 1 then self:_ChiView( list, tip_hu, function(id) if tip_hu and td.type ~= 7 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 ,td.type ) --self._chipeng_tip.visible = false return end if tip_hu and td.type ~= 7 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,typeValue) local _pop_tip_choice = UIPackage.CreateObject('Main_RunBeardMaJiang', '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() if typeValue and (typeValue==4 or typeValue==6) then if typeValue==4 then _pop_tip_choice:GetChild('n65').text="杠 牌" else _pop_tip_choice:GetChild('n65').text="招 牌" end 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_RunBeardMaJiang', 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 else 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_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[1])) item_choose:GetChild('card' .. 3).icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', tip_list[i].OpCard[2])) item_choose:GetChild('card' .. 1).icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 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 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_RunBeardMaJiang/Comp_choose') local item_choose = Bilist_choose:AddChild(item) item_choose:GetChild('card' .. 2).icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', _tiplist[i].opcard[1])) item_choose:GetChild('card' .. 3).icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', self:getCardItem('201_', _tiplist[i].opcard[2])) item_choose:GetChild('card' .. 1).icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 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] --if fz.type == RB_FZTypeFLS.Peng or fz.type == RB_FZTypeFLS.Chi or fz.type == RB_FZTypeFLS.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 self._popEvent = false local info = _player_card_info[self:GetPos(player.seat)] info:UpdateFzList(player.fz_list, true, player.seat) --更新放子数组 if (player == self._room.self_player) then if fz.type == RB_FZTypeFLS.Chi then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end elseif fz.type == RB_FZTypeFLS.Peng then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end elseif fz == RB_FZTypeFLS.Gang or fz == RB_FZTypeFLS.SGang or fz == RB_FZTypeFLS.Zhao or fz == RB_FZTypeFLS.SZhao then for i = 1, #fz.opcard do info:DeleteHandCard(fz.opcard[i]) end end info:InitHandCard(false) end if fz.type ~= RB_FZTypeFLS.Kan and fz.type ~= RB_FZTypeFLS.Bi then local info = _player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai local effect = UIPackage.CreateObject('Extend_Poker_FuLuShou', 'FzEffect') if fz.type == RB_FZTypeFLS.Peng then self:PlaySound(player.self_user.sex, 'F_Peng') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 'peng') elseif fz.type == RB_FZTypeFLS.Chi then self:PlaySound(player.self_user.sex, 'F_Chi') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 'chi') elseif fz == RB_FZTypeFLS.Gang or fz == RB_FZTypeFLS.SGang then self:PlaySound(player.self_user.sex, 'F_Gang') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 'gang') elseif fz == RB_FZTypeFLS.Zhao or fz == RB_FZTypeFLS.SZhao then self:PlaySound(player.self_user.sex, 'F_Zhao') effect:GetChild('icon1').icon = UIPackage.GetItemURL('Main_RunBeardMaJiang', 'zhao') end effect.touchable = false effect.x, effect.y = 0, 0 effect:GetTransition('t0'):Play() pNode:AddChild(effect) coroutine.start( function() coroutine.wait(1) effect:Dispose() end ) end if player.tempOutcartList then for i=1,#player.tempOutcartList do local infoP= DataManager.CurrenRoom:GetPlayerById(player.tempOutcartList[i].playerid) if infoP then infoP.outcard_list=player.tempOutcartList[i].outcard_list local infoC = _player_card_info[self:GetPos(infoP.seat)] if infoC then infoC:UpdateQiPai(infoP.outcard_list) end 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() info:ChuPaiTiShi() end ) end local removeOutcard = _player_card_info[self:GetPos(fz.from_seat)] local p = self._room:GetPlayerBySeat(fz.from_seat) if p.DiceCard ~= nil and fz.active_card == p.DiceCard then removeOutcard:ClearOutCard() p.DiceCard = nil 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)] --print(p.hu_xi) info._view:GetChild('huxi').text = p.hu_xi end if player == self._room.self_player then local info = _player_card_info[self:GetPos(player.seat)] info:SetNotPutCard() end self._popEvent = true coroutine.start( function() coroutine.wait(0.15) local info = _player_card_info[1] info:UpdateIsOnClick(true) end ) 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 p.piao then -- self._player_info[self:GetPos(p.seat)]:UpdatePiao(-1) --else self._player_info[self:GetPos(p.seat)]:UpdatePiao(p.piao) --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 = 0 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) end 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:InitHandCard(false) card_info:ShowHuTip() for i = 1, #p.fz_list do if p.fz_list[i].type == RB_FZTypeFLS.Kan then card_info:UpdateKan(3, p.fz_list[i].card) end end end end printlog("jefe abcs",room.left_count); 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 .. '/' .. room.room_config.round .. ' 局' end function M:PlayChatSound(sex, chat_index) local sex_path = ViewUtil.Sex_Chat[sex] local path1 = string.format('extend/zipai/fulushou/sound/%s/chat_%s.mp3', sex_path, tostring(chat_index)) ViewUtil.PlaySound('FuLuShou_ZP', path1) end function M:PlaySound(sex, path) local sex_path = ViewUtil.Sex_Chat[1] -- 1 男 2 女 local sound_path = string.format('extend/zipai/fulushou/sound/%s/%s.mp3', sex_path, path) printlog(sound_path) ViewUtil.PlaySound('FuLuShou_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/fulushou/ui/Extend_Poker_FuLuShou') end return M