Advertisement
Quoteory

Effects

Nov 5th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.87 KB | None | 0 0
  1. local CollectionService = game:GetService("CollectionService")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local Debris = game:GetService("Debris")
  4. local TweenService = game:GetService("TweenService")
  5. local RunService = game:GetService("RunService")
  6. local Quire = require(ReplicatedStorage.Quire)
  7. local QUtil = Quire.GetModule("QUtil")
  8.  
  9. local isServer = RunService:IsServer()
  10. local isClient = RunService:IsClient()
  11.  
  12. local effectEvent = QUtil.GetRemoteEvent("EffectEvent")
  13. local effects = ReplicatedStorage.Effects
  14. local sounds = effects.Sounds
  15.  
  16. local EffectsManager= {}
  17.  
  18. function EffectsManager.Shockwave(effectParams)
  19.     local position = effectParams.Position or Vector3.new(0, 0, 0)
  20.     local startSize = effectParams.StartSize or Vector3.new(0, 0, 0)
  21.     local endSize = effectParams.EndSize or Vector3.new(5, 5, 5)
  22.     local duration = effectParams.Duration or 1
  23.     local startTransparency = effectParams.StartTransparency or 0
  24.     local endTransparency = effectParams.EndTransparency or 1
  25.     local shockwaveType = effectParams.ShockWaveType or "Shockwave8Side"
  26.    
  27.    
  28.     local possibleRotations = {-90, 90, -180, 180}
  29.     local randomRotationEnd = possibleRotations[math.random(#possibleRotations)]
  30.    
  31.     local shockwave = effects[shockwaveType]:Clone()
  32.     shockwave.Transparency = startTransparency
  33.     shockwave.CFrame = CFrame.new(position + Vector3.new(0, startSize.Y/2, 0))
  34.     shockwave.Size = startSize
  35.     shockwave.Parent = workspace.Ignore
  36.    
  37.     local waveTweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
  38.    
  39.  
  40.    
  41.     local waveTween = TweenService:Create(shockwave, waveTweenInfo, {
  42.         Size = endSize,
  43.         CFrame = CFrame.new(position + Vector3.new(0, endSize.Y/2, 0)) * CFrame.Angles(0, math.rad(randomRotationEnd), 0)
  44.     }):Play()
  45.    
  46.     local transparencyTweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  47.    
  48.     local transparencyTween = TweenService:Create(shockwave, transparencyTweenInfo, {
  49.         Transparency = endTransparency
  50.     }):Play()
  51.    
  52.     Debris:AddItem(shockwave, duration)
  53. end
  54.  
  55. function EffectsManager.LocationSound(audioName, position, maxDistance, volume)
  56.     local soundAttachment = Instance.new("Attachment")
  57.     soundAttachment.WorldPosition = position
  58.     soundAttachment.Parent = workspace.Baseplate
  59.    
  60.     local sound = sounds[audioName]:Clone()
  61.     sound.Volume = volume
  62.     sound.MaxDistance = maxDistance or sound.MaxDistance
  63.     sound.Parent = soundAttachment
  64.    
  65.     soundAttachment:Destroy()
  66. end
  67.  
  68. function EffectsManager.VisualizeWaypoints(waypoints, lifespan)
  69.     for i = 1, #waypoints do
  70.         local waypoint = waypoints[i]
  71.         local waypointPart = effects.Waypoint:Clone()
  72.         waypointPart.BrickColor = (i == 1 and BrickColor.Green()) or (i == #waypoints and BrickColor.Red()) or BrickColor.new("White")
  73.         waypointPart.Position = waypoint.Position
  74.         waypointPart.Parent = workspace.Ignore
  75.         Debris:AddItem(waypointPart, lifespan)
  76.     end
  77. end
  78.  
  79. function EffectsManager.Hitmarker(part, number, duration)
  80.     local hitmarker = effects.HitMarker:Clone()
  81.     hitmarker.TextLabel.Text = tostring(math.floor(number)) .. "!"
  82.     hitmarker.Adornee = part
  83.     hitmarker.Parent = game.Players.LocalPlayer.PlayerGui
  84.    
  85.     local hitmarkerTweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Exponential, Enum.EasingDirection.In)
  86.     local hitmarkerTweenInfo2 = TweenInfo.new(duration, Enum.EasingStyle.Exponential, Enum.EasingDirection.In)
  87.    
  88.     TweenService:Create(hitmarker, hitmarkerTweenInfo, {
  89.         SizeOffset = Vector2.new(0, 3.5)
  90.     }):Play()
  91.    
  92.     TweenService:Create(hitmarker.TextLabel, hitmarkerTweenInfo2, {
  93.         TextTransparency = 1,
  94.         TextStrokeTransparency = 1
  95.     }):Play()
  96.    
  97.     Debris:AddItem(hitmarker, duration)
  98. end
  99.  
  100. function EffectsManager.CastEffectToAll(...)
  101.     effectEvent:FireAllClients(...)
  102. end
  103.  
  104. if isClient then
  105.     effectEvent.OnClientEvent:Connect(function(effectName, ...)
  106.         EffectsManager[effectName](...)
  107.     end)
  108. end
  109.  
  110. return EffectsManager
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement