黎川添加全球人,showNext只点击一次,结束时展示小结算
|
|
@ -448,9 +448,7 @@ function M:Show()
|
||||||
if user.group_id ~= 0 then
|
if user.group_id ~= 0 then
|
||||||
local msg_tip = MsgWindow.new(self._root_view, "还在圈子的房间中,现在重连吗?", MsgWindow.MsgMode.OkAndCancel)
|
local msg_tip = MsgWindow.new(self._root_view, "还在圈子的房间中,现在重连吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
msg_tip.onOk:Add(function()
|
msg_tip.onOk:Add(function()
|
||||||
if self.groupMainView ~= nil then
|
self:ReconnectRoom(user.group_id)
|
||||||
self.groupMainView:Show(user.group_id)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
msg_tip:Show()
|
msg_tip:Show()
|
||||||
tem.auto_show = false
|
tem.auto_show = false
|
||||||
|
|
@ -513,3 +511,35 @@ function M:OnApplicationActive()
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ local SettingView = import('.SettingView')
|
||||||
local PlayerDistanceView = import('.PlayerDistanceView')
|
local PlayerDistanceView = import('.PlayerDistanceView')
|
||||||
local FGAssistView = import('.FGAssistView')
|
local FGAssistView = import('.FGAssistView')
|
||||||
|
|
||||||
|
--lingmeng新全局标记
|
||||||
|
lingmengxin = true
|
||||||
|
|
||||||
-- MainView
|
-- MainView
|
||||||
MainView = {}
|
MainView = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
local CS_Win_Type = {
|
local CS_Win_Type = {
|
||||||
"点炮",
|
"点炮",
|
||||||
"自摸",
|
"自摸",
|
||||||
"十三烂",
|
"十三烂",
|
||||||
"七星十三烂",
|
"七星十三烂",
|
||||||
"碰碰胡",
|
"碰碰胡",
|
||||||
"七小对",
|
"七小对",
|
||||||
"天胡",
|
"天胡",
|
||||||
"地胡",
|
"地胡",
|
||||||
"平胡",
|
"平胡",
|
||||||
"德国",
|
"德国",
|
||||||
"抢杠胡",
|
"抢杠胡",
|
||||||
"杠上花",
|
"杠上花",
|
||||||
|
"全求人"
|
||||||
}
|
}
|
||||||
return CS_Win_Type
|
return CS_Win_Type
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ function M:InitData(over, room, result, total_result, callback)
|
||||||
local _overCtr = self._view:GetController("over")
|
local _overCtr = self._view:GetController("over")
|
||||||
local mainCtr = self._view:GetController("main")
|
local mainCtr = self._view:GetController("main")
|
||||||
local playerNum = self._view:GetController("playerNum")
|
local playerNum = self._view:GetController("playerNum")
|
||||||
|
local showBtnTypeCtr = self._view:GetController("showType")
|
||||||
|
|
||||||
local peopleNum = room.room_config.people_num
|
local peopleNum = room.room_config.people_num
|
||||||
|
|
||||||
|
|
@ -55,22 +56,27 @@ function M:InitData(over, room, result, total_result, callback)
|
||||||
self:DestroyWithCallback()
|
self:DestroyWithCallback()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
nextRoundBtn2.onClick:Set(function()
|
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
|
||||||
_gamectr:PlayerReady()
|
|
||||||
self:DestroyWithCallback()
|
|
||||||
end)
|
|
||||||
|
|
||||||
endRound.onClick:Set(function()
|
endRound.onClick:Set(function()
|
||||||
ViewManager.ChangeView(ViewManager.View_Family)
|
ViewManager.ChangeView(ViewManager.View_Family)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
self:fillResult0(room, peopleNum, result)
|
||||||
if over == 0 then
|
if over == 0 then
|
||||||
|
showBtnTypeCtr.selectedIndex = 0
|
||||||
_overCtr.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
|
else
|
||||||
_overCtr.selectedIndex = 1
|
showBtnTypeCtr.selectedIndex = 1
|
||||||
self:fillResult1(room, peopleNum, total_result)
|
self:fillResult1(room, peopleNum, total_result)
|
||||||
|
nextRoundBtn2.onClick:Set(function()
|
||||||
|
_overCtr.selectedIndex = 1
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,12 @@ function M:InitView(url)
|
||||||
self._showNextName = nil
|
self._showNextName = nil
|
||||||
end)
|
end)
|
||||||
showNextList.onClickItem:Set(function(context)
|
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)
|
end)
|
||||||
ShowNextConfrimCtr.onChanged:Set(function()
|
ShowNextConfrimCtr.onChanged:Set(function()
|
||||||
pop_showNextConfrim:GetChild("btn_ShowCard").icon = self._showNextName
|
pop_showNextConfrim:GetChild("btn_ShowCard").icon = self._showNextName
|
||||||
|
|
@ -405,7 +410,6 @@ function M:EventInit()
|
||||||
local tem = win_list[i]
|
local tem = win_list[i]
|
||||||
if tem.type > 0 and tem.type < 32 then
|
if tem.type > 0 and tem.type < 32 then
|
||||||
local com_name = "he" .. tem.type
|
local com_name = "he" .. tem.type
|
||||||
-- print("===================================com_name", com_name)
|
|
||||||
local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_LiChuan/" .. com_name)
|
local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_LiChuan/" .. com_name)
|
||||||
coroutine.wait(0.3)
|
coroutine.wait(0.3)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
|
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
|
||||||
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
|
local MJPlayerCardInfoView = require(".MJPlayerCardInfoView")
|
||||||
local MJMainView = require("main.majiang.MJMainView")
|
local MJMainView = require("main.majiang.MJMainView")
|
||||||
local EXClearingView = import(".EXClearingView")
|
local EXClearingView = import(".EXClearingView")
|
||||||
local TX_GameEvent = import(".GameEvent")
|
local TX_GameEvent = import(".GameEvent")
|
||||||
|
|
@ -54,6 +54,10 @@ function M:InitView(url)
|
||||||
local showNextList = self._view:GetChild('list_showNext')
|
local showNextList = self._view:GetChild('list_showNext')
|
||||||
local pop_showNextConfrim = self._view:GetChild('pop_showNextConfrim')
|
local pop_showNextConfrim = self._view:GetChild('pop_showNextConfrim')
|
||||||
local btn_closeRoom = self._view:GetChild("btn_setting")
|
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()
|
self._view:GetChild('btn_closeRoom').onClick:Set(function()
|
||||||
---[[
|
---[[
|
||||||
|
|
@ -199,8 +203,9 @@ 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
|
||||||
print("================================InitPlayerInfoView", string.format("player_info%d_1", i))
|
print("================================InitPlayerInfoView",
|
||||||
local tem = self._view:GetChild(string.format("player_info%d_1", i))
|
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] = PlayerInfoView.new(tem, self)
|
||||||
tem.visible = false
|
tem.visible = false
|
||||||
end
|
end
|
||||||
|
|
@ -877,17 +882,6 @@ function M:PlayerChangeLineState()
|
||||||
-- self._player_card_info[1]._area_handcard_list.touchable = isOutCard
|
-- self._player_card_info[1]._area_handcard_list.touchable = isOutCard
|
||||||
end
|
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----------------------------
|
-----------------------lingmeng----------------------------
|
||||||
function M:SendShowNext(ShowNextConfrimCtr)
|
function M:SendShowNext(ShowNextConfrimCtr)
|
||||||
if not self._showNextName then
|
if not self._showNextName then
|
||||||
|
|
@ -908,15 +902,20 @@ end
|
||||||
function M:UpdatePlayerInfoView()
|
function M:UpdatePlayerInfoView()
|
||||||
self._player_info = {}
|
self._player_info = {}
|
||||||
local _player_info = 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
|
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))
|
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] = PlayerInfoView.new(tem, self)
|
||||||
|
_player_info[i]:FillData(list[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M:UpdateCardBox(seat)
|
||||||
|
local index = seat
|
||||||
|
self._ctr_cardbox.selectedIndex = index - 1
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ function M:FillRoomConfig(room, _config)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:FillRoomData(s2croom)
|
function M:FillRoomData(s2croom)
|
||||||
|
print("==========================FillRoomData1")
|
||||||
local room = DataManager.CurrenRoom
|
local room = DataManager.CurrenRoom
|
||||||
|
pt(room)
|
||||||
|
|
||||||
|
|
||||||
local reload = s2croom["reload"]
|
local reload = s2croom["reload"]
|
||||||
|
|
@ -108,8 +110,10 @@ function M:FillRoomData(s2croom)
|
||||||
fz.card = op["card"]
|
fz.card = op["card"]
|
||||||
p.fz_list[#p.fz_list + 1] = fz
|
p.fz_list[#p.fz_list + 1] = fz
|
||||||
end
|
end
|
||||||
|
print("=======================在此进入", playing)
|
||||||
|
|
||||||
if not playing and room.curren_round > 0 then
|
if not playing and room.curren_round > 0 then
|
||||||
-- print("=======================在此进入")
|
print("=======================在此进入")
|
||||||
self.GetGameController():PlayerReady()
|
self.GetGameController():PlayerReady()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -33,6 +33,7 @@ function M:ShowHuTip(card_list)
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -57,7 +58,7 @@ function M:UpdateHandCard(getcard, mp)
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ function M:GetCard(btn)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:UpdateHandCard(getcard, mp)
|
function M:UpdateHandCard(getcard, mp)
|
||||||
|
print("====================================UpdateHandCard4")
|
||||||
|
|
||||||
getcard = getcard or false
|
getcard = getcard or false
|
||||||
mp = mp or false
|
mp = mp or false
|
||||||
local handcard_list = self._mask_data['handcard_list']
|
local handcard_list = self._mask_data['handcard_list']
|
||||||
|
|
|
||||||
|
|
@ -1,225 +1,227 @@
|
||||||
local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
|
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()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:init()
|
function M:init()
|
||||||
MJPlayerCardInfoView.init(self)
|
MJPlayerCardInfoView.init(self)
|
||||||
|
|
||||||
local filename = 'mjsize' .. DataManager.SelfUser.account_id
|
local filename = 'mjsize' .. DataManager.SelfUser.account_id
|
||||||
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
|
||||||
|
|
||||||
function M:setHandCardPos(btn_card, i, getcard)
|
function M:setHandCardPos(btn_card, i, getcard)
|
||||||
if DataManager.CurrenRoom.room_config.people_num == 2 then
|
if DataManager.CurrenRoom.room_config.people_num == 2 then
|
||||||
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
|
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
|
||||||
elseif DataManager.CurrenRoom.room_config.people_num == 4 then
|
elseif DataManager.CurrenRoom.room_config.people_num == 4 then
|
||||||
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
|
btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0)
|
||||||
else
|
else
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:UpdateHandCard(getcard, mp)
|
function M:UpdateHandCard(getcard, mp)
|
||||||
if self.outcard_button then
|
print("====================================UpdateHandCard2")
|
||||||
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 _lit = pv._area_handcard_list
|
if self.outcard_button then
|
||||||
for i = 1, #_carViewList do
|
self.outcard_button:Dispose()
|
||||||
_carViewList[i].card:Dispose()
|
self.outcard_button = nil
|
||||||
end
|
end
|
||||||
_carViewList = {}
|
getcard = getcard or false
|
||||||
local _dragCom = self._dragCom
|
mp = mp or false
|
||||||
if (_dragCom == nil) then
|
local pv = self
|
||||||
_dragCom = UIPackage.CreateObject("Common", "UIPanel")
|
local _carViewList = self._carViewList
|
||||||
_dragCom.size = Vector2(1, 1)
|
|
||||||
pv._view:AddChild(_dragCom)
|
|
||||||
end
|
|
||||||
_dragCom.xy = pv._area_handcard_list.xy
|
|
||||||
self._dragCom = _dragCom
|
|
||||||
self._carViewList = _carViewList
|
|
||||||
|
|
||||||
local b3d = ""
|
local _lit = pv._area_handcard_list
|
||||||
if self._current_card_type == 2 then
|
for i = 1, #_carViewList do
|
||||||
b3d = "_3d"
|
_carViewList[i].card:Dispose()
|
||||||
end
|
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 b3d = ""
|
||||||
local cards = _room.self_player.card_list
|
if self._current_card_type == 2 then
|
||||||
|
b3d = "_3d"
|
||||||
|
end
|
||||||
|
|
||||||
if (not mp) then
|
local _room = DataManager.CurrenRoom
|
||||||
for i = 0, (#cards) - 1 do
|
local cards = _room.self_player.card_list
|
||||||
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
|
|
||||||
|
|
||||||
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
|
if (not mp) then
|
||||||
self:fillCard(btn_card, "201_", tem_card)
|
for i = 0, (#cards) - 1 do
|
||||||
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)
|
local tem_card = cards[i + 1]
|
||||||
local c_v = NewCardView(btn_card, tem_card)
|
local btn_card = nil
|
||||||
c_v.index = i
|
if _room.room_config.people_num == 2 then
|
||||||
c_v.old_postion = btn_card.xy
|
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d)
|
||||||
_carViewList[#_carViewList + 1] = c_v
|
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
|
_lit:AddChild(btn_card)
|
||||||
btn_card.data = c_v
|
|
||||||
-- btn_card.draggable = true;
|
if (not self._player.auto_out_card) then
|
||||||
-- btn_card.onDragStart:Set(function(evt)
|
btn_card.data = c_v
|
||||||
-- local _agent = evt.sender
|
-- btn_card.draggable = true;
|
||||||
-- _agent:RemoveFromParent()
|
-- btn_card.onDragStart:Set(function(evt)
|
||||||
-- _dragCom:AddChild(_agent)
|
-- local _agent = evt.sender
|
||||||
-- if self.__OnDragStart then
|
-- _agent:RemoveFromParent()
|
||||||
-- self:__OnDragStart(evt)
|
-- _dragCom:AddChild(_agent)
|
||||||
-- end
|
-- if self.__OnDragStart then
|
||||||
-- _agent.onDragEnd:Set(self.__OnDragEnd,self)
|
-- self:__OnDragStart(evt)
|
||||||
-- end)
|
-- end
|
||||||
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
|
-- _agent.onDragEnd:Set(self.__OnDragEnd,self)
|
||||||
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
|
-- end)
|
||||||
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
|
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
|
||||||
btn_card.onClick:Set(self.__OnClickHandCard, self)
|
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
|
||||||
else
|
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
|
||||||
btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5)
|
btn_card.onClick:Set(self.__OnClickHandCard, self)
|
||||||
btn_card.touchable = false
|
else
|
||||||
end
|
btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5)
|
||||||
end
|
btn_card.touchable = false
|
||||||
else
|
end
|
||||||
for i = 0, (#cards) - 1 do
|
end
|
||||||
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card" .. b3d)
|
else
|
||||||
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
|
for i = 0, (#cards) - 1 do
|
||||||
self:fillCard(mp_card, "202_", cards[i + 1])
|
local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card" .. b3d)
|
||||||
mp_card:SetScale(1.05, 1.05)
|
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
|
||||||
-- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0)
|
self:fillCard(mp_card, "202_", cards[i + 1])
|
||||||
self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard)
|
mp_card:SetScale(1.05, 1.05)
|
||||||
_lit:AddChild(mp_card)
|
-- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0)
|
||||||
end
|
self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard)
|
||||||
end
|
_lit:AddChild(mp_card)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
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)
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
|
||||||
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.onDragEnd:Set(nil)
|
-- button.onDragEnd:Set(nil)
|
||||||
--button:RemoveFromParent()
|
--button:RemoveFromParent()
|
||||||
local card = button.data
|
local card = button.data
|
||||||
local _room = DataManager.CurrenRoom
|
local _room = DataManager.CurrenRoom
|
||||||
if not _room or _room:GetReloadStatus() then return end
|
if not _room or _room:GetReloadStatus() then return end
|
||||||
|
|
||||||
-- -- 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 < -150 and _room.curren_outcard_seat == _room.self_player.seat) then
|
if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then
|
||||||
self._mainView:OutCard(card.card_item)
|
self._mainView:OutCard(card.card_item)
|
||||||
button.touchable = false
|
button.touchable = false
|
||||||
self.outcard_button = buttond
|
self.outcard_button = buttond
|
||||||
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:__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
|
||||||
end
|
end
|
||||||
local _room = DataManager.CurrenRoom
|
local _room = DataManager.CurrenRoom
|
||||||
if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then
|
if (Utils.IsDoubleClick(context) 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:GetCardObjPack()
|
function M:GetCardObjPack()
|
||||||
return "Main_Majiang"
|
return "Main_Majiang"
|
||||||
end
|
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 = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 808 KiB After Width: | Height: | Size: 820 KiB |
|
Before Width: | Height: | Size: 859 KiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 4.0 MiB After Width: | Height: | Size: 3.7 MiB |
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 261 KiB After Width: | Height: | Size: 256 KiB |