Polish Capture the Flag navigation and feedback
This commit is contained in:
1 parent
522344e34b
commit
9fb926537c
8 files changed
+203
-5
No files matched your search
@@ -0,0 +1,107 @@
|
||||
--!strict
|
||||
local Players = game:GetService("Players")
|
||||
local rs = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local UI = require(rs:WaitForChild("HunterUI") :: ModuleScript)
|
||||
local S = require(rs.Hunter.Strings)
|
||||
local Stage = require(rs.Hunter.Stage)
|
||||
local player = Players.LocalPlayer
|
||||
local pg = player:WaitForChild("PlayerGui")
|
||||
local match = rs:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
||||
local providers = script.Parent.HintProviders
|
||||
local gui = Instance.new("ScreenGui")
|
||||
gui.Name, gui.DisplayOrder, gui.ResetOnSpawn, gui.Enabled = "ModeGuide", 25, false, false
|
||||
gui.Parent = pg
|
||||
local panel = UI.plate(gui,"Direction",UDim2.fromScale(.5,.73),UDim2.new(.85,0,0,60),UI.Outline)
|
||||
panel.AnchorPoint = Vector2.new(.5,.5)
|
||||
Instance.new("UISizeConstraint",panel).MaxSize = Vector2.new(326,60)
|
||||
local contour = UI.contour(panel,UI.Gold)
|
||||
local arrow = UI.label(panel,"Arrow","▲",UDim2.fromOffset(11,10),UDim2.fromOffset(40,38),26,UI.Gold)
|
||||
local title = UI.label(panel,"Title","",UDim2.fromOffset(54,6),UDim2.new(1,-65,0,22),18,UI.Ink)
|
||||
local detail = UI.label(panel,"Distance","",UDim2.fromOffset(54,30),UDim2.new(1,-65,0,22),15,UI.Muted)
|
||||
title.TextXAlignment, detail.TextXAlignment = Enum.TextXAlignment.Left, Enum.TextXAlignment.Left
|
||||
local markers = Instance.new("Folder")
|
||||
markers.Name = "ModeTargets"
|
||||
markers.Parent = workspace
|
||||
local highlights: {[Player]: Highlight} = {}
|
||||
local provider: any = nil
|
||||
local currentMode: string? = nil
|
||||
local current: Vector3? = nil
|
||||
local function color(side: unknown): Color3
|
||||
return if side=="Blue" then UI.Blue elseif side=="Orange" then UI.Orange else UI.Gold
|
||||
end
|
||||
local function refresh()
|
||||
local id = match:GetAttribute("Ruleset")
|
||||
local active = player:GetAttribute("InArena")==true and match:GetAttribute("Phase")=="Round" and Stage.combatAllowed(match)
|
||||
if id~=currentMode then
|
||||
currentMode = if typeof(id)=="string" then id else nil
|
||||
local module = if typeof(id)=="string" then providers:FindFirstChild(id) else nil
|
||||
provider = if module and module:IsA("ModuleScript") then require(module) else nil
|
||||
end
|
||||
local ready: {[Player]: boolean} = {}
|
||||
if active and provider and provider.highlight then
|
||||
for _, member in Players:GetPlayers() do
|
||||
local character = member.Character
|
||||
if member~=player and character and provider.highlight(match,player,member) then
|
||||
ready[member]=true
|
||||
local entry=highlights[member]
|
||||
if not entry then
|
||||
entry=Instance.new("Highlight")
|
||||
entry.Name = "ModeTarget"
|
||||
entry.DepthMode=Enum.HighlightDepthMode.AlwaysOnTop
|
||||
entry.FillTransparency=.77
|
||||
entry.OutlineTransparency=.16
|
||||
entry.Parent=markers
|
||||
highlights[member]=entry
|
||||
end
|
||||
entry.Adornee=character
|
||||
local tone=color(member:GetAttribute("ArenaTeam"))
|
||||
entry.FillColor,entry.OutlineColor=tone,tone
|
||||
end
|
||||
end
|
||||
end
|
||||
for member,entry in highlights do
|
||||
if not ready[member] then entry:Destroy(); highlights[member]=nil end
|
||||
end
|
||||
local root=player.Character and player.Character.PrimaryPart
|
||||
local menu=pg:FindFirstChild("MainMenu")
|
||||
local results=pg:FindFirstChild("ArenaResults")
|
||||
local blocked=pg:GetAttribute("HunterVoting")==true or (menu and menu:IsA("ScreenGui") and menu.Enabled)
|
||||
or (results and results:GetAttribute("LiveScoreboardOpen")==true)
|
||||
gui.Enabled=active and not blocked
|
||||
panel.Visible=false
|
||||
current=nil
|
||||
if not gui.Enabled or not root or not provider or not provider.target then return end
|
||||
local point,label,side=provider.target(match,player)
|
||||
if not point or not label then return end
|
||||
local delta=point-root.Position
|
||||
current=point
|
||||
panel.Visible=true
|
||||
title.Text=label
|
||||
local copy=S.hint.Siege
|
||||
detail.Text=S.studs(delta.Magnitude)..(if delta.Y>8 then copy.above elseif delta.Y < -8 then copy.below else "")
|
||||
local tint=color(side)
|
||||
arrow.TextColor3=tint
|
||||
contour:SetAttribute("Accent",tint)
|
||||
end
|
||||
local elapsed=0
|
||||
local step=RunService.Heartbeat:Connect(function(dt)
|
||||
elapsed+=dt
|
||||
if elapsed < .14 then return end
|
||||
elapsed%=.14
|
||||
refresh()
|
||||
end)
|
||||
local render=RunService.RenderStepped:Connect(function()
|
||||
local camera=workspace.CurrentCamera
|
||||
local root=player.Character and player.Character.PrimaryPart
|
||||
if not camera or not root or not current then return end
|
||||
local d=current-root.Position
|
||||
local v=camera.CFrame:VectorToObjectSpace(Vector3.new(d.X,0,d.Z))
|
||||
arrow.Rotation=math.deg(math.atan2(v.X,-v.Z))
|
||||
end)
|
||||
script.Destroying:Once(function()
|
||||
step:Disconnect()
|
||||
render:Disconnect()
|
||||
markers:Destroy()
|
||||
gui:Destroy()
|
||||
end)
|
||||
Reference in new issue
Block a user