Skip to content

Commit

Permalink
fixed spawnAt bounderies
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad11Dab committed Oct 1, 2023
1 parent 1369a4e commit 50ab0d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private void spawnDeflectWizard(int x, int y) {

private void spawnFireWorm() {

int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() )

.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
Expand All @@ -540,7 +540,7 @@ private void spawnFireWorm() {

private void spawnSkeleton() {

int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() )
.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]);
Expand All @@ -552,7 +552,7 @@ private void spawnSkeleton() {

private void spawnDragonKnight() {

int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() )

.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
Expand All @@ -565,7 +565,7 @@ private void spawnDragonKnight() {

private void spawnWizard() {

int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() )

.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
Expand All @@ -578,7 +578,7 @@ private void spawnWizard() {

private void spawnWaterQueen() {

int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() )

.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
Expand All @@ -591,7 +591,7 @@ private void spawnWaterQueen() {

private void spawnWaterSlime() {

int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1)
int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() )

.distinct().limit(5).toArray();
for (int i = 0; i < NUM_GRUNTS; i++) {
Expand Down Expand Up @@ -705,7 +705,7 @@ private void spawnWeaponTower() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1);

for (int i = 0; i < NUM_WEAPON_TOWERS + 10 ; i++) {
for (int i = 0; i < NUM_WEAPON_TOWERS + 7 ; i++) {
GridPoint2 randomPos1 = RandomUtils.random(minPos, maxPos);
GridPoint2 randomPos2 = RandomUtils.random(minPos, maxPos);
Entity wallTower = TowerFactory.createWallTower();
Expand Down Expand Up @@ -734,7 +734,7 @@ private void spawnTNTTower() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1);

for (int i = 0; i < NUM_WEAPON_TOWERS + 15; i++) {
for (int i = 0; i < NUM_WEAPON_TOWERS + 5; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity weaponTower = TowerFactory.createTNTTower();
spawnEntityAt(weaponTower, randomPos, true, true);
Expand All @@ -746,7 +746,7 @@ private void spawnDroidTower() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1);

for (int i = 0; i < NUM_WEAPON_TOWERS + 15; i++) {
for (int i = 0; i < NUM_WEAPON_TOWERS + 5; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity weaponTower = TowerFactory.createDroidTower();
spawnEntityAt(weaponTower, randomPos, true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public WaveClass getWave(int index) {
public void spawnWave() {
if (gameTime.getTime() >= startTime + spawnDelay * 1000) {
do {
currentRandom = rand.nextInt(0, ServiceLocator.getMapService().getHeight() + 1);
currentRandom = rand.nextInt(0, ServiceLocator.getMapService().getHeight());
} while (currentRandom == previousRandom);
ServiceLocator.getWaveService().setNextLane(currentRandom);
GridPoint2 randomPos = new GridPoint2(19, currentRandom);
Expand Down

0 comments on commit 50ab0d7

Please sign in to comment.