local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local MJPlayerCardInfoView = import(".MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") local CS_ClearingView = import(".EXClearingView") local CS_GameEvent = import(".CS_GameEvent") local PlayerInfoView = import(".EXPlayerInfoView") local HuTipView = import("main.majiang.HuTipView") local SettingView = import("main.majiang.MJSettingViewNew") -- local Fix_Msg_Chat = { -- "你真棒!", -- "快点出牌咯", -- "神仙怕左手", -- "这个吃得好", -- "天灵灵 地灵灵 来支好牌行不行", -- "我一听牌你就自摸", -- "做了一天的最佳炮手", -- "摸了一天的烂牌", -- "不要走 决战到天亮", -- "大家小心 我马上自摸", -- "上家是冤家 放个牌吃行不行", -- "冲动是魔鬼 犹豫也是", -- "这局我糊了 请大家吃饭", -- "这牌来得有点着急 简直让人疯狂", -- } local M = {} --- Create a new CS_MainView function M.new() setmetatable(M,{__index = MJMainView}) local self = setmetatable({}, {__index = M}) self.class = "CS_MainView" self.asset_group = "ChangSha_MJ" self:init() ViewUtil.PlayMuisc(self.asset_group, "extend/majiang/changsha/sound/bg.mp3") return self end function M:InitView(url) local room = self._room self._style = 1 self._gps_style = 1 self._full = true -- self.Fix_Msg_Chat = Fix_Msg_Chat UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人长麻 ' .. room.score_times .. '倍' self.LaiziBG=self._view:GetChild('n103') self.LaiziBG.text="鬼牌" self.LaiziBG.visible=false self.selectLaiziBtn=self._view:GetChild('selectlaizi') self.Laizi1Btn=self._view:GetChild('selectlaizi1') self.Laizi2Btn=self._view:GetChild('selectlaizi2') self.Laizi1Btn.visible=false self.Laizi2Btn.visible=false self.selectLaiziBtn.visible=false self._hu_tip = HuTipView.new(self) self:PlayerChangeLineState() --print("CS_MainView") if (room.playing or room.curren_round > 0) or room.status == 1 then self:ReloadRoom() end end function M:NewMJPlayerCardInfoView(view,index) if index == 1 then return MJPlayerSelfCardInfoView.new(view,self) end return MJPlayerCardInfoView.new(view,self) end function M:EventInit() MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info local _gamectr = self._gamectr _gamectr:AddEventListener(CS_GameEvent.EventXiPai,function( ... ) 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(CS_GameEvent.SendCards,function( ... ) local arg = {...} self._tex_LeftCard.text = arg[1] local info = self._player_card_info[1] info._player.auto_out_card = false self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list for i=1,#list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:UpdateHandCard() end end) _gamectr:AddEventListener(CS_GameEvent.EventTurn, function(...) local arg = {...} self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) end) _gamectr:AddEventListener(CS_GameEvent.OutHint, function(...) local arg = {...} local auto = arg[1].auto if auto then local p = self._room.self_player local my_info = self._player_card_info[1] if not my_info._player then info._player = {} end my_info._player.auto_out_card = true -- coroutine.start(function() -- coroutine.wait(0.5) -- self:OutCard(p.card_list[#p.card_list]) -- end) end _room.curren_outcard_seat = _room.self_player.seat --printlog("OutHint===>>>",_room.curren_outcard_seat) local info = self._player_card_info[self:GetPos(_room.self_player.seat)] info:UpdateHandCard(true) end) local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(CS_GameEvent.OutCard, function(...) self:__CloseTip() self:ClearQSHTips() self._left_time = 0 local arg = {...} local p = arg[1] local seat = p.seat local card = arg[2] local info = self._player_card_info[self:GetPos(seat)] self:RemoveCursor() info:UpdateHandCard() local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) info:UpdateOutCardList(outcard, card, self._cursor) self:PlaySound(p.self_user.sex,tostring(card)) self:PlayMJSound("chupai.mp3") if seat == _room.self_player.seat then _room.curren_outcard_seat = -1 end end) _gamectr:AddEventListener(CS_GameEvent.GetCard, function(...) self:__CloseTip() if self.kg_card then self.kg_card:Dispose() end local arg = {...} local seat = arg[1] local card = arg[2] self._tex_LeftCard.text = arg[3] -- self:UpdateRoomInfo() local info = self._player_card_info[self:GetPos(seat)] info:UpdateHandCard(true) end) _gamectr:AddEventListener(CS_GameEvent.FZTips, function(...) local arg = {...} local _tip = arg[1] self:__FangziTip(_tip) end) _gamectr:AddEventListener(CS_GameEvent.FangziAction, handler(self,self.OnFangziAction)) _gamectr:AddEventListener(CS_GameEvent.ZPHuCard, function(...) if self.kg_card then self.kg_card:Dispose() end self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false local arg = {...} local win_seat = arg[1] local lose_seat = arg[2] local win_card = arg[3] local cards = arg[4] local win_list = arg[5] local index = self:GetPos(win_seat) local info = self._player_card_info[index] self:RemoveCursor() info:UpdateHandCard(false, true) local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card") obj_win_card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. win_card obj_win_card:GetController("bg").selectedIndex = 1 info._view:AddChild(obj_win_card) obj_win_card:Center() local player = _room:GetPlayerBySeat(win_seat) local hu_sound = win_seat == lose_seat and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) self:PlaySound(player.self_user.sex, hu_sound) if win_list[1].type == 11 then local url, pNode if win_seat ~= _room.self_player.seat then url = "ui://Main_Majiang/别人胡" pNode = info._mask_liangpai elseif win_seat == _room.self_player.seat then url = "ui://Main_Majiang/自己胡牌" pNode = self._view end if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() if win_seat == _room.self_player.seat then he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end coroutine.start(function() coroutine.wait(2) obj_win_card:Dispose() he:Dispose() self._popEvent = true end) else local pNode = info._view local url = (index == 1 or index == 3) and "eff_list1" or "eff_list2" local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChangSha/" .. url) he_list.touchable = false pNode:AddChild(he_list) he_list:Center() coroutine.start(function() for i = 1 ,#win_list do local tem = win_list[i] local com_name = "he" .. tem.type if tem.type == 1 then com_name = com_name .. "_" .. tem.value end local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/" .. com_name) coroutine.wait(0.3) end if player.win_count and player.win_count >= 3 then he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/he_4w") end coroutine.wait(2) obj_win_card:Dispose() he_list:Dispose() self._popEvent = true end) end end) _gamectr:AddEventListener(CS_GameEvent.EventNiao, function(...) local arg = {...} self._popEvent = false local list = arg[1] local start_seat = arg[2] ViewUtil.PlaySound("ChangSha_MJ", "extend/majiang/changsha/sound/zhuaniao.mp3") coroutine.start(self.RunNiao,self,list, start_seat) end) _gamectr:AddEventListener(CS_GameEvent.ZPResult1, function(...) self._popEvent = false self:__CloseTip() if self._com_haidi then self._com_haidi:Dispose() self._com_haidi = nil end if self.kg_card then self.kg_card:Dispose() _room.kg_card={} end self._left_time = 0 self:UpdateCardBox(0) local arg = {...} local result = arg[1] local liuju = result.liuju local data = result.info_list local niao = result.niao if liuju then local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") self._view:AddChild(le) le:Center() le:GetTransition("t0"):Play() coroutine.start(function() coroutine.wait(1) le:Dispose() end) end self:RemoveCursor() if self._clearingView == nil then self._clearingView = CS_ClearingView.new(self._view) coroutine.start(function() coroutine.wait(0.5) if self._clearingView._is_destroy then return end self._clearingView:Show() self._popEvent = true end) end if _room.curren_round ~= _room.room_config.round then -- if #niao == 0 then self._view:GetChild("n13").visible = false end self._clearingView:InitData(0, _room, result, nil, function(...) for i = 1, #data do local p = _room:GetPlayerBySeat(data[i].seat) p.total_score = data[i].total_score local card_info = self._player_card_info[self:GetPos(p.seat)] local info = self._player_info[self:GetPos(p.seat)] card_info:Clear() card_info:ResetCardType() if _room:checkHpNonnegative() then p.cur_hp = data[i].hp_info.cur_hp end info:UpdateScore() info._view:GetChild("zhanji").visible = true local num = data[i].hp_info.total_hp if num > 0 then info._view:GetController("text_color").selectedIndex = 0 info._view:GetChild("text_jifen").text = "+" .. d2ad(num) else info._view:GetController("text_color").selectedIndex = 1 info._view:GetChild("text_jifen").text = d2ad(num) end info._view:GetChild("mask_piao").title = "" info._view:GetController("piao_niao").selectedIndex = 0 p.win_count = data[i].win_count if p.win_count >= 3 then info._view:GetController("three_win").selectedIndex = 1 info._view:GetChild("com_three_win"):GetChild("tex_win").text = p.win_count info._view:GetChild("com_three_win"):GetTransition("t0"):Play() else info._view:GetController("three_win").selectedIndex = 0 end info._view:GetController("ting").selectedIndex = 0 p.fz_list = {} p.auto_play=false end DataManager.CurrenRoom.self_player.card_list = {} self._state.selectedIndex = 2 self._clearingView = nil end) end self._player_card_info[1]:ShowHuTip() end) _gamectr:AddEventListener(CS_GameEvent.ZPResult2, function(...) if self._com_haidi then self._com_haidi:Dispose() self._com_haidi = nil end self:UnmarkSelfTuoguan() self._left_time = 0 self:UpdateCardBox(0) local arg = {...} local total_result = arg[2] local result = arg[1] local over = arg[3] self._clearingView = CS_ClearingView.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(CS_GameEvent.EventQSTip, function(...) local arg = {...} local data = arg[1] local tip = data["types"] local lit = data["tip_list"] local htype = lit[1]["type"] local tip_qishou if htype == 7 then tip_qishou = UIPackage.CreateObject("Extend_MJ_ChangSha", "pop_tip_qishou") elseif htype == 8 then tip_qishou = UIPackage.CreateObject("Extend_MJ_ChangSha", "pop_tip_zhongtu") end local tipList = tip_qishou:GetChild("list") for i = 1, #tip do local item = tipList:AddItemFromPool() item:GetChild("icon").url = "ui://Extend_MJ_ChangSha/qs" .. tip[i].type item:GetChild("num").text = tip[i].value end local id = lit[1].id tip_qishou:GetChild("btn_qs").onClick:Add(function() _gamectr:SendAction(id) tip_qishou:Dispose() end) local btn_close = tip_qishou:GetChild("btn_close") btn_close.onClick:Add(function() _gamectr:SendAction(0) tip_qishou:Dispose() end) self._view:AddChild(tip_qishou) tip_qishou:Center() self._com_qishou = tip_qishou end) _gamectr:AddEventListener(CS_GameEvent.EvnetQSAction, function(...) local arg = {...} local data = arg[1] self._popEvent = false self:__QsHu(data) end) _gamectr:AddEventListener(CS_GameEvent.EventKaiGang, function(...) local arg = {...} local data = arg[1] local outlist = arg[2] self._popEvent = false self:__KaiGang(data) end) _gamectr:AddEventListener(CS_GameEvent.EvnetHaiDi, function() self:__Haidi() end) _gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function() self:UpdateRound() self._tex_LeftCard.text = "0" self._state.selectedIndex = 1 if oldGameVersion==1 then self:__PiaoNiaoTip() else self:__PiaoNiaoTip1() end end) _gamectr:AddEventListener(CS_GameEvent.EvnetPiao, function(...) local arg = {...} local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 end if seat == _room.self_player.seat then if self._com_piao then self._com_piao:Dispose() self._com_piao = nil end end end) _gamectr:AddEventListener(CS_GameEvent.EventTingTip, function(...) local com_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") com_tip:GetController("hide_bg").selectedIndex = 1 self._chipeng_tip = com_tip local _lit_fanzi = com_tip:GetChild("lit_fanzi") _lit_fanzi:RemoveChildrenToPool() local _btn_ting = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_fztip") _btn_ting.icon = "ui://Main_Majiang/fztip_6" _btn_ting.onClick:Set(function( ... ) _gamectr:SendAction(1) com_tip:Dispose() self._chipeng_tip = nil end) local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") _btn_pass.onClick:Set(function( ... ) _gamectr:SendAction(0) self._chipeng_tip:Dispose() self._chipeng_tip = nil end) self._view:AddChild(com_tip) com_tip:Center() end) _gamectr:AddEventListener(CS_GameEvent.EventTing, function(...) local arg = {...} local seat = arg[1] local index = self:GetPos(seat) local head_info = self._player_info[index] head_info._view:GetController("ting").selectedIndex = 1 local info = self._player_card_info[index] info._player.auto_out_card = true info:UpdateHandCard() end) end function M:UpdateRound() self._view:GetChild("tex_round1").text = self._room.curren_round self._view:GetChild("tex_round2").text = self._room.room_config.round end function M:InitPlayerInfoView() self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do local tem = self._view:GetChild("player_info" .. i) _player_info[i] = PlayerInfoView.new(tem,self) tem.visible = false end end local discard_frame = 0 function M:OutCard(card) -- 防止同一帧内执行两次OutCard事件 local last_discard_frame = discard_frame discard_frame = Time.frameCount --print("帧数:-------------------------",discard_frame, last_discard_frame, discard_frame == last_discard_frame) if discard_frame == last_discard_frame then return end local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 _gamectr:SendOutCard(card, function() local info = self._player_card_info[1] self:RemoveCursor() info:UpdateHandCard() info:UpdateOutCardList(nil, card, self._cursor) self:PlaySound(self._room.self_player.self_user.sex,tostring(card)) self:PlayMJSound("chupai.mp3") end) end function M:__FangziTip(tip) if self.kg_card then self.kg_card:Dispose() end local _gamectr = self._gamectr local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") _chipeng_tip:GetController("hide_bg").selectedIndex = 1 self._chipeng_tip = _chipeng_tip local p = self._room.self_player -- self._player_card_info[self:GetPos(p.seat)] local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) local tip_hu = false local count = #_tlist table.sort(_tlist) local isHu = false for k=1,#_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_Majiang/Btn_fztip" local weight = td.weight if tonumber(weight) == 5 then isHu = true weight = 8 url = "ui://Main_Majiang/Btn_hu" elseif tonumber(weight) == 3 then weight = 16 end local btn_t = _lit_fanzi:AddItemFromPool(url) if url == "ui://Main_Majiang/Btn_hu" and td.card then btn_t:GetChild("hupai").icon="ui://Main_Majiang/202_" ..td.card btn_t:GetController("hupai").selectedIndex=1 end btn_t.icon = "ui://Main_Majiang/fztip_"..weight btn_t.data = { tip, td } btn_t.onClick:Add(self.__TipAction,self) end local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") _btn_pass.onClick:Set(function() if isHu 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) self._view:AddChild(_chipeng_tip) _chipeng_tip:Center() end function M:__TipAction(context) local data = context.sender.data local _gamectr = self._gamectr local tip = data[1] local td = data[2] local list = tip.tip_map_type[td.weight] if (#list > 1) then self:_ChiView(list, function(id) _gamectr:SendAction(id) self:__CloseTip() end) self._chipeng_tip.visible = false return end _gamectr:SendAction(td.id) if (self._chipeng_tip == nil) then return end self._chipeng_tip:Dispose() self._chipeng_tip = nil end function M:_ChiView(tiplist, callback) self._chipeng_tip.visible = false local _pop_tip_choice = UIPackage.CreateObject("Extend_MJ_ChangSha", "Pop_tip_choice") local list_choose1 = _pop_tip_choice:GetChild("Lst_choose") local list_choose2 = _pop_tip_choice:GetChild("Lst_choose2") local crossCtr = _pop_tip_choice:GetController("state") crossCtr.selectedIndex = #tiplist == 3 and 0 or (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) _pop_tip_choice:GetChild("Btn_cross").onClick:Add(function() _pop_tip_choice:Dispose() self._chipeng_tip.visible = true end) list_choose1:RemoveChildrenToPool() list_choose2:RemoveChildrenToPool() for i = 1, #tiplist do local list_choose = i <= 3 and list_choose1 or list_choose2 local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = (1 == tiplist[i].weight or 2 == tiplist[i].weight) and 1 or 0 if tiplist[i].weight ~= 1 then for j = 1, 4 do item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tiplist[i].card) end else local tem = {} table.insert(tem, tiplist[i].opcard[1]) table.insert(tem, tiplist[i].opcard[2]) local tcard = tiplist[i].card table.insert(tem, tcard) table.sort(tem, function(a, b) return a < b end) item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[1]) item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[2]) item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[3]) local cardpos = tem[2] > tcard and 1 or (tem[2] < tcard and 4 or 2) item_choose:GetChild("card" .. cardpos):GetController("color").selectedIndex = 1 end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end function M:__QsHu(data) local seat = data.seat if seat == DataManager.CurrenRoom.self_player.seat then if self._com_qishou then self._com_qishou:Dispose() self._com_qishou = nil end end if data.niao and #data.niao > 0 then local shaizi = UIPackage.CreateObject("Extend_MJ_ChangSha", "Ani_shaizi") local dice1 = data.niao[1].card local dice2 = data.niao[2].card shaizi:GetChild("shaizi1").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice1) shaizi:GetChild("shaizi2").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice2) self._view:AddChild(shaizi) shaizi:Center() coroutine.start(function() -- coroutine.wait(0.5) -- shaizi:GetController("c1").selectedIndex = 1 coroutine.wait(1.5) local xy = shaizi.xy local head_info = self._player_info[self:GetPos(seat)] local target_xy = self._view:GlobalToLocal(head_info._view:LocalToGlobal(head_info:GetHeadCenter())) local diff_x = (target_xy.x - 0.5 * shaizi.width) - xy.x local diff_y = (target_xy.y - 0.5 * shaizi.height) - xy.y self._tween_shaizi = TweenUtils.TweenFloat(0,1,1,function(value) shaizi.x = xy.x + diff_x * value shaizi.y = xy.y + diff_y * value end) coroutine.wait(1.2) shaizi:Dispose() end) end local qs_data = data.data local allShowCards = {} local ShowCardsNum = {} local types = {} local showAllCards = false local qs_type = data.type -- 6是起手胡 8是中途 for i = 1, #qs_data do local cards = {} local opcard =qs_data[i].opcard local qtype = qs_data[i].type if not types[qtype] then types[qtype] = qs_data[i].value end if qtype == 23 or qtype == 24 or qtype == 27 then showAllCards = true allShowCards = opcard end if not showAllCards then for j = 1, #opcard do local card = opcard[j] if cards[card] then cards[card] = cards[card] + 1 else cards[card] = 1 end end for k,v in pairs(cards) do local card = k if ShowCardsNum[card] then if ShowCardsNum[card] < cards[card] then ShowCardsNum[card] = cards[card] end else ShowCardsNum[card] = cards[card] end end end end if not showAllCards then for i,v in pairs(ShowCardsNum) do for j = 1, v do table.insert(allShowCards, i) end end else end local info = self._player_card_info[self:GetPos(seat)] local pNode = info._mask_liangpai self.QSHList={} coroutine.start(function() for i, v in pairs(types) do local show_tip = UIPackage.CreateObject("Extend_MJ_ChangSha", "Tip_qishou") show_tip:GetChild("icon").url = "ui://Extend_MJ_ChangSha/qs" .. i show_tip:GetChild("num").text = v pNode:AddChild(show_tip) show_tip:Center() table.insert(self.QSHList,show_tip) --coroutine.wait(4) --show_tip:Dispose() end end) table.sort(allShowCards, ViewUtil.HandCardSort) info:UpdateHandCard(false, false, allShowCards) coroutine.start(function() coroutine.wait(0.5) self._popEvent = true coroutine.wait(4) self._room.room_config.banyiquan=true if not (self._room.room_config.banyiquan and qs_type == 6) then info:UpdateHandCard(false, false, {}) end --self._popEvent = true end) end function M:ClearQSHTips() if self.QSHList and #self.QSHList>0 then for i=1,#self.QSHList do self.QSHList[i]:Dispose() end self.QSHList=nil end end function M:__KaiGang(data) local seat = data["seat"] local kg_info = data["info"] local dice1 = kg_info["diceNum1"] local dice2 = kg_info["diceNum2"] local cardList = kg_info["cardList"] local info = self._player_card_info[self:GetPos(seat)] local p = self._room:GetPlayerBySeat(seat) local card = p.outcard_list[#p.outcard_list] printlog("jefe kai_gang",dice1) printlog("jefe kai_gang",dice2) local shaizi = UIPackage.CreateObject("Extend_MJ_ChangSha", "Ani_shaizi") shaizi:GetChild("shaizi1").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice1) shaizi:GetChild("shaizi2").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice2) self._view:AddChild(shaizi) shaizi:Center() if self.kg_card then self.kg_card:Dispose() end self.kg_card = UIPackage.CreateObject("Extend_MJ_ChangSha", "kai_gang") local gang_list = self.kg_card:GetChild("list") gang_list:RemoveChildrenToPool() for i = 1, #cardList do local item = gang_list:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_" .. cardList[i]) end if p.seat == self._room.self_player.seat then if not info._player then info._player = {} end info._player.auto_out_card = true info:UpdateHandCard() end coroutine.start(function() -- coroutine.wait(0.5) -- shaizi:GetController("c1").selectedIndex = 1 coroutine.wait(1.5) local xy = shaizi.xy local head_info = self._player_info[self:GetPos(seat)] local target_xy = self._view:GlobalToLocal(head_info._view:LocalToGlobal(head_info:GetHeadCenter())) local diff_x = (target_xy.x - 0.5 * shaizi.width) - xy.x local diff_y = (target_xy.y - 0.5 * shaizi.height) - xy.y self._tween_shaizi = TweenUtils.TweenFloat(0,1,1,function(value) shaizi.x = xy.x + diff_x * value shaizi.y = xy.y + diff_y * value end) coroutine.wait(1.2) shaizi:Dispose() self._view:AddChild(self.kg_card) self.kg_card:Center() info:UpdateOutCardList(nil,card, self._cursor) self._view:GetChild("remaining_card").text = string.format("剩余%d张牌",self._room.remain_cards) coroutine.wait(1) self._popEvent = true end) end function M:__Haidi() -- if DataManager.CurrenRoom.self_player.entrust then return end local item = UIPackage.CreateObject("Extend_MJ_ChangSha", "hai_di") local btn_confirm = item:GetChild("btn_confirm") local btn_cancel = item:GetChild("btn_cancel") local _gamectr = self._gamectr btn_confirm.onClick:Add(function() _gamectr:SendAction(1) item:Dispose() end) btn_cancel.onClick:Add(function() _gamectr:SendAction(0) item:Dispose() end) self._view:AddChild(item) item:Center() self._com_haidi = item end function M:__PiaoNiaoTip() local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") self._view:AddChild(obj_piao) obj_piao.x = (self._view.width - obj_piao.width) * 0.5 obj_piao.y = self._view.height * 0.6 local piaoState=obj_piao:GetController('piao') piaoState.selectedIndex=1 for i = 1, 4 do obj_piao:GetChild("btn_" .. i).onClick:Add(function() self._gamectr:SendAction(i - 1) obj_piao:Dispose() end) end self._com_piao = obj_piao end function M:__PiaoNiaoTip1() local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") self._view:AddChild(obj_piao) obj_piao.x = (self._view.width - obj_piao.width) * 0.5 obj_piao.y = self._view.height * 0.6 local piaoState=obj_piao:GetController('piao') local tconfig=DataManager.CurrenRoom.room_config.config local piaoList={} for i = 1, 4 do local piaoT=obj_piao:GetChild("btn_" .. i) table.insert(piaoList,piaoT) piaoT.onClick:Add(function() self._gamectr:SendAction(i - 1) obj_piao:Dispose() end) end self._com_piao = obj_piao if tconfig.piao_niao<2 then for i=1,#piaoList do piaoList[i].visible=true end piaoState.selectedIndex=1 else piaoList[1].visible=false for i=2,#piaoList do piaoList[i].visible=tconfig["piao"..(i-1)] end piaoState.selectedIndex=2 end end function M:OnFangziAction(...) self._popEvent = false if self.kg_card then self.kg_card:Dispose() end self:__CloseTip() local arg = {...} local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] local index = arg[3] local info = _player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai local effect = UIPackage.CreateObject("Extend_MJ_ChangSha", "FzEffect") local fangzi = "" local fz_sound = "" if fz.type == FZType.Peng then fangzi = "碰" fz_sound = "peng"..math.random(1, 3) elseif fz.type == FZType.Chi then fangzi = "吃" fz_sound = "chi"..math.random(1, 3) else if fz.opengang then fangzi = "杠" fz_sound = "gang"..math.random(1, 2) else fangzi = "补" fz_sound = "buzhang" end end self:PlaySound(player.self_user.sex,fz_sound) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", fangzi) effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", fangzi) effect.touchable = false effect:GetTransition("t2"):Play() pNode:AddChild(effect) coroutine.start(function() coroutine.wait(0.3) self._popEvent = true end) coroutine.start(function() coroutine.wait(1.8) effect:Dispose() end) self:RemoveCursor() if (player.seat ~= fz.from_seat) then local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end info:UpdateFzList(fz, index, true) local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi info:UpdateHandCard(getcard) self:PlayMJSound("fangzi.mp3") end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View self._niao_View = UIPackage.CreateObject("Extend_MJ_ChangSha","Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() for i = 1, #list do --添加背面的麻將 local item = list_niao_card:AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") item:GetChild("tex_score").text = "+" .. list[i].score end for i = 1, #list do --顯示正面 local item = list_niao_card:GetChildAt(i - 1) local card = list[i].card -- coroutine.wait(0.3) item:GetTransition("appear"):Play() item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_"..card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() coroutine.wait(1.5) _niao_View:Dispose() self._popEvent = true end) end function M:ReloadRoom(bskip) local room = self._room if bskip == nil or bskip == false then if not room.playing then self._state.selectedIndex = 2 else self._state.selectedIndex = 1 self._room._reload_flag = true end end if room.kg_card and #room.kg_card ~= 0 then self.kg_card = UIPackage.CreateObject("Extend_MJ_ChangSha", "kai_gang") for i = 1, #room.kg_card do local item = self.kg_card:GetChild("list"):AddItemFromPool() item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_" .. room.kg_card[i]) end self._view:AddChild(self.kg_card) self.kg_card:Center() end for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] local head_info = self._player_info[self:GetPos(p.seat)] head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true local num = p.total_hp or 0 if num > 0 then head_info._view:GetController('text_color').selectedIndex = 0 head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) else head_info._view:GetController('text_color').selectedIndex = 1 head_info._view:GetChild('text_jifen').text = d2ad(num) end if p.win_count~=nil and p.win_count >= 3 then head_info._view:GetController("three_win").selectedIndex = 1 head_info._view:GetChild("com_three_win"):GetChild("tex_win").text = p.win_count end if p.ting then head_info._view:GetController("ting").selectedIndex = 1 end for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end if p == room.self_player and p.auto_play then if not info._player then info._player = {} end info._player.auto_out_card = true end info:UpdateHandCard() if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] info:UpdateOutCardList(nil,card, self._cursor) elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() else info:UpdateOutCardList() end if p.seat == room.banker_seat then local head = self._player_info[self:GetPos(p.seat)] head:MarkBank(true) end if bskip == nil or bskip == false then if p.ready and room.playing == false then self._player_info[self:GetPos(p.seat)]:Ready(true) end end if p.piao_niao~=nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() end local me = room.self_player if room.curren_outcard_seat == me.seat and me.auto_play then self:OutCard(me.draw_card) me.draw_card = nil end end function M:GetPos(seat) local pos = 0 if seat ~= 0 then pos = ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num) end return pos end function M:PlaySound(sex,path) MJMainView.PlaySound(self, "ChangSha_MJ", sex, path) end function M:PlayerChangeLineState() end function M:UpdateCardBox(seat) local index = seat local people_num = self._room.room_config.people_num if people_num == 2 and seat == 2 then index = 3 elseif people_num == 3 and seat == 3 then index = 4 end self._ctr_cardbox.selectedIndex = index 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:closeTipOnTuoguan() self:__CloseTip() if self._com_haidi then self._com_haidi:Dispose() self._com_haidi = nil end if self._com_qishou then self._com_qishou:Dispose() self._com_qishou = nil end -- if self._com_piao then -- self._com_piao:Dispose() -- self._com_piao = nil -- end end function M:Destroy() MJMainView.Destroy(self) UIPackage.RemovePackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") if self._tween_shaizi then TweenUtils.Kill(self._tween_shaizi) end end return M