修改字牌

master
罗家炜 2025-04-01 13:56:18 +08:00
parent 623618f78e
commit ec8e4f9cd5
8 changed files with 194 additions and 197 deletions

View File

@ -341,8 +341,11 @@ function M:UpdateFamilyRoom(fgCtr, id)
list_room:SetVirtual() list_room:SetVirtual()
local list_gamePlay = self._view:GetChild('list_gamePlay') local list_gamePlay = self._view:GetChild('list_gamePlay')
list_gamePlay:SetVirtual() list_gamePlay:SetVirtual()
local playList = DataManager.groups:get(id).playList local playList = self._group.playList
local roomList = DataManager.groups:get(id).rooms local roomList = self._group.rooms
print("=========================playList,rooms")
pt(playList)
pt(roomList)
list_room.itemRenderer = function(index, obj) list_room.itemRenderer = function(index, obj)
if index < #roomList then if index < #roomList then
-- local config = ExtendManager.GetExtendConfig(roomList[index + 1].pid) -- local config = ExtendManager.GetExtendConfig(roomList[index + 1].pid)
@ -351,13 +354,13 @@ function M:UpdateFamilyRoom(fgCtr, id)
-- obj:GetChild('Label_gameRule').title = gamePlay -- obj:GetChild('Label_gameRule').title = gamePlay
obj:GetChild('game_type').text = string.format("房间-%s", roomList[index + 1].id) obj:GetChild('game_type').text = string.format("房间-%s", roomList[index + 1].id)
obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 1 obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 1
obj:GetChild('btn_joinGame').onClick:Add(function() obj:GetChild('btn_joinGame').onClick:Set(function()
ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room') ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room')
local roomCtr = ControllerManager.GetController(RoomController) local roomCtr = ControllerManager.GetController(RoomController)
roomCtr:PublicJoinRoom( roomCtr:PublicJoinRoom(
Protocol.WEB_FG_MATCH_ROOM, Protocol.WEB_FG_JOIN_ROOM,
roomList[index + 1].id, roomList[index + 1].id,
true, false,
function(response) function(response)
ViewUtil.CloseModalWait('join_room') ViewUtil.CloseModalWait('join_room')
if (response.ReturnCode == -1) then if (response.ReturnCode == -1) then
@ -374,7 +377,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
end end
end, end,
id, id,
playList[index + 1].id roomList[index + 1].pid
) )
end) end)
else else
@ -384,7 +387,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
-- obj:GetChild('Label_gameRule').title = gamePlay -- obj:GetChild('Label_gameRule').title = gamePlay
obj:GetChild('game_type').text = playList[index - #roomList + 1].name obj:GetChild('game_type').text = playList[index - #roomList + 1].name
obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 0 obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 0
obj:GetChild('btn_joinGame').onClick:Add(function() obj:GetChild('btn_joinGame').onClick:Set(function()
ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room') ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room')
local roomCtr = ControllerManager.GetController(RoomController) local roomCtr = ControllerManager.GetController(RoomController)
fgCtr:FG_ChangeFag(id, DataManager.SelfUser.acc, 777777, function() fgCtr:FG_ChangeFag(id, DataManager.SelfUser.acc, 777777, function()
@ -436,6 +439,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
end) end)
end) end)
end end
print("=======================why", list_room.numItems, #playList, #roomList)
list_room.numItems = #playList + #roomList list_room.numItems = #playList + #roomList
list_gamePlay.numItems = #playList + 1 list_gamePlay.numItems = #playList + 1
end end
@ -535,7 +539,6 @@ function M:OnUpdate()
ViewUtil.ErrorTip(res.ReturnCode, string.format('删除房间-%s失败', self._group.rooms[i].id)) ViewUtil.ErrorTip(res.ReturnCode, string.format('删除房间-%s失败', self._group.rooms[i].id))
else else
self._roomNum = #self._group.rooms self._roomNum = #self._group.rooms
self._group.update_room = false
end end
end end
) )

View File

@ -106,7 +106,7 @@ end
function M:Show() function M:Show()
BaseView.Show(self) BaseView.Show(self)
-- self:QuickLogin() self:QuickLogin()
end end
local function __goto_lobby(response) local function __goto_lobby(response)

View File

@ -4,10 +4,10 @@ local CardCheck = import(".CardCheck")
local M = {} local M = {}
-- --
function M.new(view,mainView) function M.new(view, mainView)
setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView}) setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView })
setmetatable(M, {__index = MJPlayerSelfCardInfoView}) setmetatable(M, { __index = MJPlayerSelfCardInfoView })
local self = setmetatable({},{__index = M}) local self = setmetatable({}, { __index = M })
self.class = "PlayerSelfCardInfoView" self.class = "PlayerSelfCardInfoView"
self._view = view self._view = view
self._mainView = mainView self._mainView = mainView
@ -17,16 +17,16 @@ 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, DataManager.CurrenRoom.room_config.Laizi) local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui,
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
@ -35,29 +35,25 @@ 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
@ -73,7 +69,8 @@ function M:UpdateHandCard(getcard, mp)
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, DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true,
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
@ -109,7 +106,6 @@ function M:UpdateHandCard(getcard, mp)
end end
self._out_card = false self._out_card = false
end end
end end
function M:__OnClickHandCard(context) function M:__OnClickHandCard(context)
@ -117,7 +113,7 @@ function M:__OnClickHandCard(context)
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
@ -190,6 +186,7 @@ function M:CheckPlayerOnlineState()
end end
return true return true
end end
function M:Clear(bskip) function M:Clear(bskip)
--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
@ -204,10 +201,10 @@ function M:Clear(bskip)
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

@ -20,7 +20,7 @@ local M = PlayerCardInfoView
--- Create a new PlayerCardInfoView --- Create a new PlayerCardInfoView
function M.new(view, mainView) function M.new(view, mainView)
local self = {} local self = {}
setmetatable(self, {__index = M}) setmetatable(self, { __index = M })
self._view = view self._view = view
self._mainView = mainView self._mainView = mainView
self:init() self:init()
@ -56,13 +56,11 @@ function M:init()
if _gamectr then if _gamectr then
_gamectr:AddEventListener(GameEvent.MJModifySzie, handler(self, self.SetMJSize)) _gamectr:AddEventListener(GameEvent.MJModifySzie, handler(self, self.SetMJSize))
end end
end end
function M:SetMJSize(zS) function M:SetMJSize(zS)
local tempSzieConfig={} local tempSzieConfig = {}
tempSzieConfig.size=zS tempSzieConfig.size = zS
local filename = 'mjsize' .. DataManager.SelfUser.account_id local filename = 'mjsize' .. DataManager.SelfUser.account_id
Utils.SaveLocalFile(filename, json.encode(tempSzieConfig)) Utils.SaveLocalFile(filename, json.encode(tempSzieConfig))
@ -119,12 +117,12 @@ function M:GetPrefix()
end end
function M:fillCard(obj, pos_str, card, use3d) function M:fillCard(obj, pos_str, card, use3d)
if self._current_card_type == 2 and (use3d == nil or use3d == true) then if self._current_card_type == 2 and (use3d == nil or use3d == true) then
obj.icon = 'ui://MajiangCard3d/' .. 'b' .. pos_str .. card obj.icon = 'ui://MajiangCard3d/' .. 'b' .. pos_str .. card
else else
obj.icon = 'ui://Main_Majiang/' .. self:GetPrefix() .. pos_str .. card obj.icon = 'ui://Main_Majiang/' .. self:GetPrefix() .. pos_str .. card
end end
print("================================fillCard", obj, pos_str, card, use3d, obj.icon)
end end
function M:getBackCard(card) function M:getBackCard(card)

View File

