双人对局新界面

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

View File

@ -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

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

@ -134,7 +134,6 @@ function ViewUtil.HandCardSort2(a,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
@ -142,18 +141,15 @@ function ViewUtil.HandCardSort3(a,b)
return sort_a < sort_b return sort_a < sort_b
end end
function ViewUtil.CardPos(obj, area, oder, index, offset, isAdd, padding)
function ViewUtil.CardPos(obj, area, oder, index, offset,isAdd)
offset = offset or 0 offset = offset or 0
padding = padding or 0
if oder == AreaOderType.left_right then if oder == AreaOderType.left_right then
obj.x = index * obj.width + offset obj.x = index * (obj.width + padding) + offset
elseif oder == AreaOderType.up_down then elseif oder == AreaOderType.up_down then
obj.y = index * obj.height + offset obj.y = index * (obj.height + padding) + offset
elseif oder == AreaOderType.right_left then elseif oder == AreaOderType.right_left then
obj.x = (area.width - obj.width) - index * obj.width - offset obj.x = (area.width - obj.width) - index * (obj.width + padding) - offset
elseif oder == AreaOderType.down_up then elseif oder == AreaOderType.down_up then
if isAdd then if isAdd then
obj.y = area.height - obj.height - index * obj.height * 1.5 - offset obj.y = area.height - obj.height - index * obj.height * 1.5 - offset
@ -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
@ -256,7 +253,6 @@ 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
--截断结果 --截断结果
@ -282,9 +278,7 @@ function ViewUtil.stringEllipsis(szText,size,full)
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

View File

@ -81,7 +81,6 @@ 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
@ -97,11 +96,8 @@ function M:OnEventXiPai(evt_data)
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)
@ -124,7 +120,6 @@ function M:OnEventXiPaiAnim(evt_data)
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()
@ -178,7 +173,6 @@ function M:OnEventOutCard(evt_data)
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"]
@ -301,7 +295,8 @@ 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

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")
if self._room.room_config.people_num == 2 then
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") 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()
if self._room.room_config.people_num == 2 then
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round, self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
self._room.room_config.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)
if mainView._room.room_config.people_num == 2 then
setmetatable(M, { __index = PlayerInfoView_copy })
else
setmetatable(M, { __index = PlayerInfoView }) 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()
if self._main_view._room.room_config.people_num ~= 2 then
PlayerInfoView.init(self) 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

@ -43,6 +43,7 @@ function M:setHandCardPos(btn_card, i, getcard)
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
@ -113,7 +114,6 @@ function M:UpdateHandCard(getcard,mp)
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])

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, oder, col)
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row) ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
end
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)
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) 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
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d) 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) btn_card:SetScale(1.05, 1.05)
end
-- 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)