Time for action – the enemy manager
Add a new module called
EnemyManager
to the Robot Rampage project.Add declarations to the
EnemyManager
module:#Region "Declarations" Public Enemies As List(Of Enemy) = new List(Of Enemy)() Private _texture As Texture2D Private _initialFrame As Rectangle Public MaxActiveEnemies As Integer = 30 #End Region
Add the
Initialize()
method to theEnemyManager
module:#Region "Initialization" Public Sub Initialize( texture As Texture2D, initialFrame As Rectangle) _texture = texture _initialFrame = initialFrame End Sub #End Region
Add the
AddEnemy()
method to theEnemyManager
module:#region "Enemy Management" Public Sub AddEnemy(squareLocation As Vector2) Dim startX As Integer = CInt(Int(squareLocation.X)) Dim startY As Integer = CInt(Int(squareLocation.Y)) Dim squareRect As Rectangle = TileMap.SquareWorldRectangle(startX, startY) Dim newEnemy As Enemy = New Enemy( New Vector2(squareRect.X, squareRect.Y), ...