hengyang_client/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua

117 lines
3.9 KiB
Lua
Raw Permalink Normal View History

2025-04-01 10:48:36 +08:00
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local M = {}
2025-04-02 19:03:26 +08:00
function M.new(view, mainView)
setmetatable(M, { __index = MJPlayerCardInfoView })
local self = setmetatable({}, { __index = M })
self.class = "PlayerCardInfoView"
self._view = view
self._mainView = mainView
self:init()
return self
2025-04-01 10:48:36 +08:00
end
local function CardPos(obj, area, oder, loc, offset)
offset = offset or 0
local location = loc
if oder == AreaOderType.left_right then
obj.x = location + offset
location = obj.x + obj.width
elseif oder == AreaOderType.up_down then
obj.y = location + offset
location = obj.y + obj.height
elseif oder == AreaOderType.right_left then
obj.x = (area.width - obj.width) - location - offset
location = location + obj.width
elseif oder == AreaOderType.down_up then
obj.y = area.height - obj.height - location - offset
location = location + obj.height
end
return location
end
function M:UpdateHandCard(getcard, mp, opcard)
2025-04-11 12:49:08 +08:00
-- mp 是否明牌
-- 如果不明牌,但是有 opcard 表示是起手胡
getcard = getcard or false
mp = mp or false
local handcard_list = self._mask_data["handcard_list"]
local oder = handcard_list["oder"]
local _player = self._player
local comp_back = handcard_list["comp_back"]
local comp = handcard_list["comp"]
local outcard_list = self._mask_data["outcard_list"]
local card = outcard_list["card"]
2025-04-02 19:03:26 +08:00
self._area_handcard_list:RemoveChildren(0, -1, true)
local opnum = opcard and #opcard or -1
if not mp and opnum > -1 then
-- 起手胡板牌记录,手牌变化两次后,板牌收回
self.__show_qs_hu_times = 1
self.__qs_hu_cards = opcard
elseif self.__qs_hu_cards and opnum == -1 and self.__show_qs_hu_times > 0 then
self.__show_qs_hu_times = self.__show_qs_hu_times - 1
opcard = self.__qs_hu_cards
opnum = #opcard
end
local loc = 0
if not mp then
2025-04-01 10:48:36 +08:00
local comp_back = handcard_list["comp_back"]
2025-04-02 19:03:26 +08:00
if self._current_card_type == 2 then
comp_back = comp_back .. "_3d"
end
for i = 0, _player.hand_left_count - 1 do
local obj
local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0)
if i < opnum then
obj = UIPackage.CreateObject("Main_Majiang", comp)
self:fillCard(obj, card, opcard[i + 1])
else
obj = UIPackage.CreateObject("Main_Majiang", comp_back)
end
if opnum ~= -1 then
loc = CardPos(obj, self._area_handcard_list, oder, loc, offset)
else
2025-04-11 12:49:08 +08:00
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
2025-04-02 19:03:26 +08:00
end
--改变左右两边的手牌的x值
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
obj.x = i * -7.0
end
if (oder == AreaOderType.down_up) then
self._area_handcard_list:AddChildAt(obj, 0)
else
self._area_handcard_list:AddChild(obj)
end
end
else
2025-04-01 10:48:36 +08:00
local outcard_list = self._mask_data["outcard_list"]
2025-04-02 19:03:26 +08:00
local comp = handcard_list["comp"]
2025-04-01 10:48:36 +08:00
local card = outcard_list["card"]
2025-04-11 12:49:08 +08:00
---- print("comp"..comp)
-- -- print(vardump(_player.card_list))
2025-04-01 10:48:36 +08:00
2025-04-02 19:03:26 +08:00
if self._current_card_type == 2 then
comp = comp .. "_3d"
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
for i = 0, #_player.card_list - 1 do
local obj = UIPackage.CreateObject("Main_Majiang", comp)
self:fillCard(obj, card, _player.card_list[i + 1])
local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0)
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
--改变左右两边的手牌的x值
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
obj.x = i * -7
end
if (oder == AreaOderType.down_up) then
self._area_handcard_list:AddChildAt(obj, 0)
else
self._area_handcard_list:AddChild(obj)
end
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
end
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
return M