Heya There!!
I’m working on a wave system for my game and I’m wondering how would I go by on keeping track on how many enemies are present in the wave. In GameHandler
, there is a dictionary that contains many of the enemy settings/stats with one of them being Amount.
On WaveHandler
, there is a function that, as of now, simply prints the setting/stats of the dictionary it was given. However, I’d want the function to increase CurrentEnemies using the Amount value inside of the dictionaries.
GameHandler
--[[SERVICES]]--
local Players = game:GetService("Players")
--[[MODULE REQUIRINGS]]--
local WaveHandler = require(script:WaitForChild("WaveHandler"))
--[[GAMEPLAY]]--
--//Wave List & Current Wave
local CurrentWave = 1
local WaveList = {
[1] = {
["Brickbattler"] = {
Amount = 15,
"Melee",
StartingCompetence = 1
}
},
[2] = {
["Brickbattler"] = {
Amount = 35,
"Melee",
StartingCompetence = 1
},
["Ranger"] = {
Amount = 20,
"Range",
StartingCompetence = 1
}
},
}
--//Gameplay Loop
--//Preperation Time
--//Wave & Intermission between rounds.
task.wait(5)
CurrentWave = 2
WaveHandler:StartNewWave(WaveList,CurrentWave)
WaveHandler
--[[SERVICES]]--
local ServerScriptService = game:GetService("ServerScriptService")
local Players = game:GetService("Players")
--[[BASE VARIABLES]]--
local BaseIntermissionTime = 25
local BaseWaveTime = 25
local CurrentEnemies = 0
--[[MODULE]]--
local WaveModule = {}
function WaveModule:Intermission()
local PlayerCount = #Players:GetPlayers()
--//Checking to see if they're is more than one player.
if PlayerCount > 1 then
--//If there are multiple players, add 5 seconds onto the timer.
print("More than one player detected, increasing timer!!")
for _, Player in pairs(Players:GetPlayers()) do
BaseIntermissionTime += #Players:GetPlayers() * 5
end
print("Timer increased by: "..BaseIntermissionTime..". Take your time and make it count.")
elseif PlayerCount == 1 then
--//If there is only one player, continue.
print("Solo run!! Continue.")
end
repeat
BaseIntermissionTime -= 1
task.wait(1)
until BaseIntermissionTime <= 0
end
function WaveModule:StartNewWave(WaveList, CurrentWave)
for EntityName, EntitySettings in WaveList[CurrentWave] do
print(EntityName)
for Setting, Value in pairs(EntitySettings) do
print(Value)
end
end
end
return WaveModule