public static Entity BuildEnemySprite(EnemyType type, Vector2 loc, MarioEntity mario) { Entity toReturn = null; switch (type) { case EnemyType.WalkingGoomba: toReturn = new GoombaEntity(loc); break; case EnemyType.GreenKoopa: toReturn = new GreenKoopaEntity(loc); break; case EnemyType.RedKoopa: toReturn = new RedKoopaEntity(loc); break; case EnemyType.Piranha: toReturn = new PiranhaEntity(loc); break; case EnemyType.Bowser: toReturn = new BowserEntity(loc, mario); break; } return(toReturn); }
public override void Update(GameTime gametime, Vector2 Velocity, GraphicsDeviceManager graphics) { Sprite.Update(gametime, Velocity, graphics); timer -= gametime.ElapsedGameTime.TotalSeconds; if (timer < 0) { Entity enemy; Random r = new Random(); int num = r.Next(0, 3); switch (num % 3) { case 0: enemy = new GoombaEntity(new Vector2(Sprite.Position.X - 32, Sprite.Position.Y)); break; case 1: enemy = new GreenKoopaEntity(new Vector2(Sprite.Position.X - 32, Sprite.Position.Y)); break; case 2: enemy = new RedKoopaEntity(new Vector2(Sprite.Position.X - 32, Sprite.Position.Y)) { SpriteVelocity = new Vector2(-1, 0) }; break; default: enemy = new GoombaEntity(new Vector2(Sprite.Position.X - 32, Sprite.Position.Y)); break; } enemy.SpriteVelocity = new Vector2(-1, 0); MovingEntities.Add(enemy); Tile tile = new Tile(); tile.Entity = enemy; tile.Position = enemy.SpritePosition; CollideList.Add(tile); timer = TIMER; } }