Polish arena effects, audio and diagnostics
This commit is contained in:
1 parent
2774e625c1
commit
16a359d4af
28 files changed
+512
-257
No files matched your search
@@ -7,8 +7,8 @@ local Strings = require(game.ReplicatedStorage.Hunter.Strings)
|
||||
type Fighter = Types.Fighter
|
||||
local HotPoint = require(Runtime.Parent.HotPoint)
|
||||
local Rules = require(Runtime.TrophyRules)
|
||||
local TweenService = game:GetService("TweenService")
|
||||
type Drop = {marker: Common.Marker, amount: number, expires: number, fade: Tween?}
|
||||
local Diagnostics = require(Runtime.ZoneDiagnostics)
|
||||
type Drop = {marker: Common.Marker, amount: number, expires: number}
|
||||
|
||||
local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local map, geometry, folder = assert(ctx.map), ctx.geometry, ctx.folder
|
||||
@@ -16,7 +16,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
local tokens: {Drop} = {}
|
||||
local carried: {[Player]: number} = {}
|
||||
local function floorAt(at: Vector3): Vector3
|
||||
local hit = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry)
|
||||
local hit = Diagnostics.raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry)
|
||||
return if hit then hit.Position else map.ground.position
|
||||
end
|
||||
local function tokenDrop(at: Vector3, amount: number, now: number)
|
||||
@@ -26,38 +26,34 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
if Rules.canMerge(existing.marker.origin, floor) then
|
||||
existing.amount += amount
|
||||
existing.expires = now + Rules.LIFETIME
|
||||
if existing.fade then existing.fade:Cancel(); existing.fade = nil end
|
||||
existing.marker.body.Transparency = .04
|
||||
existing.marker.body:SetAttribute("TokenExpiresAt", existing.expires)
|
||||
existing.marker.label.Text = Strings.tokens(existing.amount)
|
||||
return
|
||||
end
|
||||
end
|
||||
if #tokens >= Rules.MAX_DROPS then
|
||||
local old = table.remove(tokens, 1)
|
||||
if old.fade then old.fade:Cancel() end
|
||||
old.marker.body:Destroy()
|
||||
end
|
||||
table.insert(tokens, {marker = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true), amount = amount, expires = now + Rules.LIFETIME})
|
||||
local mark = Common.marker(folder, "Tokens", Strings.tokens(amount), floor, Common.gold, 1.55, true)
|
||||
mark.body:SetAttribute("TokenExpiresAt", now + Rules.LIFETIME)
|
||||
mark.body:SetAttribute("TokenFlashSeconds", Rules.FLASH_SECONDS)
|
||||
table.insert(tokens, {marker = mark, amount = amount, expires = now + Rules.LIFETIME})
|
||||
end
|
||||
local function runTrophies(fighters: {Fighter}, now: number)
|
||||
for i = #tokens, 1, -1 do
|
||||
local token = tokens[i]
|
||||
local collector: Fighter? = nil
|
||||
if now < token.expires then
|
||||
if token.expires - now <= Rules.FLASH_SECONDS and not token.fade then
|
||||
token.fade = TweenService:Create(token.marker.body,TweenInfo.new(.38,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true),{Transparency=.76})
|
||||
token.fade:Play()
|
||||
end
|
||||
for _, f in fighters do
|
||||
if Common.boundsAt(f.root.Position, token.marker.origin, 5, 6) and Common.visibleAt(f, token.marker.body.Position, geometry) then collector = f; break end
|
||||
end
|
||||
if not collector then continue end
|
||||
local p = collector.player
|
||||
if not carried[p] then ctx.cue(fighters, false, collector.side) end
|
||||
if not carried[p] then ctx.events.fire(Kinds.TokenPicked, {userId = p.UserId}, {p}) end
|
||||
carried[p] = (carried[p] or 0) + token.amount
|
||||
p:SetAttribute("ArenaTokens", carried[p])
|
||||
end
|
||||
if token.fade then token.fade:Cancel() end
|
||||
token.marker.body:Destroy()
|
||||
table.remove(tokens, i)
|
||||
end
|
||||
@@ -66,7 +62,7 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
if amount and Common.boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, HotPoint.Radius, 7) then
|
||||
ctx.scoring.add(f.side, amount, Kinds.TokensBanked, f.player)
|
||||
ctx.contribute(f.player, "tokensBanked", amount)
|
||||
ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount})
|
||||
ctx.events.fire(Kinds.TokensBanked, {side = f.side, userId = f.player.UserId, value = amount, at = if f.side == "Blue" then map.blue else map.orange})
|
||||
ctx.cue(fighters, true, nil)
|
||||
carried[f.player] = nil
|
||||
f.player:SetAttribute("ArenaTokens", nil)
|
||||
@@ -92,7 +88,6 @@ local function start(ctx: Types.ModeContext): Types.ModeInstance
|
||||
death = drop, leaving = drop,
|
||||
destroy = function()
|
||||
for p in carried do p:SetAttribute("ArenaTokens", nil) end
|
||||
for _, token in tokens do if token.fade then token.fade:Cancel() end end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user