-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/Team4/integrate-enemies' of https://github.com/…
…UQcsse3200/2023-studio-3 into feature/Team4/integrate-enemies
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.csse3200.game.components.tasks; | ||
|
||
import com.badlogic.gdx.math.Vector2; | ||
import com.csse3200.game.ai.tasks.DefaultTask; | ||
import com.csse3200.game.ai.tasks.PriorityTask; | ||
import com.csse3200.game.ai.tasks.Task; | ||
import com.csse3200.game.services.GameTime; | ||
import com.csse3200.game.services.ServiceLocator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class SpawnWaveTask extends DefaultTask implements PriorityTask { | ||
private static final Logger logger = LoggerFactory.getLogger(SpawnWaveTask.class); | ||
private final GameTime globalTime; | ||
private long endTime; | ||
|
||
private final int SPAWNING_INTERVAL = 10; | ||
|
||
public SpawnWaveTask() { | ||
this.globalTime = ServiceLocator.getTimeSource(); | ||
} | ||
|
||
@Override | ||
public int getPriority() { | ||
return 10; // Low priority task | ||
} | ||
|
||
@Override | ||
public void start() { | ||
super.start(); | ||
endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000); | ||
} | ||
|
||
@Override | ||
public void update() { | ||
if (globalTime.getTime() >= endTime) { | ||
this.owner.getEntity().getEvents().trigger("spawnWave"); | ||
endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters