Skip to content

Commit

Permalink
Merge branch 'main' into Team-1-Mobs-Enhancement-variations
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniSoda17 committed Oct 11, 2023
2 parents 286a953 + 9ee068a commit 639b93c
Show file tree
Hide file tree
Showing 22 changed files with 658 additions and 229 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/javadoc_publish.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: Publish Javadoc to web
# name: Publish Javadoc to web

on:
push:
# Sequence of patterns matched against refs/heads
branches:
# Push events on main branch
- main
# on:
# push:
# # Sequence of patterns matched against refs/heads
# branches:
# # Push events on main branch
# - main

jobs:
build_and_publish_jdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3 # Checkout repo to remote machine
- name: Set up OpenJDK17
uses: actions/setup-java@v1
with:
java-version: '17'
# jobs:
# build_and_publish_jdoc:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3 # Checkout repo to remote machine
# - name: Set up OpenJDK17
# uses: actions/setup-java@v1
# with:
# java-version: '17'

- name: Build Javadoc
run: |
cd $GRADLE_DIR
chmod +x ./gradlew
./gradlew javadoc
env:
GRADLE_DIR: 'source' # Modify this to wherever './gradlew' is
# - name: Build Javadoc
# run: |
# cd $GRADLE_DIR
# chmod +x ./gradlew
# ./gradlew javadoc
# env:
# GRADLE_DIR: 'source' # Modify this to wherever './gradlew' is

