Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("timers")
- if TowerWarsGameRound == nil then
- TowerWarsGameRound = class({})
- end
- ListenToGameEvent("entity_killed", Dynamic_Wrap(TowerWarsGameRound, "OnEntityKilled"), self)
- --[[
- TowerWarsGameRound - A single round of Tower Wars fichier TowerWarsGameRound.lua ne pas oublier le require
- ]]
- function TowerWarsGameRound:ReadConfiguration( kv, gameMode, roundNumber )
- print(kv)
- print("quest title",kv.round_quest_title)
- print("titre:",kv.round_title)
- print("maxunit",kv.round_maxUnit)
- self._gameMode = gameMode
- self._nRoundNumber = roundNumber
- self._szRoundQuestTitle = kv.round_quest_title
- self._szRoundTitle = kv.round_title
- self._maxUnit = tonumber(kv.round_maxUnit) or 9001
- --[[ Tableaux nécéssaire car le round contient plusieurs vagues]]
- self._npc = {}
- self._numberToSpawn = {}
- self._nextWaveIn = {}
- --[[Tableaux des loots du round ainsi que chance de drop de la vague]]
- self._dropRate = kv.DropRate
- self._loots = {}
- for k, v in pairs( kv ) do
- print(k)
- if type(v) == "table" and k == "ItemDrops" then -- si la valeur est une table et que c'est la table des loots k vaut exactement "ItemDrops" ici
- print("le parseur marche-t-il?")
- for _,loot in pairs (v) do -- on itere dans la table des loots
- self._loots[loot.ItemName] = loot.Chance
- end
- elseif type( v ) == "table" then--Si la valeur est une table et que c'est pas la table des loots, c'est que c'est la config des sous vagues, k vaudra string(1),string(2) etc
- --obligé de mettre tonumber(k) sinon la clef c'est un string
- self._npc[tonumber(k)] = v.NPCName
- self._numberToSpawn[tonumber(k)] = v.TotalUnitsToSpawn
- self._nextWaveIn[tonumber(k)] = v.NextWaveIn
- print("k est un:",type(tonumber(k)))
- end
- end
- end
- -- Courtesy of ArthurAutomaton, this guy rocks!
- function TowerWarsGameRound:BeginRound()
- SPAWNLOCATION_RADIANT = "path_customspawn_radiant"
- SPAWNLOCATION_DIRE = "path_customspawn_dire"
- WAYPOINTNAME_RADIANT = "path_radiant_wp1"
- WAYPOINTNAME_DIRE = "path_dire_wp1"
- local spawnLocationRadiant = Entities:FindByName( nil, SPAWNLOCATION_RADIANT )
- local waypointlocationRadiant = Entities:FindByName ( nil, WAYPOINTNAME_RADIANT)
- local spawnLocationDire = Entities:FindByName( nil, SPAWNLOCATION_DIRE )
- local waypointlocationDire = Entities:FindByName ( nil, WAYPOINTNAME_DIRE)
- local creature
- local waveNumber = 1
- print("Spawning round number:", self._nRoundNumber)
- print("Taux de drop:", tonumber(self._dropRate))
- Timers:CreateTimer(function() -- on se sert du timer pour spawn toutes les vagues apres le delai spécifié dans le fichier de configuration
- local numberToSpawn = self._numberToSpawn[waveNumber]
- local unitToSpawn = self._npc[waveNumber]
- if numberToSpawn == nil or unitToSpawn == nil then
- print("Spawned all units for round:", self._nRoundNumber)
- return
- end
- for i = 1, numberToSpawn do -- on spawn toute la sous vague
- creature = CreateUnitByName( unitToSpawn , spawnLocationRadiant:GetAbsOrigin() + RandomVector( RandomFloat( 0, 200 ) ), true, nil, nil, DOTA_TEAM_BADGUYS )
- creature:SetInitialGoalEntity( waypointlocationRadiant )
- creature = CreateUnitByName( unitToSpawn , spawnLocationDire:GetAbsOrigin() + RandomVector( RandomFloat( 0, 200 ) ), true, nil, nil, DOTA_TEAM_GOODGUYS )
- creature:SetInitialGoalEntity( waypointlocationDire )
- print("Spawning wave number:" , waveNumber, "Creature:", unitToSpawn)
- end
- waveNumber = waveNumber + 1 -- on incremente la vague, comme ça lors du prochain appel on spawn la vague suivante
- return self._nextWaveIn[waveNumber - 1] -- -1 car sinon c'est le temps de la vague d'apres !
- end)
- end
- --[[
- function TowerWarsGameRound:ShowTimerRound(texte,duree)
- local duree = duration
- Timers:CreateTimer(function()
- if _duree == -1 then
- self.BeginRound()
- return
- end
- _duree = _duree - 1
- towerWars:_vRounds[round]:BeginRound()
- FireGameEvent("towerWars_show_generic_timer", {text = texte, countdown = _duree})
- FireGameEvent("towerWars_show_generic_timer", {text = texte, countdown = _duree})
- return 1.0
- end
- )
- end
- ]]
- function TowerWarsGameRound:BeginRoundLater(delay)
- local _duree = tonumber(delay)
- titre = "Starting Round #" .. self._nRoundNumber .. ":"
- Timers:CreateTimer(function()
- if _duree == -1 then
- FireGameEvent("towerWars_hide_timer",{})
- self:BeginRound()
- return
- end
- FireGameEvent("towerWars_show_generic_timer", {text = titre, countdown = tostring(_duree)})
- FireGameEvent("towerWars_show_generic_timer", {text = titre, countdown = tostring(_duree)})
- _duree = _duree - 1
- return 1.0
- end
- )
- end
- function TowerWarsGameRound:SetUpLoots()
- end
- function TowerWarsGameRound:OnEntityKilled(entity)
- --[[ for k,v in pairs(entity) do
- print(k,v)
- end]]
- print("mais wtf")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement