南城使用新二人对战页面,初始hp移动到邀请人时触发

master
罗家炜 2025-04-08 14:35:41 +08:00
parent b97e76dd92
commit b5fb6912da
4 changed files with 64 additions and 37 deletions

View File

@ -282,19 +282,6 @@ function M:ChangeNumber(fgCtr, group_id, limit, num, minus_only, sort_type)
else else
list_familyNumber.itemRenderer = function(index, obj) list_familyNumber.itemRenderer = function(index, obj)
obj:GetChild('text_name').text = members[index + 1].nick obj:GetChild('text_name').text = members[index + 1].nick
if self._lev ~= 3 then
if members[index + 1].hp < 777777000 then
fgCtr:FG_ChangeFag(group_id, members[index + 1].uid, members[index + 1].hp + 777777000,
function(res)
if res.ReturnCode == 0 then
else
ViewUtil.CloseModalWait('join_room')
ViewUtil.ErrorMsg(self._root_view, res.ReturnCode, '默认分配积分失败')
end
end)
end
end
end end
list_familyNumber.numItems = res.Data.member_num list_familyNumber.numItems = res.Data.member_num
return 1 return 1
@ -506,7 +493,21 @@ function M:JoinRoom(roomId)
-- ViewUtil.ShowBannerOnScreenCenter("加入房间回调") -- ViewUtil.ShowBannerOnScreenCenter("加入房间回调")
-- end) -- end)
--先换成邀请玩家 --先换成邀请玩家
fgCtr:FG_AddMember(self._group.id, tonumber(roomId), function() fgCtr:FG_AddMember(self._group.id, tonumber(roomId), function(res)
if (res.ReturnCode == 0) then
ViewUtil.ShowBannerOnScreenCenter('添加成功!', 1)
fgCtr:FG_ChangeFag(self._group.id, tonumber(roomId), 777777000,
function(res)
if res.ReturnCode == 0 then
ViewUtil.ShowBannerOnScreenCenter('分配默认积分成功!', 1)
else
ViewUtil.ErrorMsg(self._root_view, res.ReturnCode, '默认分配积分失败')
end
end)
else
ViewUtil.ErrorTip(res.ReturnCode, '邀请玩家失败!')
end
self:ChangeNumber(fgCtr, self._group.id, 0, self._group.total_member_num1, false, self:ChangeNumber(fgCtr, self._group.id, 0, self._group.total_member_num1, false,
1) 1)
end) end)

View File

@ -57,7 +57,11 @@ function M:UpdateRemainCard(card_num, hide)
end end
function M:FillData(player) function M:FillData(player)
PlayerInfoView.FillData(self, player) if self._main_view._room.room_config.people_num == 2 then
PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
end
end end
return M return M

View File

@ -25,7 +25,11 @@ function M:InitView(url)
self._gps_style = 1 self._gps_style = 1
self._full = true self._full = true
UIPackage.AddPackage("extend/majiang/nancheng/ui/Extend_MJ_NanCheng") UIPackage.AddPackage("extend/majiang/nancheng/ui/Extend_MJ_NanCheng")
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") if self._room.room_config.people_num == 2 then
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
self._hu_tip = HuTipView.new(self) self._hu_tip = HuTipView.new(self)
self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人个旧麻将 ' .. room.score_times .. '' self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人个旧麻将 ' .. room.score_times .. ''
@ -95,8 +99,13 @@ function M:IsShowGangZi(btn, isShow)
end end
function M:UpdateRound() function M:UpdateRound()
self._view:GetChild("tex_round1").text = self._room.curren_round if self._room.room_config.people_num == 2 then
self._view:GetChild("tex_round2").text = 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()
@ -204,7 +213,7 @@ function M:EventInit()
local seat = arg[1] local seat = arg[1]
local card = arg[2] local card = arg[2]
-- self._tex_leftTime.text = arg[3] -- self._tex_leftTime.text = arg[3]
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)
@ -365,7 +374,7 @@ function M:EventInit()
if _room:checkHpNonnegative() then if _room:checkHpNonnegative() then
p.cur_hp = data[i].hp_info.cur_hp p.cur_hp = data[i].hp_info.cur_hp
end end
info:UpdateScore() -- info:UpdateScore()
info._view:GetChild("zhanji").visible = true info._view:GetChild("zhanji").visible = true
local num = data[i].hp_info.total_hp local num = data[i].hp_info.total_hp
if num > 0 then if num > 0 then
@ -408,7 +417,7 @@ function M:EventInit()
_gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() _gamectr:AddEventListener(TX_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
self:__PiaoNiaoTip() self:__PiaoNiaoTip()
end) end)
@ -719,7 +728,7 @@ function M:ReloadRoom(bskip)
end end
info:UpdateHandCard() info:UpdateHandCard()
local head_info = self._player_info[self:GetPos(p.seat)] local head_info = self._player_info[self:GetPos(p.seat)]
head_info:UpdateScore() -- head_info:UpdateScore()
head_info._view:GetChild('zhanji').visible = true head_info._view:GetChild('zhanji').visible = true
local num = p.total_hp or 0 local num = p.total_hp or 0
if num > 0 then if num > 0 then
@ -760,7 +769,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
end end

