fix(ui): 카드 드래그 중 hover 보간 중단
- hover 확대 보간 타이머 ID를 추적해 새 hover 또는 드래그 시작 시 기존 타이머를 종료 - 손패 카드 드래그 시작 시 모든 손패 카드의 scale과 위치를 기본값으로 즉시 정리 - 드래그 중 손패 hover enter/exit 처리를 무시해 드래그 위치와 hover 보간이 충돌하지 않도록 수정 - 드래그 종료 시 드래그 카드 scale을 1.0으로 복귀 검증: - node --check tools/deck/gen-slaydeck.mjs - node --test tools/balance/sim-balance.test.mjs tools/map/rogue-map.test.mjs
This commit is contained in:
@@ -78,6 +78,13 @@
|
|||||||
"Attributes": [],
|
"Attributes": [],
|
||||||
"Name": "TweenEventId"
|
"Name": "TweenEventId"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Type": "number",
|
||||||
|
"DefaultValue": "0",
|
||||||
|
"SyncDirection": 0,
|
||||||
|
"Attributes": [],
|
||||||
|
"Name": "CardHoverTweenId"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Type": "any",
|
"Type": "any",
|
||||||
"DefaultValue": "nil",
|
"DefaultValue": "nil",
|
||||||
@@ -1416,7 +1423,7 @@
|
|||||||
"Name": "hover"
|
"Name": "hover"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Code": "local prefix = \"\"\nlocal count = 0\nlocal xs = {}\nlocal baseY = 0\nlocal hoverIndex = 0\nlocal push = 110\nif string.find(path, \"/ui/DefaultGroup/CardHand/Card\") == 1 then\n\tprefix = \"/ui/DefaultGroup/CardHand/Card\"\n\tcount = 5\n\txs = { -400, -200, 0, 200, 400 }\n\tbaseY = 0\n\thoverIndex = tonumber(string.match(path, \"Card(%d+)\")) or 0\nelseif string.find(path, \"/ui/DefaultGroup/RewardHud/Reward\") == 1 then\n\tprefix = \"/ui/DefaultGroup/RewardHud/Reward\"\n\tcount = 3\n\txs = { -300, 0, 300 }\n\tbaseY = 0\n\thoverIndex = tonumber(string.match(path, \"Reward(%d+)\")) or 0\nelseif string.find(path, \"/ui/DefaultGroup/ShopHud/Card\") == 1 then\n\tprefix = \"/ui/DefaultGroup/ShopHud/Card\"\n\tcount = 3\n\txs = { -300, 0, 300 }\n\tbaseY = 20\n\thoverIndex = tonumber(string.match(path, \"Card(%d+)\")) or 0\nend\nif count <= 0 then\n\treturn\nend\nlocal items = {}\nfor i = 1, count do\n\tlocal e = _EntityService:GetEntityByPath(prefix .. tostring(i))\n\tif e ~= nil and e.UITransformComponent ~= nil then\n\t\tlocal tr = e.UITransformComponent\n\t\tlocal tx = xs[i]\n\t\tlocal ty = baseY\n\t\tlocal sc = 1\n\t\tif hover == true and hoverIndex > 0 then\n\t\t\tif i == hoverIndex and e.Enable == true then\n\t\t\t\tsc = 1.5\n\t\t\telseif i < hoverIndex then\n\t\t\t\ttx = tx - push\n\t\t\telseif i > hoverIndex then\n\t\t\t\ttx = tx + push\n\t\t\tend\n\t\tend\n\t\ttable.insert(items, { tr = tr, sx = tr.anchoredPosition.x, sy = tr.anchoredPosition.y, ss = tr.UIScale.x, tx = tx, ty = ty, ts = sc })\n\tend\nend\nlocal elapsed = 0\nlocal duration = 0.12\nlocal eventId = 0\neventId = _TimerService:SetTimerRepeat(function()\n\telapsed = elapsed + 1 / 60\n\tlocal t = math.min(elapsed / duration, 1)\n\tlocal eased = _TweenLogic:Ease(0, 1, 1, EaseType.SineEaseOut, t)\n\tfor i = 1, #items do\n\t\tlocal it = items[i]\n\t\tlocal x = it.sx + (it.tx - it.sx) * eased\n\t\tlocal y = it.sy + (it.ty - it.sy) * eased\n\t\tlocal s = it.ss + (it.ts - it.ss) * eased\n\t\tit.tr.anchoredPosition = Vector2(x, y)\n\t\tit.tr.UIScale = Vector3(s, s, 1)\n\tend\n\tif t >= 1 then\n\t\t_TimerService:ClearTimer(eventId)\n\tend\nend, 1 / 60)",
|
"Code": "local prefix = \"\"\nlocal count = 0\nlocal xs = {}\nlocal baseY = 0\nlocal hoverIndex = 0\nlocal push = 110\nif string.find(path, \"/ui/DefaultGroup/CardHand/Card\") == 1 then\n\tif self.DragSlot ~= nil and self.DragSlot > 0 then\n\t\treturn\n\tend\n\tprefix = \"/ui/DefaultGroup/CardHand/Card\"\n\tcount = 5\n\txs = { -400, -200, 0, 200, 400 }\n\tbaseY = 0\n\thoverIndex = tonumber(string.match(path, \"Card(%d+)\")) or 0\nelseif string.find(path, \"/ui/DefaultGroup/RewardHud/Reward\") == 1 then\n\tprefix = \"/ui/DefaultGroup/RewardHud/Reward\"\n\tcount = 3\n\txs = { -300, 0, 300 }\n\tbaseY = 0\n\thoverIndex = tonumber(string.match(path, \"Reward(%d+)\")) or 0\nelseif string.find(path, \"/ui/DefaultGroup/ShopHud/Card\") == 1 then\n\tprefix = \"/ui/DefaultGroup/ShopHud/Card\"\n\tcount = 3\n\txs = { -300, 0, 300 }\n\tbaseY = 20\n\thoverIndex = tonumber(string.match(path, \"Card(%d+)\")) or 0\nend\nif count <= 0 then\n\treturn\nend\nif self.CardHoverTweenId ~= nil and self.CardHoverTweenId ~= 0 then\n\t_TimerService:ClearTimer(self.CardHoverTweenId)\n\tself.CardHoverTweenId = 0\nend\nlocal items = {}\nfor i = 1, count do\n\tlocal e = _EntityService:GetEntityByPath(prefix .. tostring(i))\n\tif e ~= nil and e.UITransformComponent ~= nil then\n\t\tlocal tr = e.UITransformComponent\n\t\tlocal tx = xs[i]\n\t\tlocal ty = baseY\n\t\tlocal sc = 1\n\t\tif hover == true and hoverIndex > 0 then\n\t\t\tif i == hoverIndex and e.Enable == true then\n\t\t\t\tsc = 1.5\n\t\t\telseif i < hoverIndex then\n\t\t\t\ttx = tx - push\n\t\t\telseif i > hoverIndex then\n\t\t\t\ttx = tx + push\n\t\t\tend\n\t\tend\n\t\ttable.insert(items, { tr = tr, sx = tr.anchoredPosition.x, sy = tr.anchoredPosition.y, ss = tr.UIScale.x, tx = tx, ty = ty, ts = sc })\n\tend\nend\nlocal elapsed = 0\nlocal duration = 0.12\nlocal eventId = 0\neventId = _TimerService:SetTimerRepeat(function()\n\telapsed = elapsed + 1 / 60\n\tlocal t = math.min(elapsed / duration, 1)\n\tlocal eased = _TweenLogic:Ease(0, 1, 1, EaseType.SineEaseOut, t)\n\tfor i = 1, #items do\n\t\tlocal it = items[i]\n\t\tlocal x = it.sx + (it.tx - it.sx) * eased\n\t\tlocal y = it.sy + (it.ty - it.sy) * eased\n\t\tlocal s = it.ss + (it.ts - it.ss) * eased\n\t\tit.tr.anchoredPosition = Vector2(x, y)\n\t\tit.tr.UIScale = Vector3(s, s, 1)\n\tend\n\tif t >= 1 then\n\t\t_TimerService:ClearTimer(eventId)\n\t\tif self.CardHoverTweenId == eventId then\n\t\t\tself.CardHoverTweenId = 0\n\t\tend\n\tend\nend, 1 / 60)\nself.CardHoverTweenId = eventId",
|
||||||
"Scope": 2,
|
"Scope": 2,
|
||||||
"ExecSpace": 6,
|
"ExecSpace": 6,
|
||||||
"Attributes": [],
|
"Attributes": [],
|
||||||
@@ -1589,7 +1596,7 @@
|
|||||||
"Name": "slot"
|
"Name": "slot"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Code": "if self.CombatOver == true or self.FxBusy == true or self.TurnBusy == true then\n\treturn\nend\nif self.Hand == nil or self.Hand[slot] == nil then\n\treturn\nend\nself.DragSlot = slot",
|
"Code": "if self.CombatOver == true or self.FxBusy == true or self.TurnBusy == true then\n\treturn\nend\nif self.Hand == nil or self.Hand[slot] == nil then\n\treturn\nend\nif self.CardHoverTweenId ~= nil and self.CardHoverTweenId ~= 0 then\n\t_TimerService:ClearTimer(self.CardHoverTweenId)\n\tself.CardHoverTweenId = 0\nend\nlocal cardXs = { -400, -200, 0, 200, 400 }\nfor i = 1, 5 do\n\tlocal e = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CardHand/Card\" .. tostring(i))\n\tif e ~= nil and e.UITransformComponent ~= nil then\n\t\te.UITransformComponent.UIScale = Vector3(1, 1, 1)\n\t\te.UITransformComponent.anchoredPosition = Vector2(cardXs[i], 0)\n\tend\nend\nself.DragSlot = slot",
|
||||||
"Scope": 2,
|
"Scope": 2,
|
||||||
"ExecSpace": 6,
|
"ExecSpace": 6,
|
||||||
"Attributes": [],
|
"Attributes": [],
|
||||||
@@ -1649,7 +1656,7 @@
|
|||||||
"Name": "touchPoint"
|
"Name": "touchPoint"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Code": "if self.DragSlot ~= slot then\n\treturn\nend\nself.DragSlot = 0\nlocal cardXs = { -400, -200, 0, 200, 400 }\nlocal e = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CardHand/Card\" .. tostring(slot))\nif e ~= nil and e.UITransformComponent ~= nil then\n\te.UITransformComponent.anchoredPosition = Vector2(cardXs[slot], 0)\nend\nself:ResolveCardDrop(slot, touchPoint)",
|
"Code": "if self.DragSlot ~= slot then\n\treturn\nend\nself.DragSlot = 0\nlocal cardXs = { -400, -200, 0, 200, 400 }\nlocal e = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CardHand/Card\" .. tostring(slot))\nif e ~= nil and e.UITransformComponent ~= nil then\n\te.UITransformComponent.anchoredPosition = Vector2(cardXs[slot], 0)\n\te.UITransformComponent.UIScale = Vector3(1, 1, 1)\nend\nself:ResolveCardDrop(slot, touchPoint)",
|
||||||
"Scope": 2,
|
"Scope": 2,
|
||||||
"ExecSpace": 6,
|
"ExecSpace": 6,
|
||||||
"Attributes": [],
|
"Attributes": [],
|
||||||
|
|||||||
@@ -2437,6 +2437,7 @@ function writeCodeblocks() {
|
|||||||
prop('number', 'MaxEnergy', '3'),
|
prop('number', 'MaxEnergy', '3'),
|
||||||
prop('number', 'Turn', '0'),
|
prop('number', 'Turn', '0'),
|
||||||
prop('number', 'TweenEventId', '0'),
|
prop('number', 'TweenEventId', '0'),
|
||||||
|
prop('number', 'CardHoverTweenId', '0'),
|
||||||
prop('any', 'EndTurnHandler'),
|
prop('any', 'EndTurnHandler'),
|
||||||
prop('any', 'NewGameHandler'),
|
prop('any', 'NewGameHandler'),
|
||||||
prop('any', 'WarriorSelectHandler'),
|
prop('any', 'WarriorSelectHandler'),
|
||||||
@@ -3266,6 +3267,9 @@ local baseY = 0
|
|||||||
local hoverIndex = 0
|
local hoverIndex = 0
|
||||||
local push = 110
|
local push = 110
|
||||||
if string.find(path, "/ui/DefaultGroup/CardHand/Card") == 1 then
|
if string.find(path, "/ui/DefaultGroup/CardHand/Card") == 1 then
|
||||||
|
if self.DragSlot ~= nil and self.DragSlot > 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
prefix = "/ui/DefaultGroup/CardHand/Card"
|
prefix = "/ui/DefaultGroup/CardHand/Card"
|
||||||
count = 5
|
count = 5
|
||||||
xs = { ${CARD_XS.join(', ')} }
|
xs = { ${CARD_XS.join(', ')} }
|
||||||
@@ -3287,6 +3291,10 @@ end
|
|||||||
if count <= 0 then
|
if count <= 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if self.CardHoverTweenId ~= nil and self.CardHoverTweenId ~= 0 then
|
||||||
|
_TimerService:ClearTimer(self.CardHoverTweenId)
|
||||||
|
self.CardHoverTweenId = 0
|
||||||
|
end
|
||||||
local items = {}
|
local items = {}
|
||||||
for i = 1, count do
|
for i = 1, count do
|
||||||
local e = _EntityService:GetEntityByPath(prefix .. tostring(i))
|
local e = _EntityService:GetEntityByPath(prefix .. tostring(i))
|
||||||
@@ -3324,8 +3332,12 @@ eventId = _TimerService:SetTimerRepeat(function()
|
|||||||
end
|
end
|
||||||
if t >= 1 then
|
if t >= 1 then
|
||||||
_TimerService:ClearTimer(eventId)
|
_TimerService:ClearTimer(eventId)
|
||||||
|
if self.CardHoverTweenId == eventId then
|
||||||
|
self.CardHoverTweenId = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end, 1 / 60)`, [
|
end, 1 / 60)
|
||||||
|
self.CardHoverTweenId = eventId`, [
|
||||||
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' },
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' },
|
||||||
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'hover' },
|
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'hover' },
|
||||||
]),
|
]),
|
||||||
@@ -3466,6 +3478,18 @@ end
|
|||||||
if self.Hand == nil or self.Hand[slot] == nil then
|
if self.Hand == nil or self.Hand[slot] == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if self.CardHoverTweenId ~= nil and self.CardHoverTweenId ~= 0 then
|
||||||
|
_TimerService:ClearTimer(self.CardHoverTweenId)
|
||||||
|
self.CardHoverTweenId = 0
|
||||||
|
end
|
||||||
|
local cardXs = { ${CARD_XS.join(', ')} }
|
||||||
|
for i = 1, 5 do
|
||||||
|
local e = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand/Card" .. tostring(i))
|
||||||
|
if e ~= nil and e.UITransformComponent ~= nil then
|
||||||
|
e.UITransformComponent.UIScale = Vector3(1, 1, 1)
|
||||||
|
e.UITransformComponent.anchoredPosition = Vector2(cardXs[i], 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
self.DragSlot = slot`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]),
|
self.DragSlot = slot`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]),
|
||||||
method('OnCardDrag', `if self.DragSlot ~= slot then
|
method('OnCardDrag', `if self.DragSlot ~= slot then
|
||||||
return
|
return
|
||||||
@@ -3486,6 +3510,7 @@ local cardXs = { ${CARD_XS.join(', ')} }
|
|||||||
local e = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand/Card" .. tostring(slot))
|
local e = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand/Card" .. tostring(slot))
|
||||||
if e ~= nil and e.UITransformComponent ~= nil then
|
if e ~= nil and e.UITransformComponent ~= nil then
|
||||||
e.UITransformComponent.anchoredPosition = Vector2(cardXs[slot], 0)
|
e.UITransformComponent.anchoredPosition = Vector2(cardXs[slot], 0)
|
||||||
|
e.UITransformComponent.UIScale = Vector3(1, 1, 1)
|
||||||
end
|
end
|
||||||
self:ResolveCardDrop(slot, touchPoint)`, [
|
self:ResolveCardDrop(slot, touchPoint)`, [
|
||||||
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' },
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' },
|
||||||
|
|||||||
Reference in New Issue
Block a user