修改字牌

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()
local list_gamePlay = self._view:GetChild('list_gamePlay')
list_gamePlay:SetVirtual()
local playList = DataManager.groups:get(id).playList
local roomList = DataManager.groups:get(id).rooms
local playList = self._group.playList
local roomList = self._group.rooms
print("=========================playList,rooms")
pt(playList)
pt(roomList)
list_room.itemRenderer = function(index, obj)
if index < #roomList then
-- 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('game_type').text = string.format("房间-%s", roomList[index + 1].id)
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')
local roomCtr = ControllerManager.GetController(RoomController)
roomCtr:PublicJoinRoom(
Protocol.WEB_FG_MATCH_ROOM,
Protocol.WEB_FG_JOIN_ROOM,
roomList[index + 1].id,
true,
false,
function(response)
ViewUtil.CloseModalWait('join_room')
if (response.ReturnCode == -1) then
@ -374,7 +377,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
end
end,
id,
playList[index + 1].id
roomList[index + 1].pid
)
end)
else
@ -384,7 +387,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
-- obj:GetChild('Label_gameRule').title = gamePlay
obj:GetChild('game_type').text = playList[index - #roomList + 1].name
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')
local roomCtr = ControllerManager.GetController(RoomController)
fgCtr:FG_ChangeFag(id, DataManager.SelfUser.acc, 777777, function()
@ -436,6 +439,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
end)
end)
end
print("=======================why", list_room.numItems, #playList, #roomList)
list_room.numItems = #playList + #roomList
list_gamePlay.numItems = #playList + 1
end
@ -535,7 +539,6 @@ function M:OnUpdate()
ViewUtil.ErrorTip(res.ReturnCode, string.format('删除房间-%s失败', self._group.rooms[i].id))
else
self._roomNum = #self._group.rooms
self._group.update_room = false
end
end
)

View File

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

View File

@ -4,10 +4,10 @@ local CardCheck = import(".CardCheck")
local M = {}
--
function M.new(view,mainView)
setmetatable(MJPlayerSelfCardInfoView, {__index = MJPlayerCardInfoView})
setmetatable(M, {__index = MJPlayerSelfCardInfoView})
local self = setmetatable({},{__index = M})
function M.new(view, mainView)
setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView })
setmetatable(M, { __index = MJPlayerSelfCardInfoView })
local self = setmetatable({}, { __index = M })
self.class = "PlayerSelfCardInfoView"
self._view = view
self._mainView = mainView
@ -17,16 +17,16 @@ end
function M:ShowHuTip(card_list)
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 DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo>0 then
for i=1,#DataManager.CurrenRoom.laiziInfo do
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i],tingList)==false then
table.insert(tingList,DataManager.CurrenRoom.laiziInfo[i] )
end
end
end
if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then
for i = 1, #DataManager.CurrenRoom.laiziInfo do
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then
table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i])
end
end
end
end
self._mainView._hu_tip:FillData(tingList)
end
@ -35,30 +35,26 @@ function M:UpdateHandCard(getcard, mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
if DataManager.CurrenRoom.laiziInfo and #self._carViewList>0 then
for i=1,#self._carViewList do
local obj=self._carViewList[i]
if obj and obj.card then
if IsHasDictionary(obj.card_item,DataManager.CurrenRoom.laiziInfo) then
if obj.card.GetController then
if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex=1
end
end
else
if obj.card.GetController then
if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex=0
end
end
end
end
end
end
if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then
for i = 1, #self._carViewList do
local obj = self._carViewList[i]
if obj and obj.card then
if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then
if obj.card.GetController then
if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 1
end
end
else
if obj.card.GetController then
if obj.card:GetController("laizi") then
obj.card:GetController("laizi").selectedIndex = 0
end
end
end
end
end
end
local card_list = DataManager.CurrenRoom.self_player.card_list
@ -73,7 +69,8 @@ function M:UpdateHandCard(getcard, mp)
local btn = _carViewList[i].card
local card = self:GetCard(btn)
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
local count = 0
for j = 1, #tingList do
@ -92,7 +89,7 @@ function M:UpdateHandCard(getcard, mp)
end)
-- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多'
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]
if all_same or tem.count < lst_mark[1].count then
tem.item:GetController("mark_ting").selectedIndex = 1
@ -109,7 +106,6 @@ function M:UpdateHandCard(getcard, mp)
end
self._out_card = false
end
end
function M:__OnClickHandCard(context)
@ -117,10 +113,10 @@ function M:__OnClickHandCard(context)
local _carViewList = self._carViewList
local refresh = true
local card_list = {}
for i=1,#_carViewList do
for i = 1, #_carViewList do
local btn = _carViewList[i].card
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
refresh = false
else
@ -160,10 +156,10 @@ function M:__OnDragStart(card)
end
function M:__OnDragEnd(context)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
local button = context.sender
--button:RemoveFromParent()
@ -190,6 +186,7 @@ function M:CheckPlayerOnlineState()
end
return true
end
function M:Clear(bskip)
--self._ctr_state.selectedIndex = 0
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)
end
for i=1,#self._carViewList do
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
end
return M

