放大两人跑得快名字和分数,回退selfcard的覆盖操作
parent
d98a1fc38a
commit
9d65b49c25
|
|
@ -1,101 +1,196 @@
|
||||||
AreaOderType = {
|
local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView")
|
||||||
left_right = 'left_right',
|
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
|
||||||
right_left = 'right_left',
|
local CardCheck = import(".CardCheck")
|
||||||
up_down = 'up_down',
|
|
||||||
down_up = 'down_up'
|
|
||||||
}
|
|
||||||
|
|
||||||
local PlayerCardInfoView = {
|
local M = {}
|
||||||
_view = nil,
|
--
|
||||||
_mainView = nil,
|
|
||||||
_mask_liangpai = nil,
|
|
||||||
_mask_data = nil,
|
|
||||||
_area_handcard_list = nil,
|
|
||||||
_src_fz_list = nil,
|
|
||||||
_current_card_type = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
local M = PlayerCardInfoView
|
|
||||||
|
|
||||||
--- Create a new PlayerCardInfoView
|
|
||||||
function M.new(view, mainView)
|
function M.new(view, mainView)
|
||||||
local self = {}
|
setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView })
|
||||||
setmetatable(self, { __index = M })
|
setmetatable(M, { __index = MJPlayerSelfCardInfoView })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = "PlayerSelfCardInfoView"
|
||||||
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:ShowHuTip(card_list)
|
||||||
local view = self._view
|
printlog("ShowHuTip")
|
||||||
local _area_mask = view:GetChild('area_mask')
|
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui,
|
||||||
local mask = _area_mask.text
|
DataManager.CurrenRoom.room_config.Laizi)
|
||||||
|
pt(tingList)
|
||||||
self._mask_data = json.decode(mask)
|
if #tingList > 0 then
|
||||||
self._area_handcard_list = view:GetChild('area_handcard_list')
|
if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then
|
||||||
|
for i = 1, #DataManager.CurrenRoom.laiziInfo do
|
||||||
self._area_fz_list = view:GetChild('area_fz_list')
|
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then
|
||||||
self._area_outcard_list = view:GetChild('area_outcard_list')
|
table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i])
|
||||||
self._src_fz_list =
|
|
||||||
Vector4(self._area_fz_list.x, self._area_fz_list.y, self._area_fz_list.width, self._area_fz_list.height)
|
|
||||||
local c3d = self._view:GetController('3d')
|
|
||||||
if c3d ~= nil then
|
|
||||||
c3d.selectedIndex = 1
|
|
||||||
end
|
end
|
||||||
self._src_fz_list_3d =
|
|
||||||
Vector4(self._area_fz_list.x, self._area_fz_list.y, self._area_fz_list.width, self._area_fz_list.height)
|
|
||||||
local c3d = self._view:GetController('3d')
|
|
||||||
if c3d ~= nil then
|
|
||||||
c3d.selectedIndex = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self._mask_liangpai = view:GetChild('mask_liangpai')
|
|
||||||
|
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
|
||||||
if _gamectr then
|
|
||||||
_gamectr:AddEventListener(GameEvent.MJModifySzie, handler(self, self.SetMJSize))
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
self._mainView._hu_tip:FillData(tingList)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:SetMJSize(zS)
|
function M:UpdateHandCard(getcard, mp)
|
||||||
local tempSzieConfig = {}
|
print("====================================UpdateHandCard1", mp)
|
||||||
tempSzieConfig.size = zS
|
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
|
||||||
local filename = 'mjsize' .. DataManager.SelfUser.account_id
|
local _carViewList = self._carViewList
|
||||||
Utils.SaveLocalFile(filename, json.encode(tempSzieConfig))
|
|
||||||
|
|
||||||
--ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
|
if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then
|
||||||
ViewManager.refreshGameView()
|
for i = 1, #self._carViewList do
|
||||||
end
|
local obj = self._carViewList[i]
|
||||||
|
if obj and obj.card then
|
||||||
function M:SetPlayer(p)
|
if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then
|
||||||
self._player = p
|
if obj.card.GetController then
|
||||||
end
|
if obj.card:GetController("laizi") then
|
||||||
|
obj.card:GetController("laizi").selectedIndex = 1
|
||||||
function M:FillData(begin)
|
|
||||||
if (begin) then
|
|
||||||
for i = 1, #self._player.fz_list do
|
|
||||||
self:UpdateFzList(self._player.fz_list[i], -1)
|
|
||||||
end
|
end
|
||||||
self:UpdateOutCardList()
|
|
||||||
else
|
|
||||||
self._current_card_type = DataManager.CurrenRoom.card_type
|
|
||||||
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
local c3d = self._view:GetController('3d')
|
|
||||||
if c3d ~= nil then
|
|
||||||
c3d.selectedIndex = 1
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local c3d = self._view:GetController('3d')
|
if obj.card.GetController then
|
||||||
if c3d ~= nil then
|
if obj.card:GetController("laizi") then
|
||||||
c3d.selectedIndex = 0
|
obj.card:GetController("laizi").selectedIndex = 0
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function M:Clear()
|
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._ctr_state.selectedIndex = 0
|
||||||
self._area_fz_list.x = self._src_fz_list.x
|
self._area_fz_list.x = self._src_fz_list.x
|
||||||
self._area_fz_list.y = self._src_fz_list.y
|
self._area_fz_list.y = self._src_fz_list.y
|
||||||
|
|
@ -105,526 +200,14 @@ function M:Clear()
|
||||||
self._area_fz_list:RemoveChildren(0, -1, true)
|
self._area_fz_list:RemoveChildren(0, -1, true)
|
||||||
self._area_handcard_list:RemoveChildren(0, -1, true)
|
self._area_handcard_list:RemoveChildren(0, -1, true)
|
||||||
self._area_outcard_list:RemoveChildren(0, -1, true)
|
self._area_outcard_list:RemoveChildren(0, -1, true)
|
||||||
|
if bskip == nil or bskip == false then
|
||||||
self._mask_liangpai:RemoveChildren(0, -1, true)
|
self._mask_liangpai:RemoveChildren(0, -1, true)
|
||||||
end
|
|
||||||
|
|
||||||
-- 获取麻将资源前缀
|
|
||||||
function M:GetPrefix()
|
|
||||||
-- local card_type = DataManager.CurrenRoom.card_type
|
|
||||||
-- local prefix = card_type == 1 and "a" or ""
|
|
||||||
-- return prefix
|
|
||||||
return get_majiang_prefix(DataManager.CurrenRoom.game_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:fillCard(obj, pos_str, card, use3d)
|
|
||||||
if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then
|
|
||||||
obj:GetController('jing').selectedIndex = 1
|
|
||||||
end
|
|
||||||
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
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:getBackCard(card)
|
|
||||||
return 'ui://Main_Majiang/' .. card
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:GetCard(btn)
|
|
||||||
local pic_name = split(btn.icon, '/')[4]
|
|
||||||
local lst = string.split(pic_name, '_')
|
|
||||||
return tonumber(lst[2] or 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:UpdateHandCard(getcard, mp)
|
|
||||||
print("====================================UpdateHandCard4")
|
|
||||||
|
|
||||||
getcard = getcard or false
|
|
||||||
mp = mp or false
|
|
||||||
local handcard_list = self._mask_data['handcard_list']
|
|
||||||
local oder = handcard_list['oder']
|
|
||||||
local _player = self._player
|
|
||||||
-- -- print(vardump(self._player))
|
|
||||||
|
|
||||||
self._area_handcard_list:RemoveChildren(0, -1, true)
|
|
||||||
-- -- print(vardump(_player.card_list))
|
|
||||||
if (not mp) then
|
|
||||||
local comp_back = handcard_list['comp_back']
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
comp_back = comp_back .. '_3d'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 0, _player.hand_left_count - 1 do
|
for i = 1, #self._carViewList do
|
||||||
local obj = UIPackage.CreateObjectFromURL(self:getBackCard(comp_back))
|
self._carViewList[i].card:Dispose()
|
||||||
local _room = DataManager.CurrenRoom
|
|
||||||
local people_num = _room.room_config.people_num
|
|
||||||
local pos = ViewUtil.GetPos(_room.self_player.seat, _player.seat, people_num)
|
|
||||||
local gap = (pos == 3 and people_num == 4 or pos == 2 and people_num == 2) and 15 or 45
|
|
||||||
local offset = getcard and (i == _player.hand_left_count - 1 and gap or 0)
|
|
||||||
-- local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0)
|
|
||||||
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
|
|
||||||
|
|
||||||
--改变左右两边的手牌的x值
|
|
||||||
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
|
|
||||||
obj.x = i * -7.0
|
|
||||||
end
|
|
||||||
|
|
||||||
if (oder == AreaOderType.down_up) then
|
|
||||||
self._area_handcard_list:AddChildAt(obj, 0)
|
|
||||||
else
|
|
||||||
self._area_handcard_list:AddChild(obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local outcard_list = self._mask_data['outcard_list']
|
|
||||||
local comp = handcard_list['comp']
|
|
||||||
local card = outcard_list['card']
|
|
||||||
---- print("comp"..comp)
|
|
||||||
-- -- print(vardump(_player.card_list))
|
|
||||||
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
comp = comp .. '_3d'
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 0, #_player.card_list - 1 do
|
|
||||||
local obj = UIPackage.CreateObject('Main_Majiang', comp)
|
|
||||||
|
|
||||||
self:fillCard(obj, card, _player.card_list[i + 1])
|
|
||||||
-- obj.icon = UIPackage.GetItemURL("Main_Majiang", card .. _player.card_list[i+1])
|
|
||||||
|
|
||||||
local offset = getcard and (i == _player.hand_left_count - 1 and 0 or 0)
|
|
||||||
|
|
||||||
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
|
|
||||||
|
|
||||||
--改变左右两边的手牌的x值
|
|
||||||
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
|
|
||||||
obj.x = i * -7
|
|
||||||
end
|
|
||||||
|
|
||||||
if (oder == AreaOderType.down_up) then
|
|
||||||
self._area_handcard_list:AddChildAt(obj, 0)
|
|
||||||
else
|
|
||||||
self._area_handcard_list:AddChild(obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 获取麻将图片资源位置,可以在扩展中复写
|
|
||||||
function M:GetCardPicPack()
|
|
||||||
-- if DataManager.CurrenRoom.card_type == 2 then
|
|
||||||
-- return "MajiangCard3d"
|
|
||||||
-- else
|
|
||||||
return 'Main_Majiang'
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:adjust3dOutPut(obj, area, oder, num, index)
|
|
||||||
if index >= num then
|
|
||||||
local row = 1 + math.floor(((index - num) / (num + 2)))
|
|
||||||
local col = ((index - num) % (num + 2))
|
|
||||||
|
|
||||||
if oder == AreaOderType.left_right then
|
|
||||||
obj.x = obj.x + math.floor((area.width - obj.width * (num + 2)) / 2)
|
|
||||||
elseif oder == AreaOderType.right_left then
|
|
||||||
obj.x = obj.x - math.floor((area.width - obj.width * (num + 2)) / 2)
|
|
||||||
elseif oder == AreaOderType.up_down then
|
|
||||||
obj.y = obj.y + math.floor((area.height - obj.height * (num + 2)) / 2)
|
|
||||||
obj.x = obj.x - col * 7 + 7 * (row + 1)
|
|
||||||
elseif oder == AreaOderType.down_up then
|
|
||||||
obj.y = obj.y - math.floor((area.height - obj.height * (num + 2)) / 2)
|
|
||||||
obj.x = obj.x - col * 7 - 7 * (row - 1)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if oder == AreaOderType.left_right then
|
|
||||||
obj.x = obj.x + math.floor((area.width - obj.width * num) / 2)
|
|
||||||
elseif oder == AreaOderType.right_left then
|
|
||||||
obj.x = obj.x - math.floor((area.width - obj.width * num) / 2)
|
|
||||||
elseif oder == AreaOderType.up_down then
|
|
||||||
obj.y = obj.y + math.floor((area.height - obj.height * num) / 2)
|
|
||||||
obj.x = obj.x - index * 7
|
|
||||||
elseif oder == AreaOderType.down_up then
|
|
||||||
obj.y = obj.y - math.floor((area.height - obj.height * num) / 2)
|
|
||||||
obj.x = obj.x - index * 7
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:UpdateOutCardList(outcard, card_item, cursor)
|
|
||||||
outcard = outcard or nil
|
|
||||||
card_item = card_item or 0
|
|
||||||
cursor = cursor or nil
|
|
||||||
|
|
||||||
local outlist = self._player.outcard_list
|
|
||||||
if (outcard) then
|
|
||||||
outcard:SetPivot(0.5, 0.5, true)
|
|
||||||
outcard.touchable = false
|
|
||||||
-- outcard.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. card_item
|
|
||||||
outcard.icon = string.format('ui://%s/%s202_%s', self:GetCardPicPack(), self:GetPrefix(), card_item)
|
|
||||||
self._mask_liangpai:AddChild(outcard)
|
|
||||||
end
|
|
||||||
|
|
||||||
local outcard_list = self._mask_data['outcard_list']
|
|
||||||
local oder = outcard_list['oder']
|
|
||||||
local comp = outcard_list['comp']
|
|
||||||
local card = outcard_list['card']
|
|
||||||
local multi_oder = outcard_list['multi_oder']
|
|
||||||
local num = outcard_list['num']
|
|
||||||
local multi_draw_oder = 0
|
|
||||||
local sortStart = 0
|
|
||||||
local sortType = 0
|
|
||||||
local sortStep = 0
|
|
||||||
if (outcard_list['multi_draw_oder']) then
|
|
||||||
multi_draw_oder = outcard_list['multi_draw_oder']
|
|
||||||
end
|
|
||||||
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
comp = comp .. '_3d'
|
|
||||||
num = outcard_list['num3d']
|
|
||||||
multi_oder = outcard_list['multi_oder3d']
|
|
||||||
sortType = outcard_list['sorting_order3d']
|
|
||||||
card = outcard_list['card3d']
|
|
||||||
if sortType == 1 then
|
|
||||||
sortStart = 1
|
|
||||||
sortStep = 1
|
|
||||||
elseif sortType == -1 then
|
|
||||||
sortStart = #outlist
|
|
||||||
sortStep = -1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local obj = nil
|
|
||||||
self._area_outcard_list:RemoveChildren(0, -1, true)
|
|
||||||
for i = 0, #outlist - 1 do
|
|
||||||
obj = UIPackage.CreateObjectFromURL('ui://Main_Majiang/' .. comp)
|
|
||||||
local row = math.floor(i / num)
|
|
||||||
local col = math.floor(i % num)
|
|
||||||
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
if i >= num then
|
|
||||||
row = 1 + math.floor(((i - num) / (num + 2)))
|
|
||||||
col = ((i - num) % (num + 2))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if DataManager.CurrenRoom.room_config.people_num == 2 then
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col, nil, nil, -6)
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row, nil, nil, -12)
|
|
||||||
elseif DataManager.CurrenRoom.room_config.people_num == 4 then
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col, nil, nil, -6)
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row, nil, nil, -12)
|
|
||||||
else
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col)
|
|
||||||
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
self:adjust3dOutPut(obj, self._area_outcard_list, oder, num, i)
|
|
||||||
end
|
|
||||||
|
|
||||||
self:fillCard(obj, card, outlist[i + 1])
|
|
||||||
-- 添加角标
|
|
||||||
self:AddFlag(i + 1, outlist[i], obj)
|
|
||||||
-- obj.icon = "ui://Main_Majiang/"..card .. outlist[i+1]
|
|
||||||
sortStart = sortStart + sortStep
|
|
||||||
obj.sortingOrder = sortStart
|
|
||||||
obj.data = outlist[i + 1]
|
|
||||||
|
|
||||||
if (oder == AreaOderType.down_up or (multi_draw_oder == 1)) then
|
|
||||||
self._area_outcard_list:AddChildAt(obj, 0)
|
|
||||||
else
|
|
||||||
self._area_outcard_list:AddChild(obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (obj and cursor) then
|
|
||||||
cursor.xy = Vector2(obj.width / 2, obj.height / 2)
|
|
||||||
obj:AddChild(cursor)
|
|
||||||
obj:GetController('color').selectedIndex = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 设置添加角标的方法
|
|
||||||
function M:SetAddFlag(cb)
|
|
||||||
self.__addFlag = cb
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 给麻将牌添加flag
|
|
||||||
function M:AddFlag(index, card, btn)
|
|
||||||
if not self.__addFlag then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local str_flag = self.__addFlag(index, card, btn)
|
|
||||||
btn:GetController('hun').selectedIndex = str_flag == '' and 0 or 1
|
|
||||||
btn:GetChild('flag').icon = str_flag
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getPos(my_seat, other_seat, total)
|
|
||||||
local pos = 0
|
|
||||||
pos = other_seat - my_seat + 1
|
|
||||||
if pos <= 0 then
|
|
||||||
pos = pos + total
|
|
||||||
end
|
|
||||||
if total ~= 4 and pos == total then
|
|
||||||
pos = total + 1
|
|
||||||
end
|
|
||||||
return pos
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:UpdateFzList(fz, index, show_card)
|
|
||||||
local gn = 3
|
|
||||||
if fz.type == FZType.Gang or fz.type == FZType.Gang_An or fz.type == FZType.Gang_Peng then
|
|
||||||
gn = 4
|
|
||||||
end
|
|
||||||
|
|
||||||
local fz_list = self._mask_data['fz_list']
|
|
||||||
local oder = fz_list['oder']
|
|
||||||
local comp = fz_list['comp'] .. gn
|
|
||||||
local card = fz_list['card']
|
|
||||||
local card3d = ''
|
|
||||||
local adjust3d = 0
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
comp = comp .. '_3d'
|
|
||||||
oder = fz_list['oder3d']
|
|
||||||
adjust3d = fz_list['adjust3d']
|
|
||||||
card = fz_list['card3d']
|
|
||||||
card3d = 'b'
|
|
||||||
end
|
|
||||||
|
|
||||||
local obj = UIPackage.CreateObjectFromURL('ui://Main_Majiang/' .. comp)
|
|
||||||
-- print("============================================pengpengpeng", comp)
|
|
||||||
|
|
||||||
local _area_fz_list = self._area_fz_list
|
|
||||||
local _area_outcard_list = self._area_outcard_list
|
|
||||||
|
|
||||||
if (index == -1) then
|
|
||||||
local num = _area_fz_list.numChildren
|
|
||||||
|
|
||||||
if (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
|
|
||||||
_area_fz_list.height = _area_fz_list.height + obj.height
|
|
||||||
if (oder == AreaOderType.down_up) then
|
|
||||||
local tem1 = obj.height
|
|
||||||
for i = 1, num do
|
|
||||||
local tem = _area_fz_list:GetChildAt(num - i)
|
|
||||||
tem.y = tem.y + tem1
|
|
||||||
end
|
|
||||||
_area_fz_list.y = _area_fz_list.y - obj.height
|
|
||||||
else
|
|
||||||
ViewUtil.CardPos(obj, _area_outcard_list, oder, num)
|
|
||||||
end
|
|
||||||
elseif (oder == AreaOderType.left_right or oder == AreaOderType.right_left) then
|
|
||||||
_area_fz_list.width = _area_fz_list.width + obj.width
|
|
||||||
if (oder == AreaOderType.right_left) then
|
|
||||||
local tem1 = obj.width
|
|
||||||
for i = 1, num do
|
|
||||||
local tem = _area_fz_list:GetChildAt(num - i)
|
|
||||||
tem.x = tem.x + tem1
|
|
||||||
end
|
|
||||||
_area_fz_list.x = _area_fz_list.x - obj.width
|
|
||||||
else
|
|
||||||
ViewUtil.CardPos(obj, _area_outcard_list, oder, num)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
_area_fz_list:AddChild(obj)
|
|
||||||
|
|
||||||
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
|
|
||||||
num = _area_fz_list.numChildren
|
|
||||||
for i = 1, num do
|
|
||||||
local tem = _area_fz_list:GetChildAt(i - 1)
|
|
||||||
tem.x = adjust3d * (i - 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local obj1 = _area_fz_list:RemoveChildAt(index)
|
|
||||||
obj1:Dispose()
|
|
||||||
obj.xy = obj1.xy
|
|
||||||
_area_fz_list:AddChildAt(obj, index)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 显示fz的牌
|
|
||||||
local obj_show
|
|
||||||
if show_card then
|
|
||||||
obj_show = UIPackage.CreateObjectFromURL('ui://Main_Majiang/Fz_0_' .. gn)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, gn do
|
|
||||||
local _oc = obj:GetChild('card_' .. i)
|
|
||||||
local _oc2 = nil
|
|
||||||
|
|
||||||
if show_card then
|
|
||||||
_oc2 = obj_show:GetChild('card_' .. i)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (fz.type == FZType.Gang_An and i == gn) then
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
_oc.icon = UIPackage.GetItemURL('MajiangCard3d', card3d .. card .. '00')
|
|
||||||
else
|
|
||||||
_oc.icon = UIPackage.GetItemURL(self:GetCardPicPack(), card3d .. card .. '00')
|
|
||||||
end
|
|
||||||
|
|
||||||
if show_card then
|
|
||||||
_oc2.icon = UIPackage.GetItemURL('Main_Majiang', '202_00')
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if (fz.type == FZType.Chi) then
|
|
||||||
local index = i
|
|
||||||
if oder == AreaOderType.right_left or oder == AreaOderType.down_up then
|
|
||||||
index = gn - i + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
self:fillCard(_oc, card, fz.opcard[index])
|
|
||||||
|
|
||||||
if show_card then
|
|
||||||
self:fillCard(_oc2, '202_', fz.opcard[index], false)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self:fillCard(_oc, card, fz.card)
|
|
||||||
|
|
||||||
if show_card then
|
|
||||||
self:fillCard(_oc2, '202_', fz.card, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
obj.touchable = false
|
|
||||||
|
|
||||||
if show_card then
|
|
||||||
obj_show.touchable = false
|
|
||||||
obj_show:SetPivot(0.5, 0.5, true)
|
|
||||||
obj_show:SetScale(0.8, 0.8)
|
|
||||||
self._mask_liangpai:AddChildAt(obj_show, 0)
|
|
||||||
coroutine.start(
|
|
||||||
function()
|
|
||||||
coroutine.wait(2)
|
|
||||||
obj_show:Dispose()
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- -- 标记碰牌对象
|
|
||||||
-- local num = self._area_fz_list.numChildren
|
|
||||||
-- if num == 0 then return end
|
|
||||||
-- if index == -1 then
|
|
||||||
-- -- local obj = self._area_fz_list:GetChildAt(num - 1)
|
|
||||||
-- local pic_arrow = UIPackage.CreateObjectFromURL("ui://Main_Majiang/com_arrow")
|
|
||||||
-- obj:AddChild(pic_arrow)
|
|
||||||
-- pic_arrow:Center()
|
|
||||||
-- local my_seat = self._player.seat
|
|
||||||
-- if fz.from_seat ~= my_seat then
|
|
||||||
-- pic_arrow:GetController("show").selectedIndex = 1
|
|
||||||
-- pic_arrow:GetController("pos").selectedIndex = getPos(DataManager.CurrenRoom.self_player.seat, fz.from_seat, #DataManager.CurrenRoom.player_list)
|
|
||||||
-- pic_arrow:SetPivot(0.5, 0.5)
|
|
||||||
-- if DataManager.CurrenRoom.self_player.seat ~= self._player.seat then
|
|
||||||
-- pic_arrow.scaleX = 0.5
|
|
||||||
-- pic_arrow.scaleY = 0.5
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:GetOutCardByIndex(index)
|
|
||||||
local outcard_list = self._mask_data['outcard_list']
|
|
||||||
local oder = outcard_list['oder']
|
|
||||||
local multi_draw_oder = 0
|
|
||||||
if (outcard_list['multi_draw_oder']) then
|
|
||||||
multi_draw_oder = outcard_list['multi_draw_oder']
|
|
||||||
end
|
|
||||||
|
|
||||||
if (oder == AreaOderType.down_up or (multi_draw_oder == 1)) then
|
|
||||||
return self._area_outcard_list:GetChildAt(self._area_outcard_list.numChildren - index)
|
|
||||||
else
|
|
||||||
return self._area_outcard_list:GetChildAt(index - 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:ResetFzList()
|
|
||||||
for i = 1, #self._player.fz_list do
|
|
||||||
local fz = self._player.fz_list[i]
|
|
||||||
-- if fz.type ~= FZType.Gang_Peng then
|
|
||||||
self:UpdateFzList(fz, -1)
|
|
||||||
-- else
|
|
||||||
-- self:UpdateFzList(fz, i)
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function replace_card(obj, prefix)
|
|
||||||
local url = obj.icon
|
|
||||||
if url then
|
|
||||||
local len = string.len(url)
|
|
||||||
local pos = string.len('ui://Main_Majiang/') + 1
|
|
||||||
local head_char = string.sub(url, pos, pos)
|
|
||||||
local card = string.sub(url, pos, len)
|
|
||||||
if head_char >= 'a' then
|
|
||||||
card = string.sub(card, 2, len)
|
|
||||||
end
|
|
||||||
obj.icon = 'ui://Main_Majiang/' .. prefix .. card
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:ResetCardType()
|
|
||||||
local old_card_type = self._current_card_type
|
|
||||||
self._current_card_type = DataManager.CurrenRoom.card_type
|
|
||||||
|
|
||||||
--设置3d标志
|
|
||||||
if self._current_card_type == 2 then
|
|
||||||
local c3d = self._view:GetController('3d')
|
|
||||||
if c3d ~= nil then
|
|
||||||
c3d.selectedIndex = 1
|
|
||||||
|
|
||||||
self._area_fz_list.x = self._src_fz_list_3d.x
|
|
||||||
self._area_fz_list.y = self._src_fz_list_3d.y
|
|
||||||
self._area_fz_list.width = self._src_fz_list_3d.z
|
|
||||||
self._area_fz_list.height = self._src_fz_list_3d.w
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local c3d = self._view:GetController('3d')
|
|
||||||
if c3d ~= nil then
|
|
||||||
c3d.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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local change2d = false
|
|
||||||
if old_card_type == 2 and self._current_card_type ~= 2 then
|
|
||||||
change2d = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local change3d = false
|
|
||||||
if old_card_type ~= 2 and self._current_card_type == 2 then
|
|
||||||
change3d = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if change2d == false and change3d == false and self._current_card_type ~= 2 then
|
|
||||||
local prefix = self:GetPrefix()
|
|
||||||
|
|
||||||
--更新已出牌
|
|
||||||
for i = 1, self._area_outcard_list.numChildren do
|
|
||||||
local obj = self._area_outcard_list:GetChildAt(i - 1)
|
|
||||||
replace_card(obj, prefix)
|
|
||||||
end
|
|
||||||
|
|
||||||
--更新手牌
|
|
||||||
for i = 1, self._area_handcard_list.numChildren do
|
|
||||||
local obj = self._area_handcard_list:GetChildAt(i - 1)
|
|
||||||
replace_card(obj, prefix)
|
|
||||||
end
|
|
||||||
|
|
||||||
--更新放子牌
|
|
||||||
for i = 1, self._area_fz_list.numChildren do
|
|
||||||
local com = self._area_fz_list:GetChildAt(i - 1)
|
|
||||||
for j = 1, 4 do
|
|
||||||
local obj = com:GetChild('card_' .. j)
|
|
||||||
if obj then
|
|
||||||
replace_card(obj, prefix)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
self._carViewList = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -222,19 +222,20 @@ function M:SelectedConfigData()
|
||||||
_data["fs"] = 0
|
_data["fs"] = 0
|
||||||
|
|
||||||
|
|
||||||
_data["leaf"] = handcard + 1
|
_data["leaf"] = handcard == 0 and 2 or handcard --手牌 1是15张,2是16张
|
||||||
_data["opt"] = round + 1
|
_data["opt"] = round + 1 --局数 1是10局 2是15局 3是20局
|
||||||
_data["maxPlayers"] = peopleNum == 1 and 2 or 3
|
_data["maxPlayers"] = peopleNum == 1 and 2 or 3 --人数 2是2人 3是三人
|
||||||
_data["rule"] = wanfa1_5 == 0 and 2 or 1
|
_data["rule"] = wanfa1_5 == 0 and 2 or 1 --黑桃3必出 2是选择了该玩法 1是没有该玩法
|
||||||
_data["showlength"] = showCardNum
|
_data["showlength"] = (showCardNum + 1) % 2 --显示手牌数量 0是不显示 1是显示
|
||||||
_data["planelack"] = wanfa1_2
|
_data["planelack"] = wanfa1_2 --[[三张、飞机可少带接完 0是没有该玩法 1是有该玩法,
|
||||||
|
吴哥说这个玩法可能包含了三张、飞机可不带,没有告诉我添加字段,这个字段是飞机,下个字段是三带]]
|
||||||
_data["threelack"] = wanfa1_2
|
_data["threelack"] = wanfa1_2
|
||||||
_data["fourDaiThree"] = false
|
_data["fourDaiThree"] = false --四带三 false没有该玩法 true有该玩法
|
||||||
if wanfa1_3 then
|
if wanfa1_3 then
|
||||||
_data["fourDaiThree"] = true
|
_data["fourDaiThree"] = true
|
||||||
end
|
end
|
||||||
_data["heartten"] = wanfa1_4 + 1
|
_data["heartten"] = wanfa1_4 + 1 --红桃扎鸟 1没有该玩法 2有该玩法 似乎说的是红桃10分数翻倍,具体要问江西那边
|
||||||
_data["specilAdd"] = wanfa2_1
|
_data["specilAdd"] = wanfa2_1 --特殊加分规则:只出一张加扣10分,出2-3张加扣5分 0没有该玩法 1有该玩法
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue