双人对局新界面

master
罗家炜 2025-04-07 19:37:37 +08:00
parent 8515e03703
commit 6c104ef0fd
12 changed files with 391 additions and 348 deletions

View File

@ -120,7 +120,7 @@ function M:InitView(url, isHideIpAdds)
self:continue_game(v) self:continue_game(v)
end) end)
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
self._state.selectedIndex < 3 and 1 or 0 self._state.selectedIndex < 3 and 1 or 0
self.distance_view:Show() self.distance_view:Show()
end) end)
end end
@ -232,18 +232,21 @@ function M:InitView(url, isHideIpAdds)
self._gamectr:PlayerReady() self._gamectr:PlayerReady()
end) end)
-- local btn_xipai = _view:GetChild('btn_xipai') if self._room.room_config.people_num ~= 2 then
-- if btn_xipai then local btn_xipai = _view:GetChild('btn_xipai')
-- btn_xipai.onClick:Set(function() if btn_xipai then
-- self._gamectr:PlayerXiPai() btn_xipai.onClick:Set(function()
-- end) self._gamectr:PlayerXiPai()
-- end end)
end
-- local btn_start = _view:GetChild('btn_start') local btn_start = _view:GetChild('btn_start')
-- btn_start.onClick:Set(function() btn_start.onClick:Set(function()
-- self._gamectr:StartGame() self._gamectr:StartGame()
-- end) end)
end
local _btn_wxyqhy = _view:GetChild('btn_wxyqhy') local _btn_wxyqhy = _view:GetChild('btn_wxyqhy')
if _btn_wxyqhy then if _btn_wxyqhy then
@ -781,7 +784,7 @@ function M:OnPlayerEnter(...)
self:continue_game(v) self:continue_game(v)
end) end)
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
self._state.selectedIndex < 3 and 1 or 0 self._state.selectedIndex < 3 and 1 or 0
self.distance_view:Show() self.distance_view:Show()
if self.btn_distance then if self.btn_distance then
self.btn_distance:GetController("state").selectedIndex = 1 self.btn_distance:GetController("state").selectedIndex = 1
@ -1115,7 +1118,7 @@ function M:Show()
self:continue_game(v) self:continue_game(v)
end) end)
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
self._state.selectedIndex < 3 and 1 or 0 self._state.selectedIndex < 3 and 1 or 0
self.distance_view:Show() self.distance_view:Show()
self.btn_distance:GetController("state").selectedIndex = 1 self.btn_distance:GetController("state").selectedIndex = 1
end end

View File

