黎川添加全球人,showNext只点击一次,结束时展示小结算

master
罗家炜 2025-04-16 15:52:21 +08:00
parent 0d39226ccb
commit ddf0979dbe
19 changed files with 478 additions and 213 deletions

View File

@ -448,9 +448,7 @@ function M:Show()
if user.group_id ~= 0 then
local msg_tip = MsgWindow.new(self._root_view, "还在圈子的房间中,现在重连吗?", MsgWindow.MsgMode.OkAndCancel)
msg_tip.onOk:Add(function()
if self.groupMainView ~= nil then
self.groupMainView:Show(user.group_id)
end
self:ReconnectRoom(user.group_id)
end)
msg_tip:Show()
tem.auto_show = false
@ -513,3 +511,35 @@ function M:OnApplicationActive()
end
end
end
-----------------------lingmeng----------------------------
function M:ReconnectRoom(groupId)
local roomId = DataManager.SelfUser.room_id
print("===============================ReconnectRoom", roomId, 1)
if roomId and #roomId > 0 then
local roomCtr = ControllerManager.GetController(RoomController)
roomCtr:PublicJoinRoom(
Protocol.WEB_FG_JOIN_ROOM,
roomId,
false,
function(response)
if (response.ReturnCode == -1) then
ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, 'response.ReturnCode == -1')
RestartGame()
return
end
if response.ReturnCode ~= 0 then
ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败')
ViewManager.ChangeView(ViewManager.View_Family)
return
else
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
end
end,
groupId
)
end
end
-----------------------------------------------------------

View File

@ -6,6 +6,9 @@ local SettingView = import('.SettingView')
local PlayerDistanceView = import('.PlayerDistanceView')
local FGAssistView = import('.FGAssistView')
--lingmeng新全局标记
lingmengxin = true
-- MainView
MainView = {}

View File

@ -1,15 +1,16 @@
local CS_Win_Type = {
"点炮",
"自摸",
"十三烂",
"七星十三烂",
"碰碰胡",
"七小对",
"天胡",
"地胡",
"平胡",
"德国",
"抢杠胡",
"杠上花",
"点炮",
"自摸",
"十三烂",
"七星十三烂",
"碰碰胡",
"七小对",
"天胡",
"地胡",
"平胡",
"德国",
"抢杠胡",
"杠上花",
"全求人"
}
return CS_Win_Type

View File

@ -40,6 +40,7 @@ function M:InitData(over, room, result, total_result, callback)
local _overCtr = self._view:GetController("over")
local mainCtr = self._view:GetController("main")
local playerNum = self._view:GetController("playerNum")
local showBtnTypeCtr = self._view:GetController("showType")
local peopleNum = room.room_config.people_num
@ -55,22 +56,27 @@ function M:InitData(over, room, result, total_result, callback)
self:DestroyWithCallback()
end)
nextRoundBtn2.onClick:Set(function()
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:PlayerReady()
self:DestroyWithCallback()
end)
endRound.onClick:Set(function()
ViewManager.ChangeView(ViewManager.View_Family)
end)
self:fillResult0(room, peopleNum, result)
if over == 0 then
showBtnTypeCtr.selectedIndex = 0
_overCtr.selectedIndex = 0
self:fillResult0(room, peopleNum, result)
nextRoundBtn2.onClick:Set(function()
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:PlayerReady()
self:DestroyWithCallback()
end)
else
_overCtr.selectedIndex = 1
showBtnTypeCtr.selectedIndex = 1
self:fillResult1(room, peopleNum, total_result)
nextRoundBtn2.onClick:Set(function()
_overCtr.selectedIndex = 1
end)
end
end

View File

