121 lines
3.4 KiB
Lua
121 lines
3.4 KiB
Lua
|
|
|
|
local M = {
|
|
btn_card = nil,
|
|
card_item = 0,
|
|
Hierarchy = 0,
|
|
index_X = 0,
|
|
index_Y = 0,
|
|
isUser = false,
|
|
initPos = Vector2.zero
|
|
}
|
|
|
|
|
|
function M.InitCardView(card_code, index_X, index_Y, type)
|
|
-- setmetatable(M, {__index = CardView})
|
|
local self = setmetatable({}, {__index = M})
|
|
self._room = DataManager.CurrenRoom
|
|
self.btn_card = self:InitUI(card_code, type)
|
|
self.card_item = card_code
|
|
self.index_X = index_X
|
|
self.index_Y = index_Y
|
|
self.btn_card.data = self
|
|
|
|
self:Init()
|
|
return self, self.btn_card
|
|
end
|
|
|
|
function M:Init()
|
|
self.card_width = 87
|
|
self.initPos = Vector2.zero
|
|
end
|
|
|
|
function M:InitUI(card_code, type)
|
|
local card
|
|
if type == 0 then
|
|
card = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Btn_Card")
|
|
self.icon = card:GetChild("icon")
|
|
self.icon.icon = self:getHandCardItem("ui://Main_RunBeard/201_", card_code)
|
|
self.icon:SetScale(self:getCardSize(), self:getCardSize())
|
|
card:GetChild("n6"):SetScale(self:getCardSize(), self:getCardSize())
|
|
elseif type == 1 then
|
|
card = UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Gcm_OutCard")
|
|
self.icon = card:GetChild("icon")
|
|
if card_code == 0 then
|
|
self.icon = "ui://Main_RunBeard/202_1_300"
|
|
else
|
|
self.icon = self:GetCardItem("ui://Main_RunBeard/203_", card_code)
|
|
end
|
|
end
|
|
return card
|
|
end
|
|
|
|
function M:GetCardItem(card_1, card_2)
|
|
printlog("jefe get card_item")
|
|
local room = DataManager.CurrenRoom
|
|
if room.change_card_display ~= nil then
|
|
return card_1 .. room.change_card_display .. card_2
|
|
else
|
|
return card_1 .. "2_" .. card_2
|
|
end
|
|
end
|
|
|
|
function M:getCardSize()
|
|
if self._room.change_card_size ~= nil then
|
|
return self._room.change_card_size
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
function M:getHandCardItem(card_1, card_2)
|
|
if self._room.change_card_display ~= nil then
|
|
if self._room.change_card_display == "1_" then
|
|
if self._room.change_card_size ~= nil then
|
|
self.card_width = 94 * self._room.change_card_size
|
|
else
|
|
self.card_width = 94
|
|
end
|
|
|
|
return card_1 .. "4_" .. card_2
|
|
end
|
|
if self._room.change_card_size ~= nil then
|
|
self.card_width = 87 * self._room.change_card_size
|
|
else
|
|
self.card_width = 87
|
|
end
|
|
return card_1 .. self._room.change_card_display .. card_2
|
|
else
|
|
if self._room.change_card_size ~= nil then
|
|
self.card_width = 90 * self._room.change_card_size
|
|
else
|
|
self.card_width = 90
|
|
end
|
|
return card_1 .. "6_" .. card_2
|
|
end
|
|
end
|
|
|
|
function M:UpdateKan()
|
|
self.btn_card.touchable = false
|
|
self.btn_card:GetController("Kan").selectedIndex = 1
|
|
end
|
|
|
|
function M:UpdateTing(isting)
|
|
self.btn_card:GetController("mark_ting").selectedIndex = isting and 1 or 0
|
|
end
|
|
|
|
function M:UpdateIcon()
|
|
self.icon.icon = self:getHandCardItem("ui://Main_RunBeard/201_", self.card_item)
|
|
-- self.btn_card:TweenMove(self:GetHandCardPos(self, #CountCards), 0.02)
|
|
end
|
|
|
|
function M:UpdateScale()
|
|
local size = self._room.change_card_size
|
|
-- card_view.btn_card:GetChild("icon").icon = self:getHandCardItem("ui://Main_RunBeard/201_", card_view.card_item)
|
|
self.icon:SetScale(size, size)
|
|
self.btn_card:GetChild("n6"):SetScale(size, size)
|
|
-- self:getCardWidth()
|
|
end
|
|
|
|
return M
|