View File

@ -1,10 +1,15 @@
local PlayerInfoView = require("Game.View.PlayerInfoView") local PlayerInfoView = require("Game.View.PlayerInfoView")
local PlayerInfoView_copy = require("Game.View.PlayerInfoView copy")
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
local self = setmetatable({}, {__index = M}) setmetatable(M, { __index = PlayerInfoView_copy })
else
setmetatable(M, { __index = PlayerInfoView })
end
local self = setmetatable({}, { __index = M })
self._view = view self._view = view
self._main_view = mainView self._main_view = mainView
self:init() self:init()
@ -12,16 +17,20 @@ 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
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1") PlayerInfoView.init(self)
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2") self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
self._ct_score = self._view:GetChild("info"):GetController("score") 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)
if type == 3 then if type == 3 then
Voice.DownLoad(str, function(clip) Voice.DownLoad(str, function(clip)
if (clip ) then if (clip) then
self:ShowMaskVoice(clip.length) self:ShowMaskVoice(clip.length)
GameApplication.Instance:PlayVoice(clip) GameApplication.Instance:PlayVoice(clip)
end end
@ -30,26 +39,30 @@ function M:ShowInteraction(type,str)
self:SetChat(str) self:SetChat(str)
elseif type == 2 then elseif type == 2 then
local chat_index = tonumber(str) local chat_index = tonumber(str)
self._main_view:PlayChatSound(self._player.self_user.sex,chat_index) self._main_view:PlayChatSound(self._player.self_user.sex, chat_index)
local language, index = self._main_view:GetChatMsgLanguage(chat_index) local language, index = self._main_view:GetChatMsgLanguage(chat_index)
self:SetChat(self._main_view.Fix_Msg_Chat[index]) self:SetChat(self._main_view.Fix_Msg_Chat[index])
elseif type == 1 then elseif type == 1 then
self:SetBiaoqing("ui://Chat/"..str) self:SetBiaoqing("ui://Chat/" .. str)
end end
end end
function M:UpdateRemainCard(card_num, hide) function M:UpdateRemainCard(card_num, hide)
if hide then if hide then
self._view:GetController("show_remain").selectedIndex = 0 self._view:GetController("show_remain").selectedIndex = 0
else else
self._view:GetController("show_remain").selectedIndex = 1 self._view:GetController("show_remain").selectedIndex = 1
end end
self._view:GetChild("com_remain"):GetChild("tex_remain").text = card_num self._view:GetChild("com_remain"):GetChild("tex_remain").text = card_num
end end
function M:FillData(player) function M:FillData(player)
PlayerInfoView.FillData(self, player) if self._main_view._room.room_config.people_num == 2 then
self:UpdateScore(player.total_score) PlayerInfoView_copy.FillData(self, player)
else
PlayerInfoView.FillData(self, player)
self:UpdateScore(player.total_score)
end
end end
function M:UpdateScore() function M:UpdateScore()