@ -66,7 +66,12 @@ function M:InitView(url)
self._showNextName = nil
end)
showNextList.onClickItem:Set(function(context)
self:ClickShowNext(context, ShowNextConfrimCtr)
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendNextCard(string.sub(context.data.name, -3))
showNextCtr.selectedIndex = 0
showNextList.selectedIndex = -1
self._showNextName = nil
-- self:ClickShowNext(context, ShowNextConfrimCtr)
end)
ShowNextConfrimCtr.onChanged:Set(function()
pop_showNextConfrim:GetChild("btn_ShowCard").icon = self._showNextName
@ -405,7 +410,6 @@ function M:EventInit()
local tem = win_list[i]
if tem.type > 0 and tem.type < 32 then
local com_name = "he" .. tem.type
-- print("===================================com_name", com_name)
local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_LiChuan/" .. com_name)
coroutine.wait(0.3)
end

View File

@ -1,5 +1,5 @@
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJPlayerCardInfoView = require(".MJPlayerCardInfoView")
local MJMainView = require("main.majiang.MJMainView")
local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent")
@ -54,6 +54,10 @@ function M:InitView(url)
local showNextList = self._view:GetChild('list_showNext')
local pop_showNextConfrim = self._view:GetChild('pop_showNextConfrim')
local btn_closeRoom = self._view:GetChild("btn_setting")
local conterBoxComp = self._view:GetChild("Comp_ConterBox")
self._ctr_cardbox = conterBoxComp:GetController("type")
self._tex_leftTime = conterBoxComp:GetChild("Text_Time")
self._view:GetChild('btn_closeRoom').onClick:Set(function()
---[[
@ -199,8 +203,9 @@ function M:InitPlayerInfoView()
self._player_info = {}
local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do
print("================================InitPlayerInfoView", string.format("player_info%d_1", i))
local tem = self._view:GetChild(string.format("player_info%d_1", i))
print("================================InitPlayerInfoView",
string.format("player_info%d_%d", i, self._state.selectedIndex + 1))
local tem = self._view:GetChild(string.format("player_info%d_%d", i, self._state.selectedIndex + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false
end
@ -877,17 +882,6 @@ function M:PlayerChangeLineState()
-- self._player_card_info[1]._area_handcard_list.touchable = isOutCard
end
function M:UpdateCardBox(seat)
local index = seat
local people_num = self._room.room_config.people_num
if people_num == 2 and seat == 2 then
index = 3
elseif people_num == 3 and seat == 3 then
index = 4
end
self._ctr_cardbox.selectedIndex = index
end
-----------------------lingmeng----------------------------
function M:SendShowNext(ShowNextConfrimCtr)
if not self._showNextName then
@ -908,15 +902,20 @@ 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
print("==============================UpdatePlayerInfoView",
string.format("player_info%d_%d", i, self._state.selectedIndex + 1))
local tem = self._view:GetChild(string.format("player_info%d_%d", i, self._state.selectedIndex + 1))
_player_info[i] = PlayerInfoView.new(tem, self)
_player_info[i]:FillData(list[i])
end
end
function M:UpdateCardBox(seat)
local index = seat
self._ctr_cardbox.selectedIndex = index - 1
end
-----------------------------------------------------------

View File

@ -60,7 +60,9 @@ function M:FillRoomConfig(room, _config)
end
function M:FillRoomData(s2croom)
print("==========================FillRoomData1")
local room = DataManager.CurrenRoom
pt(room)
local reload = s2croom["reload"]
@ -108,8 +110,10 @@ function M:FillRoomData(s2croom)
fz.card = op["card"]
p.fz_list[#p.fz_list + 1] = fz
end
print("=======================在此进入", playing)
if not playing and room.curren_round > 0 then
-- print("=======================在此进入")
print("=======================在此进入")
self.GetGameController():PlayerReady()
end
end

View File

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

View File

@ -33,6 +33,7 @@ function M:ShowHuTip(card_list)
end
function M:UpdateHandCard(getcard, mp)
print("====================================UpdateHandCard1", mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
@ -57,7 +58,7 @@ function M:UpdateHandCard(getcard, mp)
end
end
print("====================================UpdateHandCard3")
local card_list = DataManager.CurrenRoom.self_player.card_list
self:ShowHuTip(card_list)
if getcard then

View File

@ -138,6 +138,8 @@ function M:GetCard(btn)
end
function M:UpdateHandCard(getcard, mp)
print("====================================UpdateHandCard4")
getcard = getcard or false
mp = mp or false
local handcard_list = self._mask_data['handcard_list']

View File

@ -1,225 +1,227 @@
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 self = {}
setmetatable(self, { __index = CardView })
self.card = card
self.card_item = cardItem
return self
local self = {}
setmetatable(self, { __index = CardView })
self.card = card
self.card_item = cardItem
return self
end
local PlayerSelfView = {
_dragCom = nil,
_carViewList = {}
_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
setmetatable(M, { __index = MJPlayerCardInfoView })
local self = setmetatable({}, { __index = M })
self._view = view
self._mainView = mainView
self:init()
return self
end
function M:init()
MJPlayerCardInfoView.init(self)
MJPlayerCardInfoView.init(self)
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)
end
end
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)
end
end
end
function M:setHandCardPos(btn_card, i, getcard)
if DataManager.CurrenRoom.room_config.people_num == 2 then
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
elseif DataManager.CurrenRoom.room_config.people_num == 4 then
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
else
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0)
end
if DataManager.CurrenRoom.room_config.people_num == 2 then
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
elseif DataManager.CurrenRoom.room_config.people_num == 4 then
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
else
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0)
end
end
function M:UpdateHandCard(getcard, mp)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
getcard = getcard or false
mp = mp or false
local pv = self
local _carViewList = self._carViewList
print("====================================UpdateHandCard2")
local _lit = pv._area_handcard_list
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)
end
_dragCom.xy = pv._area_handcard_list.xy
self._dragCom = _dragCom
self._carViewList = _carViewList
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil
end
getcard = getcard or false
mp = mp or false
local pv = self
local _carViewList = self._carViewList
local b3d = ""
if self._current_card_type == 2 then
b3d = "_3d"
end
local _lit = pv._area_handcard_list
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)
end
_dragCom.xy = pv._area_handcard_list.xy
self._dragCom = _dragCom
self._carViewList = _carViewList
local _room = DataManager.CurrenRoom
local cards = _room.self_player.card_list
local b3d = ""
if self._current_card_type == 2 then
b3d = "_3d"
end
if (not mp) then
for i = 0, (#cards) - 1 do
local tem_card = cards[i + 1]
local btn_card = nil
if _room.room_config.people_num == 2 then
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d)
elseif _room.room_config.people_num == 4 then
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_new_4" .. b3d)
else
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05, 1.05)
end
local _room = DataManager.CurrenRoom
local cards = _room.self_player.card_list
-- 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
if (not mp) then
for i = 0, (#cards) - 1 do
local tem_card = cards[i + 1]
local btn_card = nil
if _room.room_config.people_num == 2 then
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d)
elseif _room.room_config.people_num == 4 then
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_new_4" .. b3d)
else
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05, 1.05)
end
_lit:AddChild(btn_card)
-- 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
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
end
_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
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
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))
card.touch_pos = xy - button.xy
if self.__OnDragStart then
self:__OnDragStart(card.card_item)
end
local button = context.sender
local card = button.data
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)
end
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))
button.xy = xy - card.touch_pos
local button = context.sender
local card = button.data
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
button.xy = xy - card.touch_pos
end
function M:__OnDragEnd(context)
if self.outcard_button then
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
if self.outcard_button then
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
-- -- 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
-- 获取手牌资源位置,可以在扩展中复写
function M:GetCardObjPack()
return "Main_Majiang"
return "Main_Majiang"
end
function M:Clear()
MJPlayerCardInfoView.Clear(self)
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
MJPlayerCardInfoView.Clear(self)
for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose()
end
self._carViewList = {}
end
return M

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 KiB

After

Width:  |  Height:  |  Size: 820 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 KiB

After

Width:  |  Height:  |  Size: 256 KiB