hengyang_client/lua_probject/main_project/main/majiang/MJMainView.lua

883 lines
29 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local TableBG = require("Game.Data.TableBG")
local MJSettingView = import(".MJSettingViewNew")
local MJMainRightPanelView = import(".MJMainRightPanelView")
local MJCheckG = import('.MJCheckG')
local GameInfoWindow = import(".GameInfoWindow")
local HuCardImg = import(".HuCardImg")
local bg_config = {
{ id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01" },
{ id = 2, url = "base/main_majiang/bg/bg2", thumb = "ui://Main_Majiang/b02" },
{ id = 3, url = "base/main_majiang/bg/bg3", thumb = "ui://Main_Majiang/b03" }
}
local M = {}
setmetatable(M, { __index = MainView })
M.HuCardImg = HuCardImg
local default_bg = 1
local function IsRoomOwer()
--local roomOwner = self._room.player_list[1].self_user.account_id
local roomOwner = DataManager.CurrenRoom.player_list[1].self_user.account_id
return roomOwner == DataManager.SelfUser.account_id
end
function M:InitView(url, use_custom_bg, custom_bg_config)
-- 加载牌型数据
if not DataManager.CardTypeList then
local json_data = Utils.LoadLocalFile("CardTypeData")
if json_data then
DataManager.CardTypeList = json.decode(json_data)
else
DataManager.CardTypeList = {}
end
end
self._room.card_type = DataManager.CardTypeList[tostring(self._room.game_id)] or 1
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
self._full = false
self._scale = true
MainView.InitView(self, url)
self.list_otherHuEffect = self._view:GetChild("list_otherHuEffect")
self.list_HuEffect = self._view:GetChild("list_HuEffect")
self.loader_otherHuCardEffect = self._view:GetChild("loader_otherHuCardEffect")
self.loader_selfHuCardEffect = self._view:GetChild("loader_selfHuCardEffect")
self.cHuCardEffect = self._view:GetController("cHuCardEffect")
self.effect_ZiMo = self._view:GetChild("effect_ZiMo")
self.com_notice = self._view:GetChild("com_notice")
self.btn_setting = self._view:GetChild("btn_setting")
local _view = self._view
self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj")
bg_config = custom_bg_config == nil and bg_config or custom_bg_config
if use_custom_bg then
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
end
local _room = self._room
local _cardbox = _view:GetChild("cardbox")
self._zhuanpanCtr = _cardbox:GetController("zuozi")
-- self._ctr_cardbox = _cardbox:GetController("c1")
-- self._tex_leftTime = _cardbox:GetChild("tex_leftnum")
local centerBox = _view:GetChild("Comp_ConterBox")
self._ctr_cardbox = centerBox:GetController("seat")
self._tex_leftTime = centerBox:GetChild("Text_Time")
self.com_logocType = _view:GetChild("com_logo"):GetController("cType")
if self._room.card_type == 2 then
self:Change3d(true)
else
self:Change3d(false)
end
local rightpanel = self._view:GetChild("com_roominfo")
if self._rightPanelView ~= nil then
self._rightPanelView:Destroy()
end
self._rightPanelView = MJMainRightPanelView.new(self, rightpanel)
--local tempdsaf=self._view:GetChild("btn_back_jiesan")
--tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false)
---- print("2222222222222222222222")
---- print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name)
--self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false)
--local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject
--temp111:SetActive(false)
self._view:GetChild("btn_back_jiesan").onClick:Set(function()
if self.dismiss_room_cd_time > 0 then
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
else
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:AskDismissRoom()
end
end)
self._tex_LeftCard = _view:GetChild("remaining_card")
self._player_card_info = {}
local _player_card_info = self._player_card_info
for i = 1, _room.room_config.people_num do
local tem = _view:GetChild("player_card_info" .. i)
print("====================================", "player_card_info" .. i, tem)
pt(_view)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
end
local list = _room.player_list
for i = 1, #list do
local p = list[i]
local info = _player_card_info[self:GetPos(p.seat)]
info:SetPlayer(p)
info:FillData()
end
local list = _room.player_list
local readyNum = 0
for i = 1, #list do
local p = list[i]
if p.ready then readyNum = readyNum + 1 end
end
for i = 1, #_room.player_list do
local p = _room.player_list[i]
local zi, icon = self:GetPosString(p.seat)
if self._room.card_type == 2 then
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
end
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
end
self._ctr_action = _view:GetController("action")
if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then
--self._ctr_action.selectedIndex = 2
elseif not _room.self_player.ready then
local round = DataManager.CurrenRoom.room_config.config.times or 1
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
if xpconfig then
if round > 1 then
self._ctr_action.selectedIndex = 1
else
self._ctr_action.selectedIndex = 2
end
else
self._ctr_action.selectedIndex = 1
end
else
self._ctr_action.selectedIndex = 0
end
local changeTable = self._view:GetChild('btn_change')
if changeTable then
changeTable.onClick:Set(function()
default_bg = default_bg + 1 > #bg_config and 1 or default_bg + 1
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
end)
end
local checkG = self._view:GetChild('btn_check')
if checkG then
checkG.onClick:Set(function()
local checkG = MJCheckG.new()
checkG:Show()
end)
end
local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players')
viewList_witness:SetVirtual()
viewList_witness.itemRenderer = function(index, obj)
obj:GetChild('title').text = _room.witness_player_list[index + 1].nick
ImageLoad.Load(_room.witness_player_list[index + 1].portrait, obj:GetChild('btn_head')._iconObject)
end
local btn_witness = self._view:GetChild('btn_pangGuang')
if btn_witness then
btn_witness.onClick:Set(function()
if _room._flag_updateWitness then
print("linemng", _room._flag_updateWitness, #_room.witness_player_list, viewList_witness.numItems)
_room._flag_updateWitness = false
if viewList_witness.numItems == #_room.witness_player_list then
viewList_witness:RefreshVirtualList()
else
viewList_witness.numItems = #_room.witness_player_list
end
end
self._view:GetController('witness').selectedIndex = 1
end)
end
self._view:GetChild('btn_closeRoom').onClick:Set(function()
if IsRoomOwer() then
self._gamectr:AskDismissRoom(
function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Family)
else
ViewUtil.ErrorTip(res.ReturnCode)
end
end)
return
end
self._gamectr:LevelRoom(function(res)
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode)
end
ViewManager.ChangeView(ViewManager.View_Family)
end)
end)
self:InitXiPai()
self:InitXiPai1()
self.btn_setting.onClick:Set(function()
local view = MJSettingView.new(self)
view:Show()
end)
end
function M:InitXiPai()
self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim")
self._xipaiPanel.visible = false
self._root_view:AddChild(self._xipaiPanel)
local offset = get_offset(self._full_offset)
self._xipaiPanel.width = GRoot.inst.width - (offset * 2)
self._xipaiPanel.height = GRoot.inst.height
self._xipaiPanel.x = offset
self._handAnimCtr = self._xipaiPanel:GetController("anim")
self._handAnimCtr.selectedIndex = 0
--self:PlayXiPai()
end
function M:InitXiPai1()
self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim02")
self._xipaiPanel1.visible = false
self._root_view:AddChild(self._xipaiPanel1)
local offset = get_offset(self._full_offset)
self._xipaiPanel1.width = GRoot.inst.width - (offset * 2)
self._xipaiPanel1.height = GRoot.inst.height
self._xipaiPanel1.x = offset
self._handAnimCtr1 = self._xipaiPanel1:GetController("anim1")
self._handAnimCtr1.selectedIndex = 0
end
function M:PlayXiPai(xipaiCallBack)
if self._xipaiPanel then
coroutine.start(function()
self._xipaiPanel.visible = true
self._xipaiPanel:GetTransition("XiPai"):Play()
self._handAnimCtr.selectedIndex = 1
coroutine.wait(3)
self._handAnimCtr.selectedIndex = 0
self._xipaiPanel.visible = false
if xipaiCallBack then
xipaiCallBack()
end
end)
end
end
function M:PlayXiPai1(xipaiCallBack)
if self._xipaiPanel1 then
coroutine.start(function()
self._xipaiPanel1.visible = true
self._xipaiPanel1:GetTransition("XiPai"):Play()
self._handAnimCtr1.selectedIndex = 1
coroutine.wait(3)
self._handAnimCtr1.selectedIndex = 0
self._xipaiPanel1.visible = false
if xipaiCallBack then
xipaiCallBack()
end
end)
end
end
function M:EventInit()
MainView.EventInit(self)
end
function M:Change3d(flag)
local _room = self._room
local _view = self._view
local _cardbox = _view:GetChild("cardbox")
for i = 1, #_room.player_list do
local p = _room.player_list[i]
local zi, icon = self:GetPosString(p.seat)
if self._room.card_type == 2 then
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
end
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
end
-- 如果要切换3d牌桌的cardbox位置及上方文字(剩余牌,回合数)显示不错乱,需要做以下改动
-- 取消文字组合的3d控制器的位置 并设置对cardbox的关联左左顶顶
if flag == true then
if _view:GetController("3d") ~= nil then
_view:GetController("3d").selectedIndex = 1
_cardbox.x = (_view.width - _cardbox.width) * 0.5
end
_cardbox:GetController("3d").selectedIndex = 1
_cardbox.x = (_view.width - _cardbox.width) * 0.5
else
if _view:GetController("3d") ~= nil then
_view:GetController("3d").selectedIndex = 0
_cardbox.x = (_view.width - _cardbox.width) * 0.5
end
_cardbox:GetController("3d").selectedIndex = 0
_cardbox.x = (_view.width - _cardbox.width) * 0.5
end
end
-- function M:NewSettingView()
-- local settingView = MJSettingView.new(self._root_view)
-- settingView:FillBgSection(function(url)
-- LoadGameBg(url, self._root_view)
-- end, self._room.game_id, default_bg)
-- settingView.onChangeCardCallback:Add(function()
-- self:Change3d(DataManager.CurrenRoom.card_type == 2)
-- self:ReloadRoom()
-- for i = 1, #self._room.player_list do
-- local p = self._room.player_list[i]
-- local card_info = self._player_card_info[self:GetPos(p.seat)]
-- card_info:ResetCardType()
-- end
-- end)
-- settingView.onEXVoiceCallback:Add(function()
-- end)
-- settingView.onEXChuPaiCallback:Add(function()
-- end)
-- return settingView
-- end
function M:NewSettingView()
local settingView = MJSettingView.new(self._root_view)
-- settingView._view:GetChild("btn_card_1").icon = pack_full_name .. "com_card_preview"
-- local gear = settingView._view:GetChild("panel_bg"):GetGear(0)
-- gear.pages = {"0", "1", "2"}
-- gear:Apply()
-- settingView.Change3d = function() end
settingView:FillBgSection(function(url, index)
LoadGameBg(url, self._root_view)
self._zhuanpanCtr.selectedIndex = index - 1
end, self._room.game_id, 1, bg_config)
settingView.onChangeCardCallback:Add(function()
self:RemoveCursor()
for i = 1, #self._room.player_list do
local p = self._room.player_list[i]
local card_info = self._player_card_info[self:GetPos(p.seat)]
card_info:Clear(true)
card_info:ResetCardType()
end
self:Change3d(DataManager.CurrenRoom.card_type == 2)
self:ReloadRoom(true)
end)
return settingView
end
function M:GetIndex(seat)
local index = seat
local people_num = self._room.room_config.people_num
if people_num == 2 and seat == 2 then
index = 3
elseif people_num == 3 and seat == 3 then
index = 4
end
return index
end
function M:GetPosString(seat)
if DataManager.CurrenRoom.room_config.people_num == 4 then
if seat == 1 then
return "", "dir_1"
elseif seat == 2 then
return "", "dir_2"
elseif seat == 3 then
return "西", "dir_3"
elseif seat == 4 then
return "", "dir_4"
end
elseif DataManager.CurrenRoom.room_config.people_num == 3 then
if seat == 1 then
return "", "dir_1"
elseif seat == 2 then
return "", "dir_2"
elseif seat == 3 then
return "西", "dir_3"
end
elseif DataManager.CurrenRoom.room_config.people_num == 2 then
if seat == 1 then
return "", "dir_1"
elseif seat == 2 then
return "西", "dir_3"
end
end
end
function M:SetCardBoxPosition()
local _room = self._room
for i = 1, _room.room_config.people_num do
local tex = self._view:GetChild("cardbox"):GetChild("direction" .. i)
local index = _room.self_player.seat + i - 1
index = index > 4 and index - 4 or index
tex.text = self._gamectr:GetPosString(index)
end
end
function M:markOutCards(showTip, data)
for i = 1, #self._room.player_list do
local p = self._room.player_list[i]
local info = self._player_card_info[self:GetPos(p.seat)]
for j = 1, #p.outcard_list do
local card = p.outcard_list[j]
if card == data then
for k = 1, #p.outcard_list do
local obj = info:GetOutCardByIndex(k)
if obj.data == card then
obj:GetController("gray").selectedIndex = showTip and 1 or 0
end
end
end
end
end
end
function M:OnPlayerEnter(...)
self:PlayMJSound("user_enter.mp3")
MainView.OnPlayerEnter(self, ...)
local arg = { ... }
local p = arg[1]
local info = self._player_card_info[self:GetPos(p.seat)]
info:SetPlayer(p)
info:FillData()
end
function M:OnPlayerReady(...)
self:PlayMJSound("user_ready.mp3")
local arg = { ... }
local p = arg[1]
local _room = self._room
local _view = self._view
local _player_info = self._player_info
if p.seat == _room.self_player.seat then
self._ctr_action.selectedIndex = 0
if p.entrust and self._clearingView and self._clearingView.DestroyWithCallback then
self._clearingView:DestroyWithCallback()
end
end
local info = _player_info[self:GetPos(p.seat)]
info:Ready(true)
local readyNum = self:GetReadyNum()
if readyNum == _room.room_config.people_num then
local _cardbox = _view:GetChild("cardbox")
for i = 1, #_room.player_list do
local p = _room.player_list[i]
local zi, icon = self:GetPosString(p.seat)
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
end
end
if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then
if self._state.selectedIndex == 2 then
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:StartGame()
end
--self._ctr_action.selectedIndex = 2
elseif not _room.self_player.ready then
--self._ctr_action.selectedIndex = 1
local round = DataManager.CurrenRoom.room_config.config.times or 1
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
if xpconfig then
if round > 1 then
self._ctr_action.selectedIndex = 1
else
self._ctr_action.selectedIndex = 2
end
else
self._ctr_action.selectedIndex = 1
end
else
self._ctr_action.selectedIndex = 0
end
end
function M:CountCardLeftNum(card)
local player_list = DataManager.CurrenRoom.player_list
local count = 4
for i = 1, #player_list do
local p = player_list[i]
if p.card_list then
for j = 1, #p.card_list do
if p.card_list[j] == card then
count = count - 1
end
end
end
for j = 1, #p.outcard_list do
if p.outcard_list[j] == card then
count = count - 1
end
end
for j = 1, #p.fz_list do
local fz = p.fz_list[j]
if fz.type == FZType.Chi then
for k = 1, #fz.opcard do
if card == fz.opcard[k] then
count = count - 1
break
end
end
else
local num = fz.type == FZType.Peng and 3 or 4
if card == fz.card then
count = count - num
end
end
end
end
return count
end
function M:OnPlayerLeave(...)
self:PlayMJSound("user_leave.mp3")
MainView.OnPlayerLeave(self, ...)
local _room = self._room
if _room.banker_seat == _room.self_player.seat then
self._ctr_action.selectedIndex = 0
end
end
function M:PlayerChangeLineState()
local isOutCard = true
local str = "玩家 "
for _, player in ipairs(self._room.player_list) do
if player.line_state == 0 then
isOutCard = false
-- str = str .. self._gamectr:GetPosString(player.seat) .. "、"
end
end
-- if not isOutCard then
-- str = str.sub(str, 1, string.len(str) - string.len("、"))
-- str = str .. " 正在赶来,请稍等"
-- if self._room.curren_round > 0 then
-- self._waitingView = ModalWaitingView.new(self._view, str)
-- end
-- else
-- if self._waitingView then
-- self._waitingView:CloseWaitingView()
-- end
-- end
self._player_card_info[1]._area_handcard_list.touchable = isOutCard
end
function M:NewMJPlayerCardInfoView(view, index)
local infoView = {}
if self._room.room_config.people_num == 2 then
if index == 1 then
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
elseif index == 2 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
end
elseif self._room.room_config.people_num == 3 then
if index == 1 then
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
elseif index == 2 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "E")
elseif index == 3 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
end
elseif self._room.room_config.people_num == 4 then
if index == 1 then
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
elseif index == 2 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "E")
elseif index == 3 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
elseif index == 4 then
infoView = MJPlayerCardInfoView.new(view, self, nil, "W")
end
end
return infoView
end
function M:RemoveCursor()
-- if self._cursor.parent then
-- self._cursor.parent:GetController("color").selectedIndex = 0
-- end
self._cursor:RemoveFromParent()
end
function M:Destroy()
UIPackage.RemovePackage("base/main_majiang/ui/Main_Majiang")
MainView.Destroy(self)
self._cursor:Dispose()
self._xipaiPanel:Dispose()
end
local majiang_asset_path = "base/main_majiang/sound/"
function M:PlayMJSound(path)
ViewUtil.PlaySound(self.asset_group, majiang_asset_path .. path)
end
function M:PlayMJMusic(path)
ViewUtil.PlayMuisc(self.asset_group, majiang_asset_path .. path)
end
function M:PlaySound(group, sex, path)
local sex_path = ViewUtil.Sex_Chat[sex]
local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path)
ViewUtil.PlaySound(group, path1)
end
function M:GetPrefix()
return get_majiang_prefix(DataManager.CurrenRoom.game_id)
end
-- 所有对家显示手牌
function M:ShowHand(msg)
local data = msg[1]
for _, player in pairs(data.info_list) do
local infoView = self._player_card_info[self:GetPos(player.seat)]
if infoView.class ~= "PlayerSelfCardInfoView" then
printlog("ShowHand", player.seat)
infoView:ShowHand(player.hand_card)
end
end
end
function M:OnResult1(...)
local _room = self._room
self._popEvent = false
self:__CloseTip()
self._left_time = 0
self:UpdateCardBox(0)
self._ctr_cardbox.selectedIndex = 0
local arg = { ... }
self:ShowHand(arg)
local result = arg[1]
local liuju = result.liuju
local data = result.info_list
local niao = result.niao
-- if liuju then
-- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
-- self._view:AddChild(le)
-- le:Center()
-- le:GetTransition("t0"):Play()
-- coroutine.start(function()
-- coroutine.wait(1)
-- le:Dispose()
-- end)
-- end
self:RemoveCursor()
self._clearingView = self.EXClearingViewClass.new(self._root_view)
coroutine.start(function()
coroutine.wait(0.5)
self._clearingView:Show()
self._popEvent = true
end)
if _room.curren_round ~= _room.room_config.round then
-- if #niao == 0 then self._view:GetChild("n13").visible = false end
self._clearingView:InitData(0, _room, result, nil, function(...)
for i = 1, #data do
local p = _room:GetPlayerBySeat(data[i].seat)
p.total_score = data[i].total_score
local card_info = self._player_card_info[self:GetPos(p.seat)]
local info = self._player_info[self:GetPos(p.seat)]
--card_info:Clear()
card_info:ResetCardType()
if _room:checkHpNonnegative() then
p.cur_hp = data[i].total_score
end
info:UpdateScore()
info._view:GetChild("zhanji").visible = true
local num = data[i].total_score
if num >= 0 then
info._view:GetController("text_color").selectedIndex = 0
info._view:GetChild("text_jifen").text = "+" .. num
else
info._view:GetController("text_color").selectedIndex = 1
info._view:GetChild("text_jifen").text = num
end
info._view:GetChild("mask_piao").title = ""
info._view:GetController("piao_niao").selectedIndex = 0
p.fz_list = {}
end
DataManager.CurrenRoom.self_player.card_list = {}
--self._state.selectedIndex = 2
self._clearingView = nil
end)
end
end
function M:OnHuCard(...)
self._left_time = 0
self:UpdateCardBox(0)
self:__CloseTip()
self._popEvent = false
local arg = { ... }
local win_seat = arg[1]
local lose_seat = arg[2]
local win_card = arg[3]
local cards = arg[4]
local win_list = arg[5]
local scoreData = arg[6]
local index = self:GetPos(win_seat)
local info = self._player_card_info[index]
local player = self._room:GetPlayerBySeat(win_seat)
self:RemoveCursor()
--info:UpdateHandCard(false, false)
info:ShowHuCard(win_card)
self.cHuCardEffect.selectedIndex = 1
local loader_HuEffect = nil
local list_HuCardEffect = nil
if win_seat == self._room.self_player.seat then
loader_HuEffect = self.loader_selfHuCardEffect
list_HuCardEffect = self.list_HuEffect
else
loader_HuEffect = self.loader_otherHuCardEffect
list_HuCardEffect = self.list_otherHuEffect
end
---
local isZiMo = win_seat == lose_seat
DataManager.CurrenRoom.isZiMoHu = isZiMo
local hu_sound = isZiMo and ("zimo") or ("hu")
printlog("声音====>>>", hu_sound)
self:PlaySound(self.asset_group, player.self_user.sex, hu_sound)
local effects = isZiMo and ("tile_zimo") or ("tile_hu")
loader_HuEffect.visible = true
loader_HuEffect.url = "ui://Main_Majiang/" .. effects
loader_HuEffect:SetScale(2, 2)
loader_HuEffect:TweenScale(Vector2(1, 1), 0.3):SetEase(EaseType.QuartOut)
self.effect_ZiMo.xy = loader_HuEffect.xy
self.effect_ZiMo:SetPlaySettings(0, -1, 1, -1);
self.effect_ZiMo.visible = true
self.effect_ZiMo.playing = true
self.effect_ZiMo.onPlayEnd:Set(function()
self.effect_ZiMo.visible = false
end)
coroutine.start(function()
coroutine.wait(1)
loader_HuEffect.visible = false
local Effects = {}
for i = 1, #win_list do
local HuMsg = win_list[i]
-- ↓↓↓先排列好特效图片
if HuMsg.type > 2 and HuMsg.type < 32 then
local sound_name = string.format(self.Sound_path .. "%s/%s.mp3",
ViewUtil.Sex_Chat[player.self_user.sex],
"he" .. HuMsg.type)
ViewUtil.PlaySound(self.asset_group, sound_name)
local imgList = self.HuCardImg[HuMsg.type]
for _, img in pairs(imgList) do
local imgPath = "ui://Main_Majiang/" .. img
local imgObj = list_HuCardEffect:AddItemFromPool()
local imgLoader = imgObj:GetChild("loader_img")
imgLoader.url = imgPath
imgObj.visible = false
Effects[#Effects + 1] = imgObj
end
end
end
-- ↓↓↓播放动画
for _, imgObj in pairs(Effects) do
imgObj.visible = true
local effect_xingxing = imgObj:GetChild("effect_xingxing")
effect_xingxing:SetPlaySettings(0, -1, 1, -1);
effect_xingxing.visible = true
effect_xingxing.playing = true
effect_xingxing.onPlayEnd:Set(function()
effect_xingxing.visible = false
end)
local imgLoader = imgObj:GetChild("loader_img")
imgLoader:SetScale(2, 2)
imgLoader:Center()
imgLoader:TweenScale(Vector2(1, 1), 0.3)
coroutine.wait(0.7)
end
-- 扣分动画
for _, pScore in pairs(scoreData) do
local infoView = self._player_info[self:GetPos(pScore.seat)]
infoView:UpdateScore(pScore.total_score, true)
end
coroutine.wait(0.5)
self._popEvent = true
list_HuCardEffect:RemoveChildrenToPool()
self.cHuCardEffect.selectedIndex = 0
end)
end
function M:Show()
MainView.Show(self)
if self._room and self._room.curren_round == 0 then
local win = GameInfoWindow.New()
win:Show(self._room)
end
self:DoNoticeAnimation()
end
function M:DoNoticeAnimation()
self.noticeIndex = self.noticeIndex or 1
if not DataManager.GameNotice or #DataManager.GameNotice == 0 then
return
end
local text_notice = self.com_notice:GetChild("text_notice")
text_notice.text = DataManager.GameNotice[self.noticeIndex]
local speed = 44
local time = text_notice.width / speed
text_notice.x = self.com_notice.width
local tween = text_notice:TweenMove(Vector2(-text_notice.width, text_notice.y), time):OnComplete(function()
self:DoNoticeAnimation()
end)
tween:SetEase(EaseType.Linear)
self.noticeIndex = self.noticeIndex + 1
if self.noticeIndex > #DataManager.GameNotice then
self.noticeIndex = 1
end
end
return M