117 lines
3.9 KiB
Lua
117 lines
3.9 KiB
Lua
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
|
|
|
|
local M = {}
|
|
|
|
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
|
|
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)
|
|
-- 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"]
|
|
|
|
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
|
|
local comp_back = handcard_list["comp_back"]
|
|
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
|
|
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
|
|
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
|
|
local outcard_list = self._mask_data["outcard_list"]
|
|
local comp = handcard_list["comp"]
|
|
local card = outcard_list["card"]
|
|
---- print("comp"..comp)
|
|
-- -- print(vardump(_player.card_list))
|
|
|
|
if self._current_card_type == 2 then
|
|
comp = comp .. "_3d"
|
|
end
|
|
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
|
|
end
|
|
end
|
|
end
|
|
|
|
return M
|