@ -1,5 +1,3 @@
---
local PlayerInfoView = { local PlayerInfoView = {
_view = nil, _view = nil,
_main_view = nil, _main_view = nil,
@ -51,6 +49,7 @@ function M:init()
self._ctr_room_owner = view:GetController('room_owner') self._ctr_room_owner = view:GetController('room_owner')
self._ctr_mask_voice = view:GetController('mask_voice') self._ctr_mask_voice = view:GetController('mask_voice')
self._ctr_dismiss_room = view:GetController('dismiss_room') self._ctr_dismiss_room = view:GetController('dismiss_room')
self._ctr_site = view:GetController('site')
self.PlayerTGTips = view:GetChild('tuoguanTips') self.PlayerTGTips = view:GetChild('tuoguanTips')
if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then
@ -162,6 +161,23 @@ function M:FillData(player)
end end
end end
function M:SetStartType(peopleNum, seat)
if peopleNum == 2 then
if seat == 1 then
self._ctr_site.selectedIndex = 1
else
self._ctr_site.selectedIndex = 2
self._tex_player_name = 154
end
elseif peopleNum == 3 then
self._ctr_site.selectedIndex = 2 + seat
elseif peopleNum == 4 then
self._ctr_site.selectedIndex = 5 + seat
else
self._ctr_site.selectedIndex = 0
end
end
function M:DismissRoom(state) function M:DismissRoom(state)
state = state or false state = state or false
self._ctr_dismiss_room.selectedIndex = state == true and 1 or 0 self._ctr_dismiss_room.selectedIndex = state == true and 1 or 0

View File

@ -2,45 +2,45 @@ ViewUtil = {
Num_Converted = { "", "", "", "" }, Num_Converted = { "", "", "", "" },
Sex_Chat = { Sex_Chat = {
"man", "man",
"woman" "woman"
}, },
Fix_Msg_Chat = { Fix_Msg_Chat = {
"大家好,很高兴见到各位!", "大家好,很高兴见到各位!",
"和你合作太愉快了!", "和你合作太愉快了!",
"快点啊,我等的花儿都谢了!", "快点啊,我等的花儿都谢了!",
"你丫的牌打得也忒好了", "你丫的牌打得也忒好了",
"不要吵了不要吵了,吵什么吵啊,专心打牌", "不要吵了不要吵了,吵什么吵啊,专心打牌",
"怎么又断线了,网络这么差!", "怎么又断线了,网络这么差!",
"各位,真不好意思啊,我得离开一会", "各位,真不好意思啊,我得离开一会",
"不要走,决战到天亮!", "不要走,决战到天亮!",
"你是妹妹,还是哥哥啊?", "你是妹妹,还是哥哥啊?",
"我们交个朋友吧,能不能告诉我你的联系方法", "我们交个朋友吧,能不能告诉我你的联系方法",
"再见了,我会想念大家的", "再见了,我会想念大家的",
"不好意思临时有事,申请解散!" "不好意思临时有事,申请解散!"
} }
} }
function ViewUtil.GetPos(self_seat,seat,people_num) function ViewUtil.GetPos(self_seat, seat, people_num)
if self_seat == 0 then return seat end if self_seat == 0 then return seat end
local cur_seat = self_seat local cur_seat = self_seat
local tem = seat - (cur_seat - 1) local tem = seat - (cur_seat - 1)
if (tem <= 0) then tem = tem +people_num end if (tem <= 0) then tem = tem + people_num end
return tem return tem
end end
-- 隐藏手机号 -- 隐藏手机号
function ViewUtil.phone_hide(phone) function ViewUtil.phone_hide(phone)
return string.sub(phone,1,3).."****"..string.sub(phone,8) return string.sub(phone, 1, 3) .. "****" .. string.sub(phone, 8)
end end
-- 隐藏身份证 -- 隐藏身份证
function ViewUtil.identity_hide(identity) function ViewUtil.identity_hide(identity)
return string.sub(identity,1,8).."****"..string.sub(identity,13) return string.sub(identity, 1, 8) .. "****" .. string.sub(identity, 13)
end end
local modal_wait_win =nil local modal_wait_win = nil
-- local modal_wait_win_url = "ui://Common/GlobalModalWaiting" -- local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
function ViewUtil.ShowModalWait(blur_view, title) function ViewUtil.ShowModalWait(blur_view, title)
ViewUtil.CloseModalWait() ViewUtil.CloseModalWait()
@ -51,14 +51,14 @@ function ViewUtil.CloseModalWait()
ModalWaitingWindow.CloseModal() ModalWaitingWindow.CloseModal()
end end
local _defaultTooltipWin =nil local _defaultTooltipWin = nil
local function __waittips(obj) local function __waittips(obj)
_defaultTooltipWin:Dispose() _defaultTooltipWin:Dispose()
_defaultTooltipWin = nil _defaultTooltipWin = nil
end end
local _tip_timer local _tip_timer
local function __ShowTips(msg,time) local function __ShowTips(msg, time)
time = time or 2 time = time or 2
if _defaultTooltipWin then if _defaultTooltipWin then
_tip_timer:Stop() _tip_timer:Stop()
@ -72,24 +72,24 @@ local function __ShowTips(msg,time)
_defaultTooltipWin:MakeFullScreen() _defaultTooltipWin:MakeFullScreen()
_tip_timer = Timer.New(function() _tip_timer = Timer.New(function()
__waittips() __waittips()
end,time,1,true) end, time, 1, true)
_tip_timer:Start() _tip_timer:Start()
end end
function ViewUtil.ErrorTip(code,tip,time) function ViewUtil.ErrorTip(code, tip, time)
if(Table_Error_code_Map[code]~=nil) then if (Table_Error_code_Map[code] ~= nil) then
__ShowTips(string.format("%s",Table_Error_code_Map[code].note), time) __ShowTips(string.format("%s", Table_Error_code_Map[code].note), time)
else else
__ShowTips(tip,time) __ShowTips(tip, time)
end end
end end
function ViewUtil.ErrorMsg(_root_view,code,tip,url) function ViewUtil.ErrorMsg(_root_view, code, tip, url)
local msg = tip local msg = tip
if(Table_Error_code_Map[code]~=nil) then if (Table_Error_code_Map[code] ~= nil) then
msg = string.format("%s",Table_Error_code_Map[code].note) msg = string.format("%s", Table_Error_code_Map[code].note)
end end
local _curren_msg = MsgWindow.new(_root_view, msg, MsgWindow.MsgMode.OnlyOk,url) local _curren_msg = MsgWindow.new(_root_view, msg, MsgWindow.MsgMode.OnlyOk, url)
_curren_msg:Show() _curren_msg:Show()
end end
@ -109,7 +109,7 @@ function ViewUtil.ShowBannerOnScreenCenter(msg, s)
ViewUtil._banner = banner ViewUtil._banner = banner
local timer = Timer.New(function() local timer = Timer.New(function()
banner:Dispose() banner:Dispose()
end,time,1,true) end, time, 1, true)
timer:Start() timer:Start()
end end
@ -117,51 +117,47 @@ function ViewUtil.PlaySoundBg()
GameApplication.Instance:PlayMuisc("base/common/sound/bgmusic1.mp3") GameApplication.Instance:PlayMuisc("base/common/sound/bgmusic1.mp3")
end end
function ViewUtil.HandCardSort(a,b) function ViewUtil.HandCardSort(a, b)
local sort_a = a local sort_a = a
local sort_b = b local sort_b = b
if a >= 400 then sort_a = sort_a -1000 end if a >= 400 then sort_a = sort_a - 1000 end
if b >= 400 then sort_b = sort_b - 1000 end if b >= 400 then sort_b = sort_b - 1000 end
return sort_a<sort_b return sort_a < sort_b
end end
function ViewUtil.HandCardSort2(a,b) function ViewUtil.HandCardSort2(a, b)
a=tonumber(string.sub(a,2)) a = tonumber(string.sub(a, 2))
b=tonumber(string.sub(b,2)) b = tonumber(string.sub(b, 2))
--print(a) --print(a)
--print(b) --print(b)
return a < b return a < b
end end
function ViewUtil.HandCardSort3(a, b)
function ViewUtil.HandCardSort3(a,b)
local sort_a = a[1] or 101 local sort_a = a[1] or 101
local sort_b = b[1] or 101 local sort_b = b[1] or 101
return sort_a<sort_b return sort_a < sort_b
end end
function ViewUtil.CardPos(obj, area, oder, index, offset, isAdd, padding)
offset = offset or 0
padding = padding or 0
if oder == AreaOderType.left_right then
function ViewUtil.CardPos(obj, area, oder, index, offset,isAdd) obj.x = index * (obj.width + padding) + offset
offset = offset or 0 elseif oder == AreaOderType.up_down then
if oder == AreaOderType.left_right then obj.y = index * (obj.height + padding) + offset
obj.x = index * obj.width + offset elseif oder == AreaOderType.right_left then
elseif oder == AreaOderType.up_down then obj.x = (area.width - obj.width) - index * (obj.width + padding) - offset
obj.y = index * obj.height + offset elseif oder == AreaOderType.down_up then
elseif oder == AreaOderType.right_left then if isAdd then
obj.x = (area.width - obj.width) - index * obj.width - offset obj.y = area.height - obj.height - index * obj.height * 1.5 - offset
elseif oder == AreaOderType.down_up then else
if isAdd then obj.y = area.height - obj.height - index * obj.height - offset
obj.y = area.height - obj.height - index * obj.height*1.5 - offset end
else --obj.y = area.height - obj.height - index * obj.height - offset
obj.y = area.height - obj.height - index * obj.height - offset end
end
--obj.y = area.height - obj.height - index * obj.height - offset
end
end end
local _current_group = nil local _current_group = nil
@ -174,6 +170,7 @@ function ViewUtil.PlayMuisc(group, path)
end end
GameApplication.Instance:PlayMuisc(group, path) GameApplication.Instance:PlayMuisc(group, path)
end end
function ViewUtil.PlaySound(group, path) function ViewUtil.PlaySound(group, path)
if group ~= _current_group then if group ~= _current_group then
if _current_group then if _current_group then
@ -195,9 +192,9 @@ function get_majiang_prefix(game_id)
local ct = 1 local ct = 1
if DataManager.CurrenRoom and DataManager.CurrenRoom.card_type then if DataManager.CurrenRoom and DataManager.CurrenRoom.card_type then
ct = DataManager.CurrenRoom.card_type ct = DataManager.CurrenRoom.card_type
--printlog("get_majiang_prefix=============1111") --printlog("get_majiang_prefix=============1111")
elseif game_id then elseif game_id then
--printlog("get_majiang_prefix=============1111222222222222") --printlog("get_majiang_prefix=============1111222222222222")
local ct_data = nil local ct_data = nil
local json_data = Utils.LoadLocalFile("CardTypeData") local json_data = Utils.LoadLocalFile("CardTypeData")
if json_data then if json_data then
@ -208,7 +205,7 @@ function get_majiang_prefix(game_id)
ct = ct_data[tostring(game_id)] or 0 ct = ct_data[tostring(game_id)] or 0
end end
local prefix = ct == 0 and "" or "a" local prefix = ct == 0 and "" or "a"
--printlog("get_majiang_prefix===>>>",prefix,ct) --printlog("get_majiang_prefix===>>>",prefix,ct)
return prefix return prefix
end end
@ -237,7 +234,7 @@ end
-- 获取gps -- 获取gps
function get_gps(callback) function get_gps(callback)
if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then
local s,e = pcall(function() local s, e = pcall(function()
Utils.LocalAddress(function(result, latitude, longitude) Utils.LocalAddress(function(result, latitude, longitude)
if not result or (latitude == 0 and longitude == 0) then return end if not result or (latitude == 0 and longitude == 0) then return end
DataManager.SelfUser.location = Location.new(tostring(longitude) .. "," .. tostring(latitude)) DataManager.SelfUser.location = Location.new(tostring(longitude) .. "," .. tostring(latitude))
@ -255,8 +252,7 @@ function get_gps(callback)
end end
--依据宽度截断字符 --依据宽度截断字符
function ViewUtil.stringEllipsis(szText,size,full) function ViewUtil.stringEllipsis(szText, size, full)
full = full or false full = full or false
size = size or 4 size = size or 4
--截断结果 --截断结果
@ -267,7 +263,7 @@ function ViewUtil.stringEllipsis(szText,size,full)
local i = 1 local i = 1
local char_count = 0 local char_count = 0
while true do while true do
local cur = string.sub(szText,i,i) local cur = string.sub(szText, i, i)
local byte = string.byte(cur) local byte = string.byte(cur)
if byte == nil then if byte == nil then
break break
@ -281,10 +277,8 @@ function ViewUtil.stringEllipsis(szText,size,full)
if byte > 128 then if byte > 128 then
i = i + 3 i = i + 3
char_count = char_count + 1 char_count = char_count + 1
elseif byte ~= 32 then elseif byte ~= 32 then
if string.byte('A') <= byte and byte <= string.byte('Z') then if string.byte('A') <= byte and byte <= string.byte('Z') then
char_count = char_count + 1 char_count = char_count + 1
else else
char_count = char_count + 0.5 char_count = char_count + 0.5
@ -297,23 +291,23 @@ function ViewUtil.stringEllipsis(szText,size,full)
end end
if i ~= 1 then if i ~= 1 then
szResult = string.sub(szText, 1, i-1) szResult = string.sub(szText, 1, i - 1)
if(bOK) then if (bOK) then
szResult = szResult.."..." szResult = szResult .. "..."
end end
end end
return szResult return szResult
end end
-------------------------lingmeng--------------------------- -------------------------lingmeng---------------------------
function ViewUtil.ShowOneChooose(showText,btnType,callback) function ViewUtil.ShowOneChooose(showText, btnType, callback)
local pop_oneChoose = UIPackage.CreateObjectFromURL("ui://Common/pop_oneChoose") local pop_oneChoose = UIPackage.CreateObjectFromURL("ui://Common/pop_oneChoose")
pop_oneChoose:GetChild('text_show').text = showText pop_oneChoose:GetChild('text_show').text = showText
GRoot.inst:AddChild(pop_oneChoose) GRoot.inst:AddChild(pop_oneChoose)
pop_oneChoose:Center() pop_oneChoose:Center()
local btn_center = pop_oneChoose:GetChild('btn_center') local btn_center = pop_oneChoose:GetChild('btn_center')
if type(btnType) == "number" then if type(btnType) == "number" then
btn_center.icon = string.format("ui://Common/btn_%d",btnType) btn_center.icon = string.format("ui://Common/btn_%d", btnType)
else else
btn_center.icon = btnType btn_center.icon = btnType
end end

View File

@ -6,17 +6,17 @@ local M = {}
--- Create a new CS_GameController --- Create a new CS_GameController
function M.new() function M.new()
setmetatable(M,{__index = GameController}) setmetatable(M, { __index = GameController })
local self = setmetatable({}, {__index = M}) local self = setmetatable({}, { __index = M })
self:init("测试麻将") self:init("测试麻将")
self.class = "CS_GameController" self.class = "CS_GameController"
return self return self
end end
function M:init(name) function M:init(name)
GameController.init(self,name) GameController.init(self, name)
self._eventmap[CS_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards self._eventmap[CS_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards
self._eventmap[CS_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn self._eventmap[CS_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn
self._eventmap[CS_Protocol.GAME_EVT_DRAW] = self.OnEventTakeCard self._eventmap[CS_Protocol.GAME_EVT_DRAW] = self.OnEventTakeCard
@ -40,22 +40,22 @@ function M:init(name)
self._eventmap[CS_Protocol.GAME_EVT_PIAO] = self.OnEventPiao self._eventmap[CS_Protocol.GAME_EVT_PIAO] = self.OnEventPiao
self._eventmap[CS_Protocol.GAME_EVT_TING_TIP] = self.OnEventTingTip self._eventmap[CS_Protocol.GAME_EVT_TING_TIP] = self.OnEventTingTip
self._eventmap[CS_Protocol.GAME_EVT_TING] = self.OnEventTing self._eventmap[CS_Protocol.GAME_EVT_TING] = self.OnEventTing
self._eventmap[CS_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai self._eventmap[CS_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai
self._eventmap[CS_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim self._eventmap[CS_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim
end end
local __pre_delete_card = false local __pre_delete_card = false
-- 发送出牌指令到服务器 -- 发送出牌指令到服务器
function M:SendOutCard(card, callback) function M:SendOutCard(card, callback)
local _room = self._room local _room = self._room
local p = _room.self_player local p = _room.self_player
local _data = {} local _data = {}
_data["card"] = card _data["card"] = card
_data["card_list"] = p.card_list _data["card_list"] = p.card_list
if p.outcard_list and #p.outcard_list>0 then if p.outcard_list and #p.outcard_list > 0 then
_data["outcard_list"] = p.outcard_list _data["outcard_list"] = p.outcard_list
end end
local _client = ControllerManager.GameNetClinet local _client = ControllerManager.GameNetClinet
@ -64,11 +64,11 @@ function M:SendOutCard(card, callback)
-- 进行预删牌处理 -- 进行预删牌处理
_room.curren_outcard_seat = -1 _room.curren_outcard_seat = -1
list_remove(p.card_list,card) list_remove(p.card_list, card)
table.sort(p.card_list, ViewUtil.HandCardSort) table.sort(p.card_list, ViewUtil.HandCardSort)
p.hand_left_count = p.hand_left_count - 1 p.hand_left_count = p.hand_left_count - 1
if not p.outcard_list then p.outcard_list = {} end if not p.outcard_list then p.outcard_list = {} end
p.outcard_list[#p.outcard_list+1] = card p.outcard_list[#p.outcard_list + 1] = card
__pre_delete_card = true __pre_delete_card = true
callback() callback()
end end
@ -81,56 +81,51 @@ function M:SendAction(id)
_client:send(CS_Protocol.GAME_ACTION, _data) _client:send(CS_Protocol.GAME_ACTION, _data)
end end
function M:SendXiPaiAction(callBack) function M:SendXiPaiAction(callBack)
local _data = {} local _data = {}
local _client = ControllerManager.GameNetClinet local _client = ControllerManager.GameNetClinet
_client:send(CS_Protocol.GAME_XIPAI, _data) _client:send(CS_Protocol.GAME_XIPAI, _data)
self.XiPaiCallBack=callBack self.XiPaiCallBack = callBack
end end
function M:OnEventXiPai(evt_data) function M:OnEventXiPai(evt_data)
if evt_data["result"]==0 then if evt_data["result"] == 0 then
if self.XiPaiCallBack then if self.XiPaiCallBack then
self.XiPaiCallBack() self.XiPaiCallBack()
end end
else else
ViewUtil.ErrorTip(1000000,"申请洗牌失败") ViewUtil.ErrorTip(1000000, "申请洗牌失败")
end end
end end
function M:OnEventXiPaiAnim(evt_data) function M:OnEventXiPaiAnim(evt_data)
printlog("洗牌动画===》》》》") printlog("洗牌动画===》》》》")
pt(evt_data) pt(evt_data)
local playeridList = evt_data["list"] local playeridList = evt_data["list"]
local my_isXiPai=false local my_isXiPai = false
local other_isXiPai=false local other_isXiPai = false
if playeridList and #playeridList>0 then if playeridList and #playeridList > 0 then
for i=1,#playeridList do for i = 1, #playeridList do
local p = self._room:GetPlayerById(playeridList[i]) local p = self._room:GetPlayerById(playeridList[i])
if p== self._room.self_player then if p == self._room.self_player then
my_isXiPai=true my_isXiPai = true
else else
other_isXiPai=true other_isXiPai = true
end end
end end
end end
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EventXiPai,my_isXiPai,other_isXiPai) DispatchEvent(self._dispatcher, CS_GameEvent.EventXiPai, my_isXiPai, other_isXiPai)
end) end)
end end
function M:OnEventSendCards(evt_data) function M:OnEventSendCards(evt_data)
if ViewManager.GetCurrenView().dview_class == LobbyView then if ViewManager.GetCurrenView().dview_class == LobbyView then
self:ReturnToRoom() self:ReturnToRoom()
return return
end end
local _room = self._room local _room = self._room
-- if(_room.CurnrenState == StateType.Ready) then -- if(_room.CurnrenState == StateType.Ready) then
-- _room.CurnrenState = StateType.Palying -- _room.CurnrenState = StateType.Palying
-- end -- end
@ -145,15 +140,15 @@ function M:OnEventSendCards(evt_data)
local left_count = evt_data["left_count"] local left_count = evt_data["left_count"]
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
_room.banker_seat = seat _room.banker_seat = seat
for i=1,#_room.player_list do for i = 1, #_room.player_list do
_room.player_list[i].hand_left_count = _room.player_list[i].seat == _room.banker_seat and 14 or 13 _room.player_list[i].hand_left_count = _room.player_list[i].seat == _room.banker_seat and 14 or 13
_room.player_list[i].fz_list = {} _room.player_list[i].fz_list = {}
_room.player_list[i].card_list = {} _room.player_list[i].card_list = {}
end end
p.card_list = handcards p.card_list = handcards
self._room.self_player.hand_left_count = #handcards self._room.self_player.hand_left_count = #handcards
table.sort( handcards, ViewUtil.HandCardSort ) table.sort(handcards, ViewUtil.HandCardSort)
DispatchEvent(self._dispatcher,CS_GameEvent.SendCards, left_count) DispatchEvent(self._dispatcher, CS_GameEvent.SendCards, left_count)
end) end)
end end
@ -162,7 +157,7 @@ function M:OnEventOutCard(evt_data)
local card = evt_data["card"] local card = evt_data["card"]
local p = self._room:GetPlayerBySeat(seat) local p = self._room:GetPlayerBySeat(seat)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
local _room = self._room local _room = self._room
if seat == _room.self_player.seat and __pre_delete_card then if seat == _room.self_player.seat and __pre_delete_card then
__pre_delete_card = false __pre_delete_card = false
else else
@ -172,13 +167,12 @@ function M:OnEventOutCard(evt_data)
end end
p.hand_left_count = p.hand_left_count - 1 p.hand_left_count = p.hand_left_count - 1
if not p.outcard_list then p.outcard_list = {} end if not p.outcard_list then p.outcard_list = {} end
p.outcard_list[#p.outcard_list+1] = card p.outcard_list[#p.outcard_list + 1] = card
DispatchEvent(self._dispatcher,CS_GameEvent.OutCard, p, card) DispatchEvent(self._dispatcher, CS_GameEvent.OutCard, p, card)
end end
end) end)
end end
function M:OnEventTakeCard(evt_data) function M:OnEventTakeCard(evt_data)
local _room = self._room local _room = self._room
local seat = evt_data["seat"] local seat = evt_data["seat"]
@ -186,34 +180,34 @@ function M:OnEventTakeCard(evt_data)
local left_count = evt_data["left_count"] local left_count = evt_data["left_count"]
local p = _room:GetPlayerBySeat(seat) local p = _room:GetPlayerBySeat(seat)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
p.hand_left_count = p.hand_left_count +1 p.hand_left_count = p.hand_left_count + 1
if (seat == _room.self_player.seat) then if (seat == _room.self_player.seat) then
_room.self_player.card_list[#_room.self_player.card_list+1] = card _room.self_player.card_list[#_room.self_player.card_list + 1] = card
-- table.sort( _room.self_player.card_list, ViewUtil.HandCardSort ) -- table.sort( _room.self_player.card_list, ViewUtil.HandCardSort )
end end
DispatchEvent(self._dispatcher,CS_GameEvent.GetCard, seat, card, left_count) DispatchEvent(self._dispatcher, CS_GameEvent.GetCard, seat, card, left_count)
end) end)
end end
function M:OnEventOutHint(evt_data) function M:OnEventOutHint(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.OutHint, evt_data) DispatchEvent(self._dispatcher, CS_GameEvent.OutHint, evt_data)
end) end)
end end
function M:OnEventTurn(evt_data) function M:OnEventTurn(evt_data)
local seat = evt_data["seat"] local seat = evt_data["seat"]
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EventTurn, seat) DispatchEvent(self._dispatcher, CS_GameEvent.EventTurn, seat)
end) end)
end end
function M:OnEventFzTips(evt_data) function M:OnEventFzTips(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
local tiplist = FZTipList.new() local tiplist = FZTipList.new()
local list = evt_data["tip_list"] local list = evt_data["tip_list"]
for i=1,#list do for i = 1, #list do
local dtip = list[i] local dtip = list[i]
local tip = {} local tip = {}
tip.id = dtip["id"] tip.id = dtip["id"]
tip.weight = dtip["weight"] tip.weight = dtip["weight"]
@ -222,12 +216,12 @@ function M:OnEventFzTips(evt_data)
tip.opcard = dtip["opcard"] tip.opcard = dtip["opcard"]
tiplist:AddTip(tip) tiplist:AddTip(tip)
end end
DispatchEvent(self._dispatcher,CS_GameEvent.FZTips, tiplist) DispatchEvent(self._dispatcher, CS_GameEvent.FZTips, tiplist)
end) end)
end end
function M:OnEventFzAction(evt_data) function M:OnEventFzAction(evt_data)
local _room = self._room local _room = self._room
local playerid = evt_data["playerid"] local playerid = evt_data["playerid"]
local card = evt_data["card"] local card = evt_data["card"]
local actice_card = evt_data["active_card"] local actice_card = evt_data["active_card"]
@ -243,12 +237,12 @@ function M:OnEventFzAction(evt_data)
local index = -1 local index = -1
local ftype = type local ftype = type
if (ftype == FZType.Gang_Peng) then if (ftype == FZType.Gang_Peng) then
for i=1,#p.fz_list do for i = 1, #p.fz_list do
if (p.fz_list[i].card == card) then if (p.fz_list[i].card == card) then
p.fz_list[i].card = card p.fz_list[i].card = card
fz = p.fz_list[i] fz = p.fz_list[i]
fz.type = type fz.type = type
index = i -1 index = i - 1
break break
end end
end end
@ -259,21 +253,21 @@ function M:OnEventFzAction(evt_data)
fz.opengang = opengang fz.opengang = opengang
if (index == -1) then if (index == -1) then
if (ftype == FZType.Chi) then if (ftype == FZType.Chi) then
local data ={} local data = {}
data[1] = opcard[1] data[1] = opcard[1]
data[2] = card data[2] = card
data[3] = opcard[2] data[3] = opcard[2]
fz.opcard =data fz.opcard = data
end end
p.fz_list[#p.fz_list+1] = fz p.fz_list[#p.fz_list + 1] = fz
end end
fz.from_seat = from_seat fz.from_seat = from_seat
local remove_num = #opcard local remove_num = #opcard
if (p == _room.self_player) then if (p == _room.self_player) then
for i=1,remove_num do for i = 1, remove_num do
list_remove(p.card_list,opcard[i]) list_remove(p.card_list, opcard[i])
end end
end end
p.hand_left_count = p.hand_left_count - remove_num p.hand_left_count = p.hand_left_count - remove_num
@ -281,13 +275,13 @@ function M:OnEventFzAction(evt_data)
-- if (fz.Type == FZType.Chi) then card = actice_card end -- if (fz.Type == FZType.Chi) then card = actice_card end
local fp = _room:GetPlayerBySeat(from_seat) local fp = _room:GetPlayerBySeat(from_seat)
if card == fp.outcard_list[#fp.outcard_list] then if card == fp.outcard_list[#fp.outcard_list] then
table.remove(fp.outcard_list,#fp.outcard_list) table.remove(fp.outcard_list, #fp.outcard_list)
else else
table.remove(fp.outcard_list,#fp.outcard_list - 1) table.remove(fp.outcard_list, #fp.outcard_list - 1)
end end
end end
DispatchEvent(self._dispatcher,CS_GameEvent.FangziAction, fz, p, index) DispatchEvent(self._dispatcher, CS_GameEvent.FangziAction, fz, p, index)
end) end)
end end
@ -300,8 +294,9 @@ function M:OnEventHu(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
win_p.card_list = cards win_p.card_list = cards
table.sort( win_p.card_list, ViewUtil.HandCardSort) table.sort(win_p.card_list, ViewUtil.HandCardSort)
DispatchEvent(self._dispatcher,CS_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards, win_list) DispatchEvent(self._dispatcher, CS_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards,
win_list)
end) end)
end end
@ -317,15 +312,15 @@ function M:OneventResult1(evt_data)
p.hand_left_count = 0 p.hand_left_count = 0
p.outcard_list = {} p.outcard_list = {}
end end
DispatchEvent(self._dispatcher,CS_GameEvent.ZPResult1, result); DispatchEvent(self._dispatcher, CS_GameEvent.ZPResult1, result);
end) end)
elseif 1 == over or 2 == over then elseif 1 == over or 2 == over then
DataManager.CurrenRoom.Over = true DataManager.CurrenRoom.Over = true
ControllerManager.SetGameNetClient(nil,true) ControllerManager.SetGameNetClient(nil, true)
local total_result = evt_data.total_result local total_result = evt_data.total_result
local result = evt_data.result local result = evt_data.result
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.ZPResult2, result, total_result, over); DispatchEvent(self._dispatcher, CS_GameEvent.ZPResult2, result, total_result, over);
end) end)
end end
end end
@ -334,19 +329,19 @@ function M:OnEventNiao(evt_data)
local list = evt_data["niao"] local list = evt_data["niao"]
local start_seat = evt_data["start_seat"] local start_seat = evt_data["start_seat"]
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EventNiao, list, start_seat) DispatchEvent(self._dispatcher, CS_GameEvent.EventNiao, list, start_seat)
end) end)
end end
function M:OnEventQSTip(evt_data) function M:OnEventQSTip(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EventQSTip, evt_data) DispatchEvent(self._dispatcher, CS_GameEvent.EventQSTip, evt_data)
end) end)
end end
function M:OnEventQSAction(evt_data) function M:OnEventQSAction(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetQSAction, evt_data) DispatchEvent(self._dispatcher, CS_GameEvent.EvnetQSAction, evt_data)
end) end)
end end
@ -360,13 +355,13 @@ function M:OnEventKaiGang(evt_data)
for i = 1, #cardList do for i = 1, #cardList do
p.outcard_list[#p.outcard_list + 1] = cardList[i] p.outcard_list[#p.outcard_list + 1] = cardList[i]
end end
DispatchEvent(self._dispatcher,CS_GameEvent.EventKaiGang, evt_data, self._room.self_player.outcard_list) DispatchEvent(self._dispatcher, CS_GameEvent.EventKaiGang, evt_data, self._room.self_player.outcard_list)
end) end)
end end
function M:OnEventHaidi() function M:OnEventHaidi()
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetHaiDi, evt_data) DispatchEvent(self._dispatcher, CS_GameEvent.EvnetHaiDi, evt_data)
end) end)
end end
@ -378,44 +373,44 @@ function M:OnEventPiaoTip(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
self._room.playing = true self._room.playing = true
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetPiaoTip, evt_data) DispatchEvent(self._dispatcher, CS_GameEvent.EvnetPiaoTip, evt_data)
end) end)
end end
function M:OnEventTingTip() function M:OnEventTingTip()
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EventTingTip) DispatchEvent(self._dispatcher, CS_GameEvent.EventTingTip)
end) end)
end end
function M:OnEventTing(evt_data) function M:OnEventTing(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
local seat = evt_data.seat local seat = evt_data.seat
DispatchEvent(self._dispatcher,CS_GameEvent.EventTing, seat) DispatchEvent(self._dispatcher, CS_GameEvent.EventTing, seat)
end) end)
end end
function M:OnEventPiao(evt_data) function M:OnEventPiao(evt_data)
self._cacheEvent:Enqueue(function() self._cacheEvent:Enqueue(function()
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetPiao, evt_data.seat, evt_data.num) DispatchEvent(self._dispatcher, CS_GameEvent.EvnetPiao, evt_data.seat, evt_data.num)
end) end)
end end
function M:GetPosString( seat ) function M:GetPosString(seat)
if DataManager.CurrenRoom.room_config.people_num ~= 4 then return"" end if DataManager.CurrenRoom.room_config.people_num ~= 4 then return "" end
if seat == 1 then if seat == 1 then
return "" return ""
elseif seat == 2 then elseif seat == 2 then
return "西" return "西"
elseif seat == 3 then elseif seat == 3 then
return "" return ""
elseif seat == 4 then elseif seat == 4 then
return "" return ""
end end
end end
function M:Discard(card) function M:Discard(card)
local _data = {} local _data = {}
_data["card"] = card _data["card"] = card
local _room = self._room local _room = self._room
local _client = ControllerManager.GameNetClinet local _client = ControllerManager.GameNetClinet