View File

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

View File

@ -1,37 +1,37 @@
local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
local CardView = {
card = nil,
-- 牌序号
card_item =0,
-- 索引
index = 0,
-- 原始位置
old_postion = Vector2.zero
card = nil,
-- 牌序号
card_item = 0,
-- 索引
index = 0,
-- 原始位置
old_postion = Vector2.zero
}
local function NewCardView(card,cardItem)
local function NewCardView(card, cardItem)
local self = {}
setmetatable(self,{__index = CardView})
setmetatable(self, { __index = CardView })
self.card = card
self.card_item = cardItem
return self
end
local PlayerSelfView = {
_dragCom=nil,
_dragCom = nil,
_carViewList = {}
}
local M = PlayerSelfView
function PlayerSelfView.new(view,mainView)
setmetatable(M,{__index = MJPlayerCardInfoView})
local self = setmetatable({}, {__index = M})
self._view = view
self._mainView = mainView
self:init()
return self
function PlayerSelfView.new(view, mainView)
setmetatable(M, { __index = MJPlayerCardInfoView })
local self = setmetatable({}, { __index = M })
self._view = view
self._mainView = mainView
self:init()
return self
end
function M:init()
@ -39,46 +39,46 @@ function M:init()
local filename = 'mjsize' .. DataManager.SelfUser.account_id
local json_data = Utils.LoadLocalFile(filename)
if json_data then
local _data = json.decode(json_data)
if _data.size==0 then
self._area_handcard_list:SetScale(1,1.1)
self._area_fz_list:SetScale(0.6,0.6)
elseif _data.size==1 then
self._area_handcard_list:SetScale(1,1)
self._area_fz_list:SetScale(1,1)
elseif _data.size==2 then
self._area_handcard_list:SetScale(0.8,0.8)
self._area_fz_list:SetScale(0.8,0.8)
if json_data then
local _data = json.decode(json_data)
if _data.size == 0 then
self._area_handcard_list:SetScale(1, 1.1)
self._area_fz_list:SetScale(0.6, 0.6)
elseif _data.size == 1 then
self._area_handcard_list:SetScale(1, 1)
self._area_fz_list:SetScale(1, 1)
elseif _data.size == 2 then
self._area_handcard_list:SetScale(0.8, 0.8)
self._area_fz_list:SetScale(0.8, 0.8)
end
end
end
end
function M:setHandCardPos(btn_card, i, getcard)
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0)
end
function M:UpdateHandCard(getcard,mp)
function M:UpdateHandCard(getcard, mp)
print("======================main", getcard, mp)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
getcard = getcard or false
mp = mp or false
mp = mp or false
local pv = self
local _carViewList = self._carViewList
local _lit = pv._area_handcard_list
for i=1,#_carViewList do
for i = 1, #_carViewList do
_carViewList[i].card:Dispose()
end
_carViewList = {}
local _dragCom = self._dragCom
if (_dragCom == nil) then
_dragCom = UIPackage.CreateObject("Common","UIPanel")
_dragCom.size = Vector2(1,1)
pv._view:AddChild(_dragCom)
_dragCom = UIPackage.CreateObject("Common", "UIPanel")
_dragCom.size = Vector2(1, 1)
pv._view:AddChild(_dragCom)
end
_dragCom.xy = pv._area_handcard_list.xy
self._dragCom = _dragCom
@ -91,61 +91,60 @@ function M:UpdateHandCard(getcard,mp)
local cards = DataManager.CurrenRoom.self_player.card_list
if (not mp) then
for i=0,(#cards)-1 do
local tem_card = cards[i+1]
for i = 0, (#cards) - 1 do
local tem_card = cards[i + 1]
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card"..b3d)
btn_card:SetScale(1.05,1.05)
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
self:fillCard(btn_card,"201_",tem_card)
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)
local c_v = NewCardView(btn_card, tem_card)
c_v.index = i
c_v.old_postion = btn_card.xy
_carViewList[#_carViewList+1] = c_v
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05, 1.05)
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
self:fillCard(btn_card, "201_", tem_card)
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)
local c_v = NewCardView(btn_card, tem_card)
c_v.index = i
c_v.old_postion = btn_card.xy
_carViewList[#_carViewList + 1] = c_v
_lit:AddChild(btn_card)
_lit:AddChild(btn_card)
if (not self._player.auto_out_card) then
btn_card.data = c_v
-- btn_card.draggable = true;
-- btn_card.onDragStart:Set(function(evt)
-- local _agent = evt.sender
-- _agent:RemoveFromParent()
-- _dragCom:AddChild(_agent)
-- if self.__OnDragStart then
-- self:__OnDragStart(evt)
-- end
-- _agent.onDragEnd:Set(self.__OnDragEnd,self)
-- end)
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard,self)
else
btn_card:GetChild("icon").color = Color(0.5,0.5,0.5)
btn_card.touchable = false
end
end
if (not self._player.auto_out_card) then
btn_card.data = c_v
-- btn_card.draggable = true;
-- btn_card.onDragStart:Set(function(evt)
-- local _agent = evt.sender
-- _agent:RemoveFromParent()
-- _dragCom:AddChild(_agent)
-- if self.__OnDragStart then
-- self:__OnDragStart(evt)
-- end
-- _agent.onDragEnd:Set(self.__OnDragEnd,self)
-- end)
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard, self)
else
btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5)
btn_card.touchable = false
end
end
else
for i=0,(#cards)-1 do
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card"..b3d)
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
self:fillCard(mp_card,"202_",cards[i+1])
mp_card:SetScale(1.05,1.05)
-- 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)
_lit:AddChild(mp_card)
end
for i = 0, (#cards) - 1 do
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card" .. b3d)
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
self:fillCard(mp_card, "202_", cards[i + 1])
mp_card:SetScale(1.05, 1.05)
-- 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)
_lit:AddChild(mp_card)
end
end
end
function M:onTouchBegin(context)
local button = context.sender
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
if self.__OnDragStart then
self:__OnDragStart(card.card_item)
@ -155,7 +154,7 @@ end
function M:onTouchMove(context)
local button = context.sender
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
end
@ -164,37 +163,37 @@ function M:__OnDragEnd(context)
self.outcard_button:Dispose()
self.outcard_button = nil
end
local button = context.sender
-- button.onDragEnd:Set(nil)
--button:RemoveFromParent()
local card = button.data
local _room = DataManager.CurrenRoom
if not _room or _room:GetReloadStatus() then return end
local button = context.sender
-- button.onDragEnd:Set(nil)
--button:RemoveFromParent()
local card = button.data
local _room = DataManager.CurrenRoom
if not _room or _room:GetReloadStatus() then return end
-- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat)
if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then
self._mainView:OutCard(card.card_item)
button.touchable = false
self.outcard_button = buttond
else
self._area_handcard_list:AddChildAt(button, card.index)
button:TweenMove(card.old_postion, 0.2)
end
-- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat)
if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then
self._mainView:OutCard(card.card_item)
button.touchable = false
self.outcard_button = buttond
else
self._area_handcard_list:AddChildAt(button, card.index)
button:TweenMove(card.old_postion, 0.2)
end
end
function M:__OnClickHandCard(context)
local button = context.sender
local _carViewList = self._carViewList
for i=1,#_carViewList do
if (_carViewList[i].card ~= button) then
_carViewList[i].card.selected = false
end
end
local _room = DataManager.CurrenRoom
if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then
local card = button.data
self._mainView:OutCard(card.card_item)
end
local button = context.sender
local _carViewList = self._carViewList
for i = 1, #_carViewList do
if (_carViewList[i].card ~= button) then
_carViewList[i].card.selected = false
end
end
local _room = DataManager.CurrenRoom
if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then
local card = button.data
self._mainView:OutCard(card.card_item)
end
end
-- 获取手牌资源位置,可以在扩展中复写
@ -204,7 +203,7 @@ end
function M:Clear()
MJPlayerCardInfoView.Clear(self)
for i=1,#self._carViewList do
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB