EnemyWave.java
01 package generator;
02 
03 import org.lwjgl.util.vector.Vector2f;
04 
05 import rtype.BonusFactory;
06 import rtype.Prototyp;
07 import rtype.entity.Bonus;
08 import rtype.entity.LadyBird;
09 
10 public class EnemyWave extends IGenerator {
11 
12   float tickAccumulator = 0;
13   float delayAccumualor = 0;
14   static final Vector2f defaultLadySpeed = new Vector2f(-76.3f,0);
15   
16   // Where the entity will be generated
17   
18   private int x;
19 
20   // Rate at which generating entities.
21   public static float rate = 2f;
22   
23   private int generatedUnitCounter = 1;
24   
25   private int maxUnitGenerated = 5;
26   
27   public EnemyWave(int x,float delay)
28   {
29     super(delay);
30     this.x = x;
31   }
32   
33   public void generateEntities() 
34   {  
35     tickAccumulator += Prototyp.tick;
36     if (tickAccumulator > rate)
37     {
38       tickAccumulator = 0;
39       LadyBird lady = new LadyBird();
40       
41       if (generatedUnitCounter == maxUnitGenerated )
42       {
43         lady.setPresetBonus(BonusFactory.createBonus(Prototyp.random.nextInt(Bonus.BONUS_COUNT)));
44       }
45       lady.spawn(new Vector2f(Prototyp.SCREEN_WIDTH/2+10,x), defaultLadySpeed, Prototyp.enemies);
46       
47       generatedUnitCounter++;
48     }
49     
50     if (generatedUnitCounter > maxUnitGenerated)
51       this.done=true;
52   }
53 
54 }