@ -3,31 +3,31 @@ local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
local CardView = { local CardView = {
card = nil, card = nil,
-- 牌序号 -- 牌序号
card_item =0, card_item = 0,
-- 索引 -- 索引
index = 0, index = 0,
-- 原始位置 -- 原始位置
old_postion = Vector2.zero old_postion = Vector2.zero
} }
local function NewCardView(card,cardItem) local function NewCardView(card, cardItem)
local self = {} local self = {}
setmetatable(self,{__index = CardView}) setmetatable(self, { __index = CardView })
self.card = card self.card = card
self.card_item = cardItem self.card_item = cardItem
return self return self
end end
local PlayerSelfView = { local PlayerSelfView = {
_dragCom=nil, _dragCom = nil,
_carViewList = {} _carViewList = {}
} }
local M = PlayerSelfView local M = PlayerSelfView
function PlayerSelfView.new(view,mainView) function PlayerSelfView.new(view, mainView)
setmetatable(M,{__index = MJPlayerCardInfoView}) setmetatable(M, { __index = MJPlayerCardInfoView })
local self = setmetatable({}, {__index = M}) local self = setmetatable({}, { __index = M })
self._view = view self._view = view
self._mainView = mainView self._mainView = mainView
self:init() self:init()
@ -41,16 +41,15 @@ function M:init()
local json_data = Utils.LoadLocalFile(filename) local json_data = Utils.LoadLocalFile(filename)
if json_data then if json_data then
local _data = json.decode(json_data) local _data = json.decode(json_data)
if _data.size==0 then if _data.size == 0 then
self._area_handcard_list:SetScale(1,1.1) self._area_handcard_list:SetScale(1, 1.1)
self._area_fz_list:SetScale(0.6,0.6) self._area_fz_list:SetScale(0.6, 0.6)
elseif _data.size==1 then elseif _data.size == 1 then
self._area_handcard_list:SetScale(1,1) self._area_handcard_list:SetScale(1, 1)
self._area_fz_list:SetScale(1,1) self._area_fz_list:SetScale(1, 1)
elseif _data.size == 2 then
elseif _data.size==2 then self._area_handcard_list:SetScale(0.8, 0.8)
self._area_handcard_list:SetScale(0.8,0.8) self._area_fz_list:SetScale(0.8, 0.8)
self._area_fz_list:SetScale(0.8,0.8)
end end
end end
end end
@ -59,7 +58,8 @@ function M:setHandCardPos(btn_card, i, getcard)
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0) btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0)
end end
function M:UpdateHandCard(getcard,mp) function M:UpdateHandCard(getcard, mp)
print("======================main", getcard, mp)
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
@ -70,14 +70,14 @@ function M:UpdateHandCard(getcard,mp)
local _carViewList = self._carViewList local _carViewList = self._carViewList
local _lit = pv._area_handcard_list local _lit = pv._area_handcard_list
for i=1,#_carViewList do for i = 1, #_carViewList do
_carViewList[i].card:Dispose() _carViewList[i].card:Dispose()
end end
_carViewList = {} _carViewList = {}
local _dragCom = self._dragCom local _dragCom = self._dragCom
if (_dragCom == nil) then if (_dragCom == nil) then
_dragCom = UIPackage.CreateObject("Common","UIPanel") _dragCom = UIPackage.CreateObject("Common", "UIPanel")
_dragCom.size = Vector2(1,1) _dragCom.size = Vector2(1, 1)
pv._view:AddChild(_dragCom) pv._view:AddChild(_dragCom)
end end
_dragCom.xy = pv._area_handcard_list.xy _dragCom.xy = pv._area_handcard_list.xy
@ -91,19 +91,19 @@ function M:UpdateHandCard(getcard,mp)
local cards = DataManager.CurrenRoom.self_player.card_list local cards = DataManager.CurrenRoom.self_player.card_list
if (not mp) then if (not mp) then
for i=0,(#cards)-1 do for i = 0, (#cards) - 1 do
local tem_card = cards[i+1] local tem_card = cards[i + 1]
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card"..b3d) local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05,1.05) btn_card:SetScale(1.05, 1.05)
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card) -- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
self:fillCard(btn_card,"201_",tem_card) self:fillCard(btn_card, "201_", tem_card)
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard) self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)
local c_v = NewCardView(btn_card, tem_card) local c_v = NewCardView(btn_card, tem_card)
c_v.index = i c_v.index = i
c_v.old_postion = btn_card.xy c_v.old_postion = btn_card.xy
_carViewList[#_carViewList+1] = c_v _carViewList[#_carViewList + 1] = c_v
_lit:AddChild(btn_card) _lit:AddChild(btn_card)
@ -122,19 +122,18 @@ function M:UpdateHandCard(getcard,mp)
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard,self) btn_card.onClick:Set(self.__OnClickHandCard, self)
else else
btn_card:GetChild("icon").color = Color(0.5,0.5,0.5) btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5)
btn_card.touchable = false btn_card.touchable = false
end end
end end
else else
for i=0,(#cards)-1 do for i = 0, (#cards) - 1 do
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card" .. b3d)
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card"..b3d)
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1]) -- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
self:fillCard(mp_card,"202_",cards[i+1]) self:fillCard(mp_card, "202_", cards[i + 1])
mp_card:SetScale(1.05,1.05) mp_card:SetScale(1.05, 1.05)
-- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0) -- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0)
self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard) self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard)
_lit:AddChild(mp_card) _lit:AddChild(mp_card)
@ -145,7 +144,7 @@ end
function M:onTouchBegin(context) function M:onTouchBegin(context)
local button = context.sender local button = context.sender
local card = button.data local card = button.data
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
card.touch_pos = xy - button.xy card.touch_pos = xy - button.xy
if self.__OnDragStart then if self.__OnDragStart then
self:__OnDragStart(card.card_item) self:__OnDragStart(card.card_item)
@ -155,7 +154,7 @@ end
function M:onTouchMove(context) function M:onTouchMove(context)
local button = context.sender local button = context.sender
local card = button.data local card = button.data
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
button.xy = xy - card.touch_pos button.xy = xy - card.touch_pos
end end
@ -185,7 +184,7 @@ 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
for i=1,#_carViewList do for i = 1, #_carViewList do
if (_carViewList[i].card ~= button) then if (_carViewList[i].card ~= button) then
_carViewList[i].card.selected = false _carViewList[i].card.selected = false
end end
@ -204,7 +203,7 @@ end
function M:Clear() function M:Clear()
MJPlayerCardInfoView.Clear(self) MJPlayerCardInfoView.Clear(self)
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 = {}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB