新二三四人页面全应用

master
罗家炜 2025-04-26 16:08:52 +08:00
parent ad2767352b
commit 5bb5f1774b
9 changed files with 698 additions and 543 deletions

View File

@ -1,6 +1,7 @@
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local MJMainView = require("main.majiang.MJMainView") local MJMainView = require("main.majiang.MJMainView")
local TableBG = require("Game.Data.TableBG")
local EXClearingView = import(".EXClearingView") local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent") local TX_GameEvent = import(".GameEvent")
local HuTipView = import("main.majiang.HuTipView") local HuTipView = import("main.majiang.HuTipView")
@ -8,6 +9,13 @@ local SettingView = import(".EXSettingView")
local PlayerInfoView = import(".EXPlayerInfoView") local PlayerInfoView = import(".EXPlayerInfoView")
local M = {} local M = {}
local bg_config = {
{ id = 1, url = "extend/majiang/nancheng/bg/bg1", thumb = "ui://Extend_MJ_NanCheng/bg1" },
{ id = 2, url = "extend/majiang/nancheng/bg/bg2", thumb = "ui://Extend_MJ_NanCheng/bg2" },
{ id = 3, url = "extend/majiang/nancheng/bg/bg3", thumb = "ui://Extend_MJ_NanCheng/bg3" },
{ id = 4, url = "extend/majiang/nancheng/bg/bg4", thumb = "ui://Extend_MJ_NanCheng/bg4" }
}
--- Create a new ZZ_MainView --- Create a new ZZ_MainView
function M.new() function M.new()
setmetatable(M, { __index = MJMainView }) setmetatable(M, { __index = MJMainView })
@ -25,10 +33,16 @@ function M:InitView(url)
self._gps_style = 1 self._gps_style = 1
self._full = true self._full = true
UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou") UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou")
if self._room.room_config.people_num == 2 then -- if self._room.room_config.people_num == 2 then
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) -- MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
else -- else
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") -- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- end
local use_custom_bg = true
MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num),
use_custom_bg)
if use_custom_bg then
TableBG.LoadTableBG(1, self._room.game_id, self._root_view, bg_config)
end end
self._hu_tip = HuTipView.new(self) self._hu_tip = HuTipView.new(self)
@ -46,9 +60,17 @@ function M:InitView(url)
--[[ --[[
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
--]] --]]
local config = ExtendManager.GetExtendConfig(room.game_id)
local mode = config:GetGameInfo()
local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config))
self._view:GetChild('wanfa_text').text = gamePlay
self.jing = self._view:GetChild('jing') self.jing = self._view:GetChild('jing')
self._state.onChanged:Add(function()
self:UpdatePlayerInfoView()
end)
local showNextCtr = self._view:GetController('showNext') local showNextCtr = self._view:GetController('showNext')
local ShowNextConfrimCtr = self._view:GetController('showNextConfrim') local ShowNextConfrimCtr = self._view:GetController('showNextConfrim')
local showNextList = self._view:GetChild('list_showNext') local showNextList = self._view:GetChild('list_showNext')
@ -84,8 +106,7 @@ function M:InitView(url)
showNextList.selectedIndex = -1 showNextList.selectedIndex = -1
self._showNextName = nil self._showNextName = nil
end) end)
if self._room.room_config.people_num == 2 then local btn_closeRoom = self._view:GetChild("btn_setting")
local btn_closeRoom = self._view:GetChild("btn_setting")
self._view:GetChild('btn_closeRoom').onClick:Set(function() self._view:GetChild('btn_closeRoom').onClick:Set(function()
---[[ ---[[
@ -122,11 +143,10 @@ function M:InitView(url)
--]] --]]
end) end)
btn_closeRoom.onClick:Add(handler(self, function() btn_closeRoom.onClick:Add(handler(self, function()
local settingView = SettingView.new(self) local settingView = SettingView.new(self)
settingView:Show() settingView:Show()
end)) end))
end
-------- --------
self:PlayerChangeLineState() self:PlayerChangeLineState()
@ -186,13 +206,8 @@ function M:IsShowGangZi(btn, isShow)
end end
function M:UpdateRound() function M:UpdateRound()
if self._room.room_config.people_num == 2 then self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round, self._room.room_config.round)
self._room.room_config.round)
else
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
end end
function M:ShowJing() function M:ShowJing()
@ -212,12 +227,24 @@ function M:InitPlayerInfoView()
self._player_info = {} self._player_info = {}
local _player_info = self._player_info local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild("player_info" .. i) local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self) _player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false tem.visible = false
end end
end end
function M:UpdatePlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
local list = self._room.player_list
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
_player_info[i]:FillData(list[i])
end
end
function M:NewMJPlayerCardInfoView(view, index) function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self) return MJPlayerSelfCardInfoView.new(view, self)
@ -356,7 +383,7 @@ function M:EventInit()
local player = _room:GetPlayerBySeat(win_seat) local player = _room:GetPlayerBySeat(win_seat)
if win_seat ~= _room.self_player.seat then if win_seat ~= _room.self_player.seat then
url = "ui://Main_Majiang/别人胡" url = "ui://Main_Majiang/别人胡"
pNode = info._mask_liangpai pNode = info._view
elseif win_seat == _room.self_player.seat then elseif win_seat == _room.self_player.seat then
url = "ui://Main_Majiang/自己胡牌" url = "ui://Main_Majiang/自己胡牌"
pNode = self._view pNode = self._view
@ -443,16 +470,16 @@ function M:EventInit()
local liuju = result.liuju local liuju = result.liuju
local data = result.info_list local data = result.info_list
local niao = result.niao local niao = result.niao
if liuju then -- if liuju then
local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") -- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
self._view:AddChild(le) -- self._view:AddChild(le)
le:Center() -- le:Center()
le:GetTransition("t0"):Play() -- le:GetTransition("t0"):Play()
coroutine.start(function() -- coroutine.start(function()
coroutine.wait(1) -- coroutine.wait(1)
le:Dispose() -- le:Dispose()
end) -- end)
end -- end
self:RemoveCursor() self:RemoveCursor()
if self._clearingView == nil then if self._clearingView == nil then
self._clearingView = EXClearingView.new(self._root_view) self._clearingView = EXClearingView.new(self._root_view)
@ -496,7 +523,7 @@ function M:EventInit()
self._clearingView = nil self._clearingView = nil
end) end)
end end
self._player_card_info[1]:ShowHuTip() -- self._player_card_info[1]:ShowHuTip()
end) end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
@ -563,59 +590,119 @@ function M:OutCard(card)
end end
end end
-- function M:__FangziTip(tip, weight)
-- printlog("__FangziTip")
-- 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)
-- printlog(tip.tip_map_type)
-- pt(_tlist)
-- 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 td_weight = td.weight
-- if td_weight == 16 then td_weight = 8 end
-- if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
-- local btn_t = _lit_fanzi:AddItemFromPool(url)
-- btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
-- btn_t.data = { tip, td }
-- btn_t.onClick:Add(self.__TipAction, self)
-- end
-- -- if not (tonumber(weight) >= 16) then
-- local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- -- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
-- _btn_pass.onClick:Set(function()
-- if tonumber(weight) >= 8 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()
-- end
function M:__FangziTip(tip, weight) function M:__FangziTip(tip, weight)
printlog("__FangziTip") printlog("__FangziTip")
local _gamectr = self._gamectr local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") local info = self._player_card_info[1]
_chipeng_tip:GetController("hide_bg").selectedIndex = 1 local _chipeng_tip = info._view_FZTips
self._chipeng_tip = _chipeng_tip local _ctr_tips = info._ctr_tip
local p = self._room.self_player
-- self._player_card_info[self:GetPos(p.seat)]
local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") local _lit_fanzi = _chipeng_tip:GetChild("list")
_lit_fanzi:RemoveChildrenToPool() _lit_fanzi:SetVirtual()
local _tlist = table.keys(tip.tip_map_type) local _tlist = tip.tip_map_id
printlog(tip.tip_map_type) _lit_fanzi.itemRenderer = function(index, obj)
pt(_tlist) local type = obj:GetController('type')
local tip_hu = false if index == tip.tip_num then
local count = #_tlist type.selectedIndex = 0
table.sort(_tlist) obj.onClick:Set(function()
local isHu = false local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
for k = 1, #_tlist do guo_msg.onOk:Add(function()
local td = tip.tip_map_type[_tlist[k]][1] _gamectr:SendAction(0)
local url = "ui://Main_Majiang/Btn_fztip" _ctr_tips.selectedIndex = 0
local td_weight = td.weight guo_msg:Close()
if td_weight == 16 then td_weight = 8 end end)
if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end guo_msg:Show()
local btn_t = _lit_fanzi:AddItemFromPool(url)
btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
btn_t.data = { tip, td }
btn_t.onClick:Add(self.__TipAction, self)
end
-- if not (tonumber(weight) >= 16) then
local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
_btn_pass.onClick:Set(function()
if tonumber(weight) >= 8 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) end)
guo_msg:Show()
else else
_gamectr:SendAction(0) index = index + 1
_chipeng_tip:Dispose() if _tlist[index].type == FZType.HU then
self._chipeng_tip = nil type.selectedIndex = 4
obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/202_%d', _tlist[index].card)
elseif _tlist[index].type == FZType.Chi then
type.selectedIndex = FZType.Chi
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].opcard[i])
end
elseif _tlist[index].type == FZType.Peng then
type.selectedIndex = FZType.Peng
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
else
for i = 1, 4 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
type.selectedIndex = FZType.Gang
if _tlist[index].type == FZType.Gang_An then
obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/202_00'
end
end
obj.onClick:Set(function()
_gamectr:SendAction(_tlist[index].id)
_ctr_tips.selectedIndex = 0
end)
end end
end) end
-- end _ctr_tips.selectedIndex = 1
_lit_fanzi.numItems = tip.tip_num + 1
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
end end
function M:__TipAction(context) function M:__TipAction(context)
@ -722,7 +809,7 @@ function M:OnFangziAction(...)
end end
effect.touchable = false effect.touchable = false
effect:GetTransition("t2"):Play() effect:GetTransition("t2"):Play()
pNode:AddChild(effect) -- pNode:AddChild(effect)
coroutine.start(function() coroutine.start(function()
coroutine.wait(0.3) coroutine.wait(0.3)
self._popEvent = true self._popEvent = true

View File

@ -17,14 +17,7 @@ function M.new(view, mainView)
end end
function M:init() function M:init()
if self._main_view._room.room_config.people_num ~= 2 then PlayerInfoView_copy.init(self)
PlayerInfoView.init(self)
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
self._ct_score = self._view:GetChild("info"):GetController("score")
else
PlayerInfoView_copy.init(self)
end
end end
function M:ShowInteraction(type,str) function M:ShowInteraction(type,str)
@ -57,12 +50,7 @@ function M:UpdateRemainCard(card_num, hide)
end end
function M:FillData(player) function M:FillData(player)
if self._main_view._room.room_config.people_num == 2 then PlayerInfoView_copy.FillData(self, player)
PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
self:UpdateScore(player.total_score)
end
end end
function M:UpdateScore() function M:UpdateScore()

View File

@ -1,5 +1,5 @@
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local CardCheck = import(".CardCheck") local CardCheck = import(".CardCheck")
local M = {} local M = {}
@ -15,196 +15,197 @@ function M.new(view, mainView)
return self return self
end end
function M:ShowHuTip(card_list) -- function M:ShowHuTip(card_list)
printlog("ShowHuTip") -- printlog("ShowHuTip")
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, -- local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui,
DataManager.CurrenRoom.room_config.Laizi) -- DataManager.CurrenRoom.room_config.Laizi)
if #tingList > 0 then -- if #tingList > 0 then
if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then -- if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then
for i = 1, #DataManager.CurrenRoom.laiziInfo do -- for i = 1, #DataManager.CurrenRoom.laiziInfo do
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then -- if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then
table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) -- table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i])
end -- end
end -- end
end -- end
end -- end
self._mainView._hu_tip:FillData(tingList) -- self._mainView._hu_tip:FillData(tingList)
end -- end
function M:UpdateHandCard(getcard, mp) function M:UpdateHandCard(getcard, mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList -- local _carViewList = self._carViewList
if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then -- if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then
for i = 1, #self._carViewList do -- for i = 1, #self._carViewList do
local obj = self._carViewList[i] -- local obj = self._carViewList[i]
if obj and obj.card then -- if obj and obj.card then
if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then -- if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then
if obj.card.GetController then -- if obj.card.GetController then
if obj.card:GetController("laizi") then -- if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 1 -- obj.card:GetController("laizi").selectedIndex = 1
end -- end
end -- end
else -- else
if obj.card.GetController then -- if obj.card.GetController then
if obj.card:GetController("laizi") then -- if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 0 -- obj.card:GetController("laizi").selectedIndex = 0
end -- end
end -- end
end -- end
end -- end
end -- end
end -- end
local card_list = DataManager.CurrenRoom.self_player.card_list -- local card_list = DataManager.CurrenRoom.self_player.card_list
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
if getcard then -- if getcard then
self._out_card = true -- self._out_card = true
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) -- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- 记录需要标记听牌提示的牌 -- -- 记录需要标记听牌提示的牌
local lst_mark = {} -- local lst_mark = {}
local total_num = 0 -- local total_num = 0
for i = 1, #_carViewList do -- for i = 1, #_carViewList do
local btn = _carViewList[i].card -- local btn = _carViewList[i].card
local card = self:GetCard(btn) -- local card = self:GetCard(btn)
list_remove(card_list, card) -- list_remove(card_list, card)
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, -- local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true,
DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) -- DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi)
if #tingList > 0 then -- if #tingList > 0 then
local count = 0 -- local count = 0
for j = 1, #tingList do -- for j = 1, #tingList do
count = count + self._mainView:CountCardLeftNum(tingList[j]) -- count = count + self._mainView:CountCardLeftNum(tingList[j])
end -- end
local tem = {} -- local tem = {}
tem.item = btn -- tem.item = btn
tem.count = count -- tem.count = count
total_num = total_num + count -- total_num = total_num + count
table.insert(lst_mark, tem) -- table.insert(lst_mark, tem)
end -- end
table.insert(card_list, card) -- table.insert(card_list, card)
end -- end
table.sort(lst_mark, function(a, b) -- table.sort(lst_mark, function(a, b)
return a.count > b.count -- return a.count > b.count
end) -- end)
-- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' -- -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false -- local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
for i = 1, #lst_mark do -- for i = 1, #lst_mark do
local tem = lst_mark[i] -- local tem = lst_mark[i]
if all_same or tem.count < lst_mark[1].count then -- if all_same or tem.count < lst_mark[1].count then
tem.item:GetController("mark_ting").selectedIndex = 1 -- tem.item:GetController("mark_ting").selectedIndex = 1
else -- else
tem.item:GetController("mark_ting").selectedIndex = 2 -- tem.item:GetController("mark_ting").selectedIndex = 2
end -- end
end -- end
else -- else
for i = 1, #_carViewList do -- for i = 1, #_carViewList do
local btn = _carViewList[i].card -- local btn = _carViewList[i].card
if btn:GetController("mark_ting").selectedIndex ~= 0 then -- if btn:GetController("mark_ting").selectedIndex ~= 0 then
btn:GetController("mark_ting").selectedIndex = 0 -- btn:GetController("mark_ting").selectedIndex = 0
end -- end
end -- end
self._out_card = false -- self._out_card = false
end -- end
end end
function M:__OnClickHandCard(context) -- function M:__OnClickHandCard(context)
local button = context.sender -- local button = context.sender
local _carViewList = self._carViewList -- local _carViewList = self._carViewList
local refresh = true -- local refresh = true
local card_list = {} -- local card_list = {}
for i = 1, #_carViewList do -- for i = 1, #_carViewList do
local btn = _carViewList[i].card -- local btn = _carViewList[i].card
local card = self:GetCard(btn) -- local card = self:GetCard(btn)
if btn ~= button and btn.selected == true then -- if btn ~= button and btn.selected == true then
if button.data.card_item == card then -- if button.data.card_item == card then
refresh = false -- refresh = false
else -- else
self._mainView:markOutCards(false, card) -- self._mainView:markOutCards(false, card)
end -- end
btn.selected = false -- btn.selected = false
end -- end
if not btn.selected then -- if not btn.selected then
table.insert(card_list, card) -- table.insert(card_list, card)
end -- end
end -- end
if self._out_card then -- if self._out_card then
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
end -- end
-- 标记出牌 -- -- 标记出牌
if refresh then -- if refresh then
if button.selected then -- if button.selected then
self._mainView:markOutCards(true, button.data.card_item) -- self._mainView:markOutCards(true, button.data.card_item)
else -- else
self._mainView:markOutCards(false, button.data.card_item) -- self._mainView:markOutCards(false, button.data.card_item)
end -- end
end -- end
local _room = DataManager.CurrenRoom -- local _room = DataManager.CurrenRoom
if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then -- if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then
local card = button.data -- local card = button.data
self._mainView:OutCard(card.card_item) -- self._mainView:OutCard(card.card_item)
end -- end
end -- end
function M:__OnDragStart(card) -- function M:__OnDragStart(card)
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) -- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
list_remove(card_list, card) -- list_remove(card_list, card)
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
end -- end
function M:__OnDragEnd(context) -- function M:__OnDragEnd(context)
if self.outcard_button then -- if self.outcard_button then
self.outcard_button:Dispose() -- self.outcard_button:Dispose()
self.outcard_button = nil -- self.outcard_button = nil
end -- end
local button = context.sender -- local button = context.sender
--button:RemoveFromParent() -- --button:RemoveFromParent()
local card = button.data -- local card = button.data
local _room = DataManager.CurrenRoom -- local _room = DataManager.CurrenRoom
-- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) -- -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat)
if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then -- if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then
self._mainView:OutCard(card.card_item) -- self._mainView:OutCard(card.card_item)
button.touchable = false -- button.touchable = false
self.outcard_button = button -- self.outcard_button = button
else -- else
self._area_handcard_list:AddChildAt(button, card.index) -- self._area_handcard_list:AddChildAt(button, card.index)
button:TweenMove(card.old_postion, 0.2) -- button:TweenMove(card.old_postion, 0.2)
end -- end
end -- end
function M:CheckPlayerOnlineState() -- function M:CheckPlayerOnlineState()
local room = DataManager.CurrenRoom -- local room = DataManager.CurrenRoom
for i = 1, #room.player_list do -- for i = 1, #room.player_list do
if room.player_list[i].line_state == 0 then -- if room.player_list[i].line_state == 0 then
return false -- return false
end -- end
end -- end
return true -- return true
end -- end
function M:Clear(bskip) function M:Clear(bskip)
MJPlayerSelfCardInfoView.Clear(self)
--self._ctr_state.selectedIndex = 0 --self._ctr_state.selectedIndex = 0
self._area_fz_list.x = self._src_fz_list.x -- self._area_fz_list.x = self._src_fz_list.x
self._area_fz_list.y = self._src_fz_list.y -- self._area_fz_list.y = self._src_fz_list.y
self._area_fz_list.width = self._src_fz_list.z -- self._area_fz_list.width = self._src_fz_list.z
self._area_fz_list.height = self._src_fz_list.w -- self._area_fz_list.height = self._src_fz_list.w
self._area_fz_list:RemoveChildren(0, -1, true) -- self._area_fz_list:RemoveChildren(0, -1, true)
self._area_handcard_list:RemoveChildren(0, -1, true) -- self._area_handcard_list:RemoveChildren(0, -1, true)
self._area_outcard_list:RemoveChildren(0, -1, true) -- self._area_outcard_list:RemoveChildren(0, -1, true)
if bskip == nil or bskip == false then -- if bskip == nil or bskip == false then
self._mask_liangpai:RemoveChildren(0, -1, true) -- self._mask_liangpai:RemoveChildren(0, -1, true)
end -- end
for i = 1, #self._carViewList do -- for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose() -- self._carViewList[i].card:Dispose()
end -- end
self._carViewList = {} -- self._carViewList = {}
end end
return M return M

View File

@ -115,6 +115,7 @@ function M:fillResult0(room, peopleNum, result)
local isZhuang = playerInfoComp:GetController("zhuang") local isZhuang = playerInfoComp:GetController("zhuang")
local infoList = result.info_list[i] local infoList = result.info_list[i]
local infoJiangma = result.niao
local playInfo = room:GetPlayerBySeat(infoList.seat) local playInfo = room:GetPlayerBySeat(infoList.seat)
local fzCardInfo = playInfo.fz_list local fzCardInfo = playInfo.fz_list
local fzInfoNum = #fzCardInfo local fzInfoNum = #fzCardInfo
@ -122,6 +123,11 @@ function M:fillResult0(room, peopleNum, result)
self:fillHead(playInfo.self_user.head_url, playerInfoComp) self:fillHead(playInfo.self_user.head_url, playerInfoComp)
infoList.jing_score = infoList.jing_score or 0
infoList.gang_score = infoList.gang_score or 0
infoList.hu_score = infoList.hu_score or 0
infoList.round_score = infoList.round_score or 0
playerInfoComp:GetChild("text_name").text = playInfo.self_user.nick_name playerInfoComp:GetChild("text_name").text = playInfo.self_user.nick_name
playerInfoComp:GetChild("Text_BoJing").text = infoList.jing_score >= 0 and playerInfoComp:GetChild("Text_BoJing").text = infoList.jing_score >= 0 and
string.format("+%d", infoList.jing_score) or infoList.jing_score string.format("+%d", infoList.jing_score) or infoList.jing_score
@ -179,7 +185,6 @@ function M:fillResult0(room, peopleNum, result)
handCardList.itemRenderer = function(index, obj) handCardList.itemRenderer = function(index, obj)
obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), infoList.hand_card[index + 1]) obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), infoList.hand_card[index + 1])
if room.jing == infoList.hand_card[index + 1] then if room.jing == infoList.hand_card[index + 1] then
ViewUtil:ErrorTip("显示精")
obj:GetController('jing').selectedIndex = 1 obj:GetController('jing').selectedIndex = 1
end end
end end
@ -191,7 +196,6 @@ function M:fillResult0(room, peopleNum, result)
end end
if infoList.seat == room.banker_seat then if infoList.seat == room.banker_seat then
ViewUtil:ErrorTip("显示庄家")
isZhuang.selectedIndex = 1 isZhuang.selectedIndex = 1
end end
@ -210,7 +214,15 @@ function M:fillResult0(room, peopleNum, result)
huCardBtn.icon = string.format("ui://Main_Majiang/202_%d", infoList.win_card) huCardBtn.icon = string.format("ui://Main_Majiang/202_%d", infoList.win_card)
huCardBtn.visible = true huCardBtn.visible = true
jiangMaList.visible = false jiangMaList.visible = true
jiangMaList:SetVirtual()
jiangMaList.itemRenderer = function(index, obj)
obj.icon = string.format("ui://Main_Majiang/202_%d", infoJiangma[index + 1].card)
obj:GetController('bg').selectedIndex = infoJiangma[index + 1].score
obj:GetController('jing').selectedIndex = infoJiangma[index + 1].card == room.jing and 1 or 0
end
jiangMaList.numItems = #infoJiangma
jiangMaList.columnCount = #infoJiangma / 2
else else
playerInfoComp:GetChild("text_huShow").text = "" playerInfoComp:GetChild("text_huShow").text = ""
if not room.isZiMoHu and playInfo.self_user.account_id == result.active_player then if not room.isZiMoHu and playInfo.self_user.account_id == result.active_player then

View File

@ -133,7 +133,6 @@ function M:OnEventSendCards(evt_data)
_room.jing = jing _room.jing = jing
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
_room.banker_seat = seat _room.banker_seat = seat
-- print("========================fuzhijing")
for i = 1, #_room.player_list do for i = 1, #_room.player_list do
_room.player_list[i].hand_left_count = 13 _room.player_list[i].hand_left_count = 13
_room.player_list[i].fz_list = {} _room.player_list[i].fz_list = {}
@ -201,7 +200,6 @@ function M:OnEventTurn(evt_data)
end end
function M:OnEventFzTips(evt_data) function M:OnEventFzTips(evt_data)
print("========================OnEventFzTips")
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
local tiplist = FZTipList.new() local tiplist = FZTipList.new()
local list = evt_data["tip_list"] local list = evt_data["tip_list"]
@ -288,7 +286,6 @@ function M:OnEventFzAction(evt_data)
end end
function M:OnEventHu(evt_data) function M:OnEventHu(evt_data)
-- print("===========================OnEventHu")
local cards = evt_data["card"] local cards = evt_data["card"]
local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local win_p = self._room:GetPlayerBySeat(evt_data["seat"])
local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"])

View File

@ -1,6 +1,7 @@
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local MJMainView = require("main.majiang.MJMainView") local MJMainView = require("main.majiang.MJMainView")
local TableBG = require("Game.Data.TableBG")
local EXClearingView = import(".EXClearingView") local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent") local TX_GameEvent = import(".GameEvent")
local HuTipView = import("main.majiang.HuTipView") local HuTipView = import("main.majiang.HuTipView")
@ -8,6 +9,13 @@ local SettingView = import(".EXSettingView")
local PlayerInfoView = import(".EXPlayerInfoView") local PlayerInfoView = import(".EXPlayerInfoView")
local M = {} local M = {}
local bg_config = {
{ id = 1, url = "extend/majiang/nancheng/bg/bg1", thumb = "ui://Extend_MJ_NanCheng/bg1" },
{ id = 2, url = "extend/majiang/nancheng/bg/bg2", thumb = "ui://Extend_MJ_NanCheng/bg2" },
{ id = 3, url = "extend/majiang/nancheng/bg/bg3", thumb = "ui://Extend_MJ_NanCheng/bg3" },
{ id = 4, url = "extend/majiang/nancheng/bg/bg4", thumb = "ui://Extend_MJ_NanCheng/bg4" }
}
--- Create a new ZZ_MainView --- Create a new ZZ_MainView
function M.new() function M.new()
setmetatable(M, { __index = MJMainView }) setmetatable(M, { __index = MJMainView })
@ -25,15 +33,19 @@ function M:InitView(url)
self._gps_style = 1 self._gps_style = 1
self._full = true self._full = true
UIPackage.AddPackage("extend/majiang/lichuan/ui/Extend_MJ_LiChuan") UIPackage.AddPackage("extend/majiang/lichuan/ui/Extend_MJ_LiChuan")
if self._room.room_config.people_num == 2 then -- if self._room.room_config.people_num == 2 then
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num .. "_jiangxi") -- MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
else -- else
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") -- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
-- end
local use_custom_bg = true
MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num),
use_custom_bg)
if use_custom_bg then
TableBG.LoadTableBG(1, self._room.game_id, self._root_view, bg_config)
end end
self._hu_tip = HuTipView.new(self) self._hu_tip = HuTipView.new(self)
self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人黎川麻将 ' .. room.score_times .. ''
self.selectLaiziBtn = self._view:GetChild('selectlaizi') self.selectLaiziBtn = self._view:GetChild('selectlaizi')
self.Laizi1Btn = self._view:GetChild('selectgang1') self.Laizi1Btn = self._view:GetChild('selectgang1')
self.Laizi2Btn = self._view:GetChild('selectgang2') self.Laizi2Btn = self._view:GetChild('selectgang2')
@ -46,9 +58,17 @@ function M:InitView(url)
--[[ --[[
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
--]] --]]
local config = ExtendManager.GetExtendConfig(room.game_id)
local mode = config:GetGameInfo()
local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config))
self._view:GetChild('wanfa_text').text = gamePlay
self.jing = self._view:GetChild('jing') self.jing = self._view:GetChild('jing')
self._state.onChanged:Add(function()
self:UpdatePlayerInfoView()
end)
local showNextCtr = self._view:GetController('showNext') local showNextCtr = self._view:GetController('showNext')
local ShowNextConfrimCtr = self._view:GetController('showNextConfrim') local ShowNextConfrimCtr = self._view:GetController('showNextConfrim')
local showNextList = self._view:GetChild('list_showNext') local showNextList = self._view:GetChild('list_showNext')
@ -84,8 +104,7 @@ function M:InitView(url)
showNextList.selectedIndex = -1 showNextList.selectedIndex = -1
self._showNextName = nil self._showNextName = nil
end) end)
if self._room.room_config.people_num == 2 then local btn_closeRoom = self._view:GetChild("btn_setting")
local btn_closeRoom = self._view:GetChild("btn_setting")
self._view:GetChild('btn_closeRoom').onClick:Set(function() self._view:GetChild('btn_closeRoom').onClick:Set(function()
---[[ ---[[
@ -122,11 +141,10 @@ function M:InitView(url)
--]] --]]
end) end)
btn_closeRoom.onClick:Add(handler(self, function() btn_closeRoom.onClick:Add(handler(self, function()
local settingView = SettingView.new(self) local settingView = SettingView.new(self)
settingView:Show() settingView:Show()
end)) end))
end
-------- --------
self:PlayerChangeLineState() self:PlayerChangeLineState()
@ -185,13 +203,8 @@ function M:IsShowGangZi(btn, isShow)
end end
function M:UpdateRound() function M:UpdateRound()
if self._room.room_config.people_num == 2 then self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round, self._room.room_config.round)
self._room.room_config.round)
else
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
end end
function M:ShowJing() function M:ShowJing()
@ -211,12 +224,24 @@ function M:InitPlayerInfoView()
self._player_info = {} self._player_info = {}
local _player_info = self._player_info local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild("player_info" .. i) local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self) _player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false tem.visible = false
end end
end end
function M:UpdatePlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
local list = self._room.player_list
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
_player_info[i]:FillData(list[i])
end
end
function M:NewMJPlayerCardInfoView(view, index) function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self) return MJPlayerSelfCardInfoView.new(view, self)
@ -356,7 +381,7 @@ function M:EventInit()
local player = _room:GetPlayerBySeat(win_seat) local player = _room:GetPlayerBySeat(win_seat)
if win_seat ~= _room.self_player.seat then if win_seat ~= _room.self_player.seat then
url = "ui://Main_Majiang/别人胡" url = "ui://Main_Majiang/别人胡"
pNode = info._mask_liangpai pNode = info._view
elseif win_seat == _room.self_player.seat then elseif win_seat == _room.self_player.seat then
url = "ui://Main_Majiang/自己胡牌" url = "ui://Main_Majiang/自己胡牌"
pNode = self._view pNode = self._view
@ -443,16 +468,16 @@ function M:EventInit()
local liuju = result.liuju local liuju = result.liuju
local data = result.info_list local data = result.info_list
local niao = result.niao local niao = result.niao
if liuju then -- if liuju then
local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") -- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
self._view:AddChild(le) -- self._view:AddChild(le)
le:Center() -- le:Center()
le:GetTransition("t0"):Play() -- le:GetTransition("t0"):Play()
coroutine.start(function() -- coroutine.start(function()
coroutine.wait(1) -- coroutine.wait(1)
le:Dispose() -- le:Dispose()
end) -- end)
end -- end
self:RemoveCursor() self:RemoveCursor()
if self._clearingView == nil then if self._clearingView == nil then
self._clearingView = EXClearingView.new(self._root_view) self._clearingView = EXClearingView.new(self._root_view)
@ -496,7 +521,7 @@ function M:EventInit()
self._clearingView = nil self._clearingView = nil
end) end)
end end
self._player_card_info[1]:ShowHuTip() -- self._player_card_info[1]:ShowHuTip()
end) end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
@ -563,59 +588,119 @@ function M:OutCard(card)
end end
end end
-- function M:__FangziTip(tip, weight)
-- printlog("__FangziTip")
-- 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)
-- printlog(tip.tip_map_type)
-- pt(_tlist)
-- 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 td_weight = td.weight
-- if td_weight == 16 then td_weight = 8 end
-- if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
-- local btn_t = _lit_fanzi:AddItemFromPool(url)
-- btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
-- btn_t.data = { tip, td }
-- btn_t.onClick:Add(self.__TipAction, self)
-- end
-- -- if not (tonumber(weight) >= 16) then
-- local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- -- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
-- _btn_pass.onClick:Set(function()
-- if tonumber(weight) >= 8 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()
-- end
function M:__FangziTip(tip, weight) function M:__FangziTip(tip, weight)
print("========================OnEventFzTips2", tip, weight) printlog("__FangziTip")
local _gamectr = self._gamectr local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") local info = self._player_card_info[1]
_chipeng_tip:GetController("hide_bg").selectedIndex = 1 local _chipeng_tip = info._view_FZTips
self._chipeng_tip = _chipeng_tip local _ctr_tips = info._ctr_tip
local p = self._room.self_player
-- self._player_card_info[self:GetPos(p.seat)]
local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") local _lit_fanzi = _chipeng_tip:GetChild("list")
_lit_fanzi:RemoveChildrenToPool() _lit_fanzi:SetVirtual()
local _tlist = table.keys(tip.tip_map_type) local _tlist = tip.tip_map_id
printlog(tip.tip_map_type) _lit_fanzi.itemRenderer = function(index, obj)
pt(_tlist) local type = obj:GetController('type')
local tip_hu = false if index == tip.tip_num then
local count = #_tlist type.selectedIndex = 0
table.sort(_tlist) obj.onClick:Set(function()
local isHu = false local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
for k = 1, #_tlist do guo_msg.onOk:Add(function()
local td = tip.tip_map_type[_tlist[k]][1] _gamectr:SendAction(0)
local url = "ui://Main_Majiang/Btn_fztip" _ctr_tips.selectedIndex = 0
local td_weight = td.weight guo_msg:Close()
if td_weight == 16 then td_weight = 8 end end)
if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end guo_msg:Show()
local btn_t = _lit_fanzi:AddItemFromPool(url)
btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
btn_t.data = { tip, td }
btn_t.onClick:Add(self.__TipAction, self)
end
-- if not (tonumber(weight) >= 16) then
local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
_btn_pass.onClick:Set(function()
if tonumber(weight) >= 8 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) end)
guo_msg:Show()
else else
_gamectr:SendAction(0) index = index + 1
_chipeng_tip:Dispose() if _tlist[index].type == FZType.HU then
self._chipeng_tip = nil type.selectedIndex = 4
obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/202_%d', _tlist[index].card)
elseif _tlist[index].type == FZType.Chi then
type.selectedIndex = FZType.Chi
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].opcard[i])
end
elseif _tlist[index].type == FZType.Peng then
type.selectedIndex = FZType.Peng
for i = 1, 3 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
else
for i = 1, 4 do
obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/202_%d',
_tlist[index].card)
end
type.selectedIndex = FZType.Gang
if _tlist[index].type == FZType.Gang_An then
obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/202_00'
end
end
obj.onClick:Set(function()
_gamectr:SendAction(_tlist[index].id)
_ctr_tips.selectedIndex = 0
end)
end end
end) end
-- end _ctr_tips.selectedIndex = 1
_lit_fanzi.numItems = tip.tip_num + 1
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
end end
function M:__TipAction(context) function M:__TipAction(context)
@ -722,7 +807,7 @@ function M:OnFangziAction(...)
end end
effect.touchable = false effect.touchable = false
effect:GetTransition("t2"):Play() effect:GetTransition("t2"):Play()
pNode:AddChild(effect) -- pNode:AddChild(effect)
coroutine.start(function() coroutine.start(function()
coroutine.wait(0.3) coroutine.wait(0.3)
self._popEvent = true self._popEvent = true

View File

@ -17,14 +17,7 @@ function M.new(view, mainView)
end end
function M:init() function M:init()
if self._main_view._room.room_config.people_num ~= 2 then PlayerInfoView_copy.init(self)
PlayerInfoView.init(self)
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
self._ct_score = self._view:GetChild("info"):GetController("score")
else
PlayerInfoView_copy.init(self)
end
end end
function M:ShowInteraction(type, str) function M:ShowInteraction(type, str)
@ -57,12 +50,7 @@ function M:UpdateRemainCard(card_num, hide)
end end
function M:FillData(player) function M:FillData(player)
if self._main_view._room.room_config.people_num == 2 then PlayerInfoView_copy.FillData(self, player)
PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
self:UpdateScore(player.total_score)
end
end end
function M:UpdateScore() function M:UpdateScore()

View File

@ -1,8 +1,7 @@
local EXTEND_MODEL_NAME = ... local EXTEND_MODEL_NAME = ...
local EXGameInfo = import(".EXGameInfo") local EXGameInfo = import(".EXGameInfo")
local EXMainView = import(".EXMainView_jaingxi") local EXMainView = import(".EXMainView")
-- local EXMainView = import(".EXMainView")
local EXGameController = import(".EXGameController") local EXGameController = import(".EXGameController")
local EXRoomConfig = import(".EXRoomConfig") local EXRoomConfig = import(".EXRoomConfig")
local EXPlayBackView = import(".EXPlayBackView") local EXPlayBackView = import(".EXPlayBackView")

View File

@ -1,5 +1,5 @@
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi")
local CardCheck = import(".CardCheck") local CardCheck = import(".CardCheck")
local M = {} local M = {}
@ -15,199 +15,197 @@ function M.new(view, mainView)
return self return self
end end
function M:ShowHuTip(card_list) -- function M:ShowHuTip(card_list)
printlog("ShowHuTip") -- printlog("ShowHuTip")
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, -- local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui,
DataManager.CurrenRoom.room_config.Laizi) -- DataManager.CurrenRoom.room_config.Laizi)
pt(tingList) -- if #tingList > 0 then
if #tingList > 0 then -- if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then
if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then -- for i = 1, #DataManager.CurrenRoom.laiziInfo do
for i = 1, #DataManager.CurrenRoom.laiziInfo do -- if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then -- table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i])
table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) -- end
end -- end
end -- end
end -- end
end -- self._mainView._hu_tip:FillData(tingList)
self._mainView._hu_tip:FillData(tingList) -- end
end
function M:UpdateHandCard(getcard, mp) function M:UpdateHandCard(getcard, mp)
print("====================================UpdateHandCard1", mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList -- local _carViewList = self._carViewList
if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then -- if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then
for i = 1, #self._carViewList do -- for i = 1, #self._carViewList do
local obj = self._carViewList[i] -- local obj = self._carViewList[i]
if obj and obj.card then -- if obj and obj.card then
if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then -- if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then
if obj.card.GetController then -- if obj.card.GetController then
if obj.card:GetController("laizi") then -- if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 1 -- obj.card:GetController("laizi").selectedIndex = 1
end -- end
end -- end
else -- else
if obj.card.GetController then -- if obj.card.GetController then
if obj.card:GetController("laizi") then -- if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 0 -- obj.card:GetController("laizi").selectedIndex = 0
end -- end
end -- end
end -- end
end -- end
end -- end
end -- end
print("====================================UpdateHandCard3")
local card_list = DataManager.CurrenRoom.self_player.card_list -- local card_list = DataManager.CurrenRoom.self_player.card_list
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
if getcard then -- if getcard then
self._out_card = true -- self._out_card = true
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) -- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
-- 记录需要标记听牌提示的牌 -- -- 记录需要标记听牌提示的牌
local lst_mark = {} -- local lst_mark = {}
local total_num = 0 -- local total_num = 0
for i = 1, #_carViewList do -- for i = 1, #_carViewList do
local btn = _carViewList[i].card -- local btn = _carViewList[i].card
local card = self:GetCard(btn) -- local card = self:GetCard(btn)
list_remove(card_list, card) -- list_remove(card_list, card)
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, -- local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true,
DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) -- DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi)
if #tingList > 0 then -- if #tingList > 0 then
local count = 0 -- local count = 0
for j = 1, #tingList do -- for j = 1, #tingList do
count = count + self._mainView:CountCardLeftNum(tingList[j]) -- count = count + self._mainView:CountCardLeftNum(tingList[j])
end -- end
local tem = {} -- local tem = {}
tem.item = btn -- tem.item = btn
tem.count = count -- tem.count = count
total_num = total_num + count -- total_num = total_num + count
table.insert(lst_mark, tem) -- table.insert(lst_mark, tem)
end -- end
table.insert(card_list, card) -- table.insert(card_list, card)
end -- end
table.sort(lst_mark, function(a, b) -- table.sort(lst_mark, function(a, b)
return a.count > b.count -- return a.count > b.count
end) -- end)
-- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' -- -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false -- local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false
for i = 1, #lst_mark do -- for i = 1, #lst_mark do
local tem = lst_mark[i] -- local tem = lst_mark[i]
if all_same or tem.count < lst_mark[1].count then -- if all_same or tem.count < lst_mark[1].count then
tem.item:GetController("mark_ting").selectedIndex = 1 -- tem.item:GetController("mark_ting").selectedIndex = 1
else -- else
tem.item:GetController("mark_ting").selectedIndex = 2 -- tem.item:GetController("mark_ting").selectedIndex = 2
end -- end
end -- end
else -- else
for i = 1, #_carViewList do -- for i = 1, #_carViewList do
local btn = _carViewList[i].card -- local btn = _carViewList[i].card
if btn:GetController("mark_ting").selectedIndex ~= 0 then -- if btn:GetController("mark_ting").selectedIndex ~= 0 then
btn:GetController("mark_ting").selectedIndex = 0 -- btn:GetController("mark_ting").selectedIndex = 0
end -- end
end -- end
self._out_card = false -- self._out_card = false
end -- end
end end
function M:__OnClickHandCard(context) -- function M:__OnClickHandCard(context)
-- print("==========================__OnClickHandCard") -- local button = context.sender
local button = context.sender -- local _carViewList = self._carViewList
local _carViewList = self._carViewList -- local refresh = true
local refresh = true -- local card_list = {}
local card_list = {} -- for i = 1, #_carViewList do
for i = 1, #_carViewList do -- local btn = _carViewList[i].card
local btn = _carViewList[i].card -- local card = self:GetCard(btn)
local card = self:GetCard(btn) -- if btn ~= button and btn.selected == true then
if btn ~= button and btn.selected == true then -- if button.data.card_item == card then
if button.data.card_item == card then -- refresh = false
refresh = false -- else
else -- self._mainView:markOutCards(false, card)
self._mainView:markOutCards(false, card) -- end
end -- btn.selected = false
btn.selected = false -- end
end -- if not btn.selected then
if not btn.selected then -- table.insert(card_list, card)
table.insert(card_list, card) -- end
end -- end
end
if self._out_card then -- if self._out_card then
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
end -- end
-- 标记出牌 -- -- 标记出牌
if refresh then -- if refresh then
if button.selected then -- if button.selected then
self._mainView:markOutCards(true, button.data.card_item) -- self._mainView:markOutCards(true, button.data.card_item)
else -- else
self._mainView:markOutCards(false, button.data.card_item) -- self._mainView:markOutCards(false, button.data.card_item)
end -- end
end -- end
local _room = DataManager.CurrenRoom -- local _room = DataManager.CurrenRoom
if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then -- if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then
local card = button.data -- local card = button.data
self._mainView:OutCard(card.card_item) -- self._mainView:OutCard(card.card_item)
end -- end
end -- end
function M:__OnDragStart(card) -- function M:__OnDragStart(card)
local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) -- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list)
list_remove(card_list, card) -- list_remove(card_list, card)
-- self:ShowHuTip(card_list) -- -- self:ShowHuTip(card_list)
end -- end
function M:__OnDragEnd(context) -- function M:__OnDragEnd(context)
if self.outcard_button then -- if self.outcard_button then
self.outcard_button:Dispose() -- self.outcard_button:Dispose()
self.outcard_button = nil -- self.outcard_button = nil
end -- end
local button = context.sender -- local button = context.sender
--button:RemoveFromParent() -- --button:RemoveFromParent()
local card = button.data -- local card = button.data
local _room = DataManager.CurrenRoom -- local _room = DataManager.CurrenRoom
-- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) -- -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat)
if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then -- if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then
self._mainView:OutCard(card.card_item) -- self._mainView:OutCard(card.card_item)
button.touchable = false -- button.touchable = false
self.outcard_button = button -- self.outcard_button = button
else -- else
self._area_handcard_list:AddChildAt(button, card.index) -- self._area_handcard_list:AddChildAt(button, card.index)
button:TweenMove(card.old_postion, 0.2) -- button:TweenMove(card.old_postion, 0.2)
end -- end
end -- end
function M:CheckPlayerOnlineState() -- function M:CheckPlayerOnlineState()
local room = DataManager.CurrenRoom -- local room = DataManager.CurrenRoom
for i = 1, #room.player_list do -- for i = 1, #room.player_list do
if room.player_list[i].line_state == 0 then -- if room.player_list[i].line_state == 0 then
return false -- return false
end -- end
end -- end
return true -- return true
end -- end
function M:Clear(bskip) function M:Clear(bskip)
MJPlayerSelfCardInfoView.Clear(self)
--self._ctr_state.selectedIndex = 0 --self._ctr_state.selectedIndex = 0
self._area_fz_list.x = self._src_fz_list.x -- self._area_fz_list.x = self._src_fz_list.x
self._area_fz_list.y = self._src_fz_list.y -- self._area_fz_list.y = self._src_fz_list.y
self._area_fz_list.width = self._src_fz_list.z -- self._area_fz_list.width = self._src_fz_list.z
self._area_fz_list.height = self._src_fz_list.w -- self._area_fz_list.height = self._src_fz_list.w
self._area_fz_list:RemoveChildren(0, -1, true) -- self._area_fz_list:RemoveChildren(0, -1, true)
self._area_handcard_list:RemoveChildren(0, -1, true) -- self._area_handcard_list:RemoveChildren(0, -1, true)
self._area_outcard_list:RemoveChildren(0, -1, true) -- self._area_outcard_list:RemoveChildren(0, -1, true)
if bskip == nil or bskip == false then -- if bskip == nil or bskip == false then
self._mask_liangpai:RemoveChildren(0, -1, true) -- self._mask_liangpai:RemoveChildren(0, -1, true)
end -- end
for i = 1, #self._carViewList do -- for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose() -- self._carViewList[i].card:Dispose()
end -- end
self._carViewList = {} -- self._carViewList = {}
end end
return M return M