View File

@ -46,8 +46,13 @@ function M:InitView(url)
self._full = true self._full = true
-- self.Fix_Msg_Chat = Fix_Msg_Chat -- self.Fix_Msg_Chat = Fix_Msg_Chat
UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha")
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) if self._room.room_config.people_num == 2 then
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
else
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
end
@ -57,10 +62,10 @@ function M:InitView(url)
self.LaiziBG.text = "鬼牌" self.LaiziBG.text = "鬼牌"
self.LaiziBG.visible = false self.LaiziBG.visible = false
self.selectLaiziBtn = self._view:GetChild('selectlaizi') self.selectLaiziBtn = self._view:GetChild('selectlaizi')
self.Laizi1Btn = self._view:GetChild('selectlaizi1') -- self.Laizi1Btn = self._view:GetChild('selectlaizi1')
self.Laizi2Btn = self._view:GetChild('selectlaizi2') -- self.Laizi2Btn = self._view:GetChild('selectlaizi2')
self.Laizi1Btn.visible = false -- self.Laizi1Btn.visible = false
self.Laizi2Btn.visible = false -- self.Laizi2Btn.visible = false
self.selectLaiziBtn.visible = false self.selectLaiziBtn.visible = false
self._hu_tip = HuTipView.new(self) self._hu_tip = HuTipView.new(self)
@ -111,7 +116,7 @@ function M:EventInit()
_gamectr:AddEventListener(CS_GameEvent.SendCards, function(...) _gamectr:AddEventListener(CS_GameEvent.SendCards, function(...)
local arg = { ... } local arg = { ... }
self._tex_LeftCard.text = arg[1] self._tex_LeftCard.text = string.format("剩余%d张牌", arg[1])
local info = self._player_card_info[1] local info = self._player_card_info[1]
info._player.auto_out_card = false info._player.auto_out_card = false
self:UpdateRound() self:UpdateRound()
@ -121,6 +126,7 @@ function M:EventInit()
local p = list[i] local p = list[i]
local info = self._player_info[self:GetPos(p.seat)] local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p) info:FillData(p)
info:SetStartType(_room.room_config.people_num, p.seat)
info:MarkBank(p.seat == _room.banker_seat) info:MarkBank(p.seat == _room.banker_seat)
info:Ready(false) info:Ready(false)
local card_info = self._player_card_info[self:GetPos(p.seat)] local card_info = self._player_card_info[self:GetPos(p.seat)]
@ -182,7 +188,7 @@ function M:EventInit()
local arg = { ... } local arg = { ... }
local seat = arg[1] local seat = arg[1]
local card = arg[2] local card = arg[2]
self._tex_LeftCard.text = arg[3] self._tex_LeftCard.text = string.format("剩余%d张牌", arg[3])
-- self:UpdateRoomInfo() -- self:UpdateRoomInfo()
local info = self._player_card_info[self:GetPos(seat)] local info = self._player_card_info[self:GetPos(seat)]
info:UpdateHandCard(true) info:UpdateHandCard(true)
@ -450,7 +456,7 @@ function M:EventInit()
_gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function() _gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function()
self:UpdateRound() self:UpdateRound()
self._tex_LeftCard.text = "0" self._tex_LeftCard.text = "剩余0张牌"
self._state.selectedIndex = 1 self._state.selectedIndex = 1
if oldGameVersion == 1 then if oldGameVersion == 1 then
self:__PiaoNiaoTip() self:__PiaoNiaoTip()
@ -514,8 +520,13 @@ function M:EventInit()
end end
function M:UpdateRound() function M:UpdateRound()
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round, if self._room.room_config.people_num == 2 then
self._room.room_config.round) self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._room.room_config.round)
else
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
end end
function M:InitPlayerInfoView() function M:InitPlayerInfoView()
@ -851,7 +862,6 @@ function M:__KaiGang(data)
self._view:AddChild(self.kg_card) self._view:AddChild(self.kg_card)
self.kg_card:Center() self.kg_card:Center()
info:UpdateOutCardList(nil, card, self._cursor) info:UpdateOutCardList(nil, card, self._cursor)
self._view:GetChild("remaining_card").text = string.format("剩余%d张牌", self._room.remain_cards)
coroutine.wait(1) coroutine.wait(1)
self._popEvent = true self._popEvent = true
@ -1105,7 +1115,7 @@ function M:ReloadRoom(bskip)
if bskip == nil or bskip == false then if bskip == nil or bskip == false then
self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self:UpdateCardBox(self:GetPos(room.curren_outcard_seat))
self._tex_LeftCard.text = room.left_count self._tex_LeftCard.text = string.format("剩余%d张牌", room.left_count)
self:UpdateRound() self:UpdateRound()
end end
local me = room.self_player local me = room.self_player

View File

@ -1,9 +1,14 @@
local PlayerInfoView = require("Game.View.PlayerInfoView copy") local PlayerInfoView_copy = require("Game.View.PlayerInfoView copy")
local PlayerInfoView = require("Game.View.PlayerInfoView")
local M = {} local M = {}
function M.new(view, mainView) function M.new(view, mainView)
setmetatable(M, { __index = PlayerInfoView }) if mainView._room.room_config.people_num == 2 then
setmetatable(M, { __index = PlayerInfoView_copy })
else
setmetatable(M, { __index = PlayerInfoView })
end
local self = setmetatable({}, { __index = M }) local self = setmetatable({}, { __index = M })
self._view = view self._view = view
self._main_view = mainView self._main_view = mainView
@ -12,7 +17,14 @@ function M.new(view, mainView)
end end
function M:init() function M:init()
PlayerInfoView.init(self) if self._main_view._room.room_config.people_num ~= 2 then
PlayerInfoView.init(self)
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
self._ct_score = self._view:GetChild("info"):GetController("score")
else
PlayerInfoView_copy.init(self)
end
end end
function M:ShowInteraction(type, str) function M:ShowInteraction(type, str)

View File

@ -32,6 +32,7 @@ local function CardPos(obj, area, oder, loc, offset)
end end
function M:UpdateHandCard(getcard, mp, opcard) function M:UpdateHandCard(getcard, mp, opcard)
print("nandaodaozhelil", getcard, mp, opcard)
-- mp 是否明牌 -- mp 是否明牌
-- 如果不明牌,但是有 opcard 表示是起手胡 -- 如果不明牌,但是有 opcard 表示是起手胡
getcard = getcard or false getcard = getcard or false
@ -56,7 +57,6 @@ function M:UpdateHandCard(getcard, mp, opcard)
opnum = #opcard opnum = #opcard
end end
local loc = 0 local loc = 0
print("===============================UpdateHandCard", getcard, mp, opcard, comp)
if not mp then if not mp then
local comp_back = handcard_list["comp_back"] local comp_back = handcard_list["comp_back"]
if self._current_card_type == 2 then if self._current_card_type == 2 then
@ -74,7 +74,8 @@ function M:UpdateHandCard(getcard, mp, opcard)
if opnum ~= -1 then if opnum ~= -1 then
loc = CardPos(obj, self._area_handcard_list, oder, loc, offset) loc = CardPos(obj, self._area_handcard_list, oder, loc, offset)
else else
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) print("=======zhihoudaizheli", oder)
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset, nil, -12)
end end
--改变左右两边的手牌的x值 --改变左右两边的手牌的x值
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then