- name: Deploy docs to GH Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: source/core/build/docs/javadoc/ # The folder the action should deploy.
# - name: Deploy docs to GH Pages
# uses: JamesIves/[email protected]
# with:
# branch: gh-pages # The branch the action should deploy to.
# folder: source/core/build/docs/javadoc/ # The folder the action should deploy.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# UQ 2023 Studio 3
# UQ 2023 Studio 3

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,22 @@ private void addActors() {

// Fetch the selected tower types if set
Array<TowerType> towers = new Array<>();

for (TowerType tower : ServiceLocator.getTowerTypes()) {
towers.add(tower);
}

// If no towers set, populate with default towers
if (towers.isEmpty()) {
towers.addAll(defaultTowers);
if (towers.isEmpty() || towers.size < 5) {
if (towers.isEmpty()) {
towers.addAll(defaultTowers);
} else {
for (TowerType tower : defaultTowers) {
if (towers.size < 5 && !towers.contains(tower, false)) {
towers.add(tower);
}
}
}
}

TextButton tower1 = new TextButton(towers.get(0).getTowerName(), skin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ public void changeInterval(int newInterval) {
public void setInterval(int interval) {
this.interval = interval;
}

public int getInterval() {
return interval;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public LevelWaves(int spawnDelay) {

long currentTime = ServiceLocator.getTimeSource().getTime();
// Setting the timestamp for when the next mobs will spawn.
// Currently, the delay of mobs spawning after wave start
// is hardcoded but will fix in the next push.
ServiceLocator.getWaveService().setNextWaveTime(currentTime + 10000);
// Currently, the delay of mobs spawning after wave start.
ServiceLocator.getWaveService().setNextWaveTime(currentTime + (spawnDelay * 1000));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public WaveClass(HashMap<String, int[]> entities) {
* Get the entities that are part of this wave and randomise the order they are spawned
* @return mobs for the wave in form of (mob name, mob health)
*/
private List<Tuple> entitiesToWave() {

public List<Tuple> entitiesToWave() {
List<Tuple> enemies = new ArrayList<>();
for (Map.Entry<String, int[]> set : entities.entrySet()) {
for (int i = 0; i < set.getValue()[0]; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class WaveTask extends DefaultTask implements PriorityTask {
private LevelWaves level;
private WaveClass currentWave;
private final GameTime globalTime;
private long nextWaveAt = 0;
private int currentWaveIndex = 0;
private boolean waveInProgress;
private float startTime = 0;
Expand Down Expand Up @@ -93,13 +94,13 @@ public void start() {
@Override
public void update() {
if (ServiceLocator.getWaveService().getEnemyCount() == 0) {
currentWaveIndex++;
// currentWaveIndex++;

long currentTime = ServiceLocator.getTimeSource().getTime();
// Setting the timestamp for when the next mobs will spawn.
// Currently, the delay of mobs spawning after wave start
// is hardcoded but will fix in the next push.
ServiceLocator.getWaveService().setNextWaveTime(currentTime + 10000);
int spawnDelay = ServiceLocator.getWaveService().getSpawnDelay();
ServiceLocator.getWaveService().setNextWaveTime(currentTime + (spawnDelay * 1000));

// Check if level has been completed - no more waves remaining
if (currentWaveIndex == this.level.getNumWaves()) {
Expand All @@ -108,22 +109,35 @@ public void update() {

} else {
// Spawn the next wave
logger.info("No enemies remaining, begin next wave");
this.waveEnd.play();
this.waveInProgress = true;
this.level.setWaveIndex(currentWaveIndex);
// Set the service wave count to the current wave index.
ServiceLocator.getWaveService().setWaveCount(currentWaveIndex);
this.currentWave = this.level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
//endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time
// logger.info("No enemies remaining, begin next wave");
if (nextWaveAt == 0) {
logger.info("Next wave in 10 seconds");
nextWaveAt = globalTime.getTime() + 10000;
ServiceLocator.getWaveService().setNextWaveTime(nextWaveAt);
} else {
if (globalTime.getTime() >= nextWaveAt || ServiceLocator.getWaveService().shouldSkip()) {
logger.info("Next wave starting");
ServiceLocator.getWaveService().toggleDelay();
currentWaveIndex++;
ServiceLocator.getWaveService().setNextWaveTime(0);
nextWaveAt = 0;
this.waveEnd.play();
this.waveInProgress = true;
this.level.setWaveIndex(currentWaveIndex);
// Set the service wave count to the current wave index.
ServiceLocator.getWaveService().setWaveCount(currentWaveIndex);
this.currentWave = this.level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
//endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time
}
}
}

} else {
// logger.info("{} enemies remaining in wave {}", ServiceLocator.getWaveService().getEnemyCount(), currentWaveIndex);
// logger.info("WAVE SERVICE NUMBER: Wave Number {}",ServiceLocator.getWaveService().getWaveCount());
// logger.info("NEXT WAVE AT {}", ServiceLocator.getWaveService().getNextWaveTime());
// logger.info("TIME IS {}", ServiceLocator.getTimeSource().getTime());
//logger.info("{} enemies remaining in wave {}", ServiceLocator.getWaveService().getEnemyCount(), currentWaveIndex);
//logger.info("WAVE SERVICE NUMBER: Wave Number {}",ServiceLocator.getWaveService().getWaveCount());
//logger.info("NEXT WAVE AT {}", ServiceLocator.getWaveService().getNextWaveTime());
//logger.info("TIME IS {}", ServiceLocator.getTimeSource().getTime());
if (waveInProgress) {
this.level.spawnWave();
}
Expand All @@ -137,4 +151,12 @@ public void update() {
public boolean isWaveInProgress() {
return waveInProgress;
}

/**
* Gets the current wave index
* @return current wave index
*/
public int getCurrentWaveIndex() {
return currentWaveIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public void dispose() {
}
}

/**
* Find an entity by its ID, if it exists return true, else return false
* @param id id of entity to find
* @return boolean true if entity exists, false if not
*/
public boolean findEntityExistence(int id) {
for (Entity entity : entities) {
if (entity.getId() == id) {
return true;
}
}
return false;
}

/**
* Get all entities
*/
Expand Down Expand Up @@ -174,6 +188,24 @@ public Entity getEntityAtPosition(float x, float y) {
return null;
}

/**
* Checks for the presence of an Entity at a specified position (x, y).
*
* @param x The x-coordinate of the position to check.
* @param y The y-coordinate of the position to check.
* @return The Entity found at the specified position, or null if no Entity is present.
*/
public Entity checkEntityAtPosition(int x, int y) {
entities.sort(Comparator.comparingInt(Entity::getLayer));
for (Entity entity : entities) {
if (entity.getPosition().x == x && entity.getPosition().y == y) {
return entity;
}
}
return null;
}


private boolean entityContainsPosition(Entity entity, float x, float y) {
float entityX = entity.getPosition().x;
float entityY = entity.getPosition().y;
Expand All @@ -198,7 +230,7 @@ public boolean entitiesInTile(int x_coord, int y_coord) {
return true;
}
if (mp.getCell(x_coord, y_coord) != null) {
Entity entity = getEntityAtPosition(x_coord, y_coord);
Entity entity = checkEntityAtPosition(x_coord, y_coord);
return entity != null;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.csse3200.game.components.tasks.waves.WaveTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.screens.GameLevelData;
import com.csse3200.game.services.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -97,10 +98,16 @@ public static LevelWaves createLevel(int maxDiff, int maxWaves, int chosenLevel)
String boss1 = "IceBoss";
// String boss1 = "PatrickBoss";
String boss2 = "PatrickBoss";
// String boss3 = "IceBoss";
//TODO change this to a fire boss in sprint 4
String boss3 = "FireBoss";
LevelWaves level = new LevelWaves(5);
//String boss3 = "IceBoss";

String boss3 = "FireBoss";

int spawnDelay = 5;

// Create new level entity with spawn delay of 5 seconds
LevelWaves level = new LevelWaves(spawnDelay);
// Tell the waveService what the spawn delay for levels will be (for UI team).
ServiceLocator.getWaveService().setSpawnDelay(spawnDelay);

ArrayList<String> possibleMobs;

Expand Down
Loading

0 comments on commit 639b93c

Please sign in to comment.