Time for action – power-ups
Add the following declarations to the
WeaponManager
module:Private _powerUps As List(Of Sprite)= New List(Of Sprite) Private _maxActivePowerups As Integer = 5 Private _timeSinceLastPowerup As Single = 0.0 Private _timeBetweenPowerups As Single = 2.0 Private _rand As Random = new Random()
Add the
tryToSpawnPowerup()
method to the Weapons Management Methods region of theWeaponManager
module:Private Sub tryToSpawnPowerup( x As Integer, y As Integer, type As WeaponType) If _powerUps.Count >= _maxActivePowerups Then Return End If Dim thisDestination As Rectangle = TileMap.SquareWorldRectangle(New Vector2(x,y)) For Each powerUp as Sprite in _powerUps If powerup.WorldRectangle = thisDestination Then Return End If Next If Not TileMap.IsWallTile(x,y) Then Dim newPowerup As Sprite = New Sprite( New Vector2(thisDestination.X, thisDestination.Y), Texture...