View File

@ -1,37 +1,37 @@
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()
@ -42,26 +42,27 @@ function M:setHandCardPos(btn_card, i, getcard)
btn_card.x = i * btn_card.width * 1.05 + (getcard and 80 or 0) btn_card.x = i * btn_card.width * 1.05 + (getcard and 80 or 0)
end end
function M:UpdateHandCard(getcard,mp) function M:UpdateHandCard(getcard, mp)
print("======================onthisUpdateHandCard")
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
getcard = getcard or false getcard = getcard or false
mp = mp or false mp = mp or false
local pv = self local pv = self
local _carViewList = self._carViewList local _carViewList = self._carViewList
local _lit = pv._area_handcard_list local _lit = pv._area_handcard_list
for i=1,#_carViewList do for i = 1, #_carViewList do
_carViewList[i].card:Dispose() _carViewList[i].card:Dispose()
end end
_carViewList = {} _carViewList = {}
local _dragCom = self._dragCom local _dragCom = self._dragCom
if (_dragCom == nil) then if (_dragCom == nil) then
_dragCom = UIPackage.CreateObject("Common","UIPanel") _dragCom = UIPackage.CreateObject("Common", "UIPanel")
_dragCom.size = Vector2(1,1) _dragCom.size = Vector2(1, 1)
pv._view:AddChild(_dragCom) pv._view:AddChild(_dragCom)
end end
_dragCom.xy = pv._area_handcard_list.xy _dragCom.xy = pv._area_handcard_list.xy
self._dragCom = _dragCom self._dragCom = _dragCom
@ -74,61 +75,60 @@ function M:UpdateHandCard(getcard,mp)
local cards = DataManager.CurrenRoom.self_player.card_list local cards = DataManager.CurrenRoom.self_player.card_list
if (not mp) then if (not mp) then
for i=0,(#cards)-1 do for i = 0, (#cards) - 1 do
local tem_card = cards[i+1] local tem_card = cards[i + 1]
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card"..b3d) local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(0.9,0.9)--(1.05,1.05) btn_card:SetScale(0.9, 0.9) --(1.05,1.05)
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card) -- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
self:fillCard(btn_card,"201_",tem_card) self:fillCard(btn_card, "201_", tem_card)
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard) self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)
local c_v = NewCardView(btn_card, tem_card) local c_v = NewCardView(btn_card, tem_card)
c_v.index = i c_v.index = i
c_v.old_postion = btn_card.xy c_v.old_postion = btn_card.xy
_carViewList[#_carViewList+1] = c_v _carViewList[#_carViewList + 1] = c_v
_lit:AddChild(btn_card) _lit:AddChild(btn_card)
if (not self._player.auto_out_card) then if (not self._player.auto_out_card) then
btn_card.data = c_v btn_card.data = c_v
-- btn_card.draggable = true; -- btn_card.draggable = true;
-- btn_card.onDragStart:Set(function(evt) -- btn_card.onDragStart:Set(function(evt)
-- local _agent = evt.sender -- local _agent = evt.sender
-- _agent:RemoveFromParent() -- _agent:RemoveFromParent()
-- _dragCom:AddChild(_agent) -- _dragCom:AddChild(_agent)
-- if self.__OnDragStart then -- if self.__OnDragStart then
-- self:__OnDragStart(evt) -- self:__OnDragStart(evt)
-- end -- end
-- _agent.onDragEnd:Set(self.__OnDragEnd,self) -- _agent.onDragEnd:Set(self.__OnDragEnd,self)
-- end) -- end)
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard,self) btn_card.onClick:Set(self.__OnClickHandCard, self)
else else
btn_card:GetChild("icon").color = Color(0.5,0.5,0.5) btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5)
btn_card.touchable = false btn_card.touchable = false
end end
end end
else else
for i=0,(#cards)-1 do for i = 0, (#cards) - 1 do
local mp_card = UIPackage.CreateObject("Main_PokeMaJiang", "Mp_self_card" .. b3d)
local mp_card = UIPackage.CreateObject("Main_PokeMaJiang", "Mp_self_card"..b3d) -- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1]) self:fillCard(mp_card, "201_", cards[i + 1])
self:fillCard(mp_card,"201_",cards[i+1]) mp_card:SetScale(0.9, 0.9) --(1.05,1.05)
mp_card:SetScale(0.9,0.9)--(1.05,1.05) -- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0)
-- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0) self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard)
self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard) _lit:AddChild(mp_card)
_lit:AddChild(mp_card) end
end
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)
@ -138,7 +138,7 @@ end
function M:onTouchMove(context) function M:onTouchMove(context)
local button = context.sender local button = context.sender
local card = button.data local card = button.data
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y)) local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
button.xy = xy - card.touch_pos button.xy = xy - card.touch_pos
end end
@ -147,37 +147,37 @@ function M:__OnDragEnd(context)
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
-- 获取手牌资源位置,可以在扩展中复写 -- 获取手牌资源位置,可以在扩展中复写
@ -187,7 +187,7 @@ end
function M:Clear() function M:Clear()
MJPlayerCardInfoView.Clear(self) MJPlayerCardInfoView.Clear(self)
for i=1,#self._carViewList do for i = 1, #self._carViewList do
self._carViewList[i].card:Dispose() self._carViewList[i].card:Dispose()
end end
self._carViewList = {} self._carViewList = {}

View File

@ -303,16 +303,20 @@ function M:UpdateOutCardList(outcard, card_item, cursor)
col = ((i - num) % (num + 2)) col = ((i - num) % (num + 2))
end end
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)
else
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col)
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
end
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col)
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
if self._current_card_type == 2 then if self._current_card_type == 2 then
self:adjust3dOutPut(obj, self._area_outcard_list, oder, num, i) self:adjust3dOutPut(obj, self._area_outcard_list, oder, num, i)
end end
self:fillCard(obj, card, outlist[i + 1]) self:fillCard(obj, card, outlist[i + 1])
print("==============================thisout", obj, card, outlist[i + 1])
-- 添加角标 -- 添加角标
self:AddFlag(i + 1, outlist[i], obj) self:AddFlag(i + 1, outlist[i], obj)
-- obj.icon = "ui://Main_Majiang/"..card .. outlist[i+1] -- obj.icon = "ui://Main_Majiang/"..card .. outlist[i+1]

View File

@ -55,11 +55,14 @@ function M:init()
end end
function M:setHandCardPos(btn_card, i, getcard) function M:setHandCardPos(btn_card, i, getcard)
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0) if DataManager.CurrenRoom.room_config.people_num == 2 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 end
function M:UpdateHandCard(getcard, mp) function M:UpdateHandCard(getcard, mp)
print("======================main", getcard, mp)
if self.outcard_button then if self.outcard_button then
self.outcard_button:Dispose() self.outcard_button:Dispose()
self.outcard_button = nil self.outcard_button = nil
@ -93,10 +96,15 @@ function M:UpdateHandCard(getcard, mp)
if (not mp) then if (not mp) then
for i = 0, (#cards) - 1 do for i = 0, (#cards) - 1 do
local tem_card = cards[i + 1] local tem_card = cards[i + 1]
local btn_card = nil
if DataManager.CurrenRoom.room_config.people_num == 2 then
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d)
else
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05, 1.05)
end
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
btn_card:SetScale(1.05, 1.05)
-- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card) -- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card)
self:fillCard(btn_card, "201_", tem_card) self:fillCard(btn_card, "201_", tem_card)
self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard) self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard)