Skip to content

Commit

Permalink
Added files StunTowerCombatTask, StunTowerAnimationController, stun_t…
Browse files Browse the repository at this point in the history
…ower.png, stun_tower.atlas and finished the base functionality for createStunTower method in TowerFactory.
  • Loading branch information
shiv-0831 committed Sep 7, 2023
1 parent e46afce commit 4bbef11
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 91 deletions.
118 changes: 118 additions & 0 deletions source/core/assets/images/towers/stun_tower.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

stun_tower.png
size: 1024, 64
format: RGBA8888
filter: Nearest, Nearest
repeat: none
attack
rotate: false
xy: 2, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 4
attack
rotate: false
xy: 136, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 9
attack
rotate: false
xy: 203, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 1
attack
rotate: false
xy: 270, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 6
attack
rotate: false
xy: 404, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 3
attack
rotate: false
xy: 538, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 8
attack
rotate: false
xy: 672, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 0
attack
rotate: false
xy: 739, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 5
attack
rotate: false
xy: 873, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 2
attack
rotate: false
xy: 940, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 7
idle
rotate: false
xy: 69, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 1
idle
rotate: false
xy: 337, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 3
idle
rotate: false
xy: 471, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 0
idle
rotate: false
xy: 605, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 5
idle
rotate: false
xy: 605, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 4
idle
rotate: false
xy: 806, 2
size: 65, 45
orig: 65, 45
offset: 0, 0
index: 2
Binary file added source/core/assets/images/towers/stun_tower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 91 additions & 87 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class ForestGameArea extends GameArea {
"images/towers/turret01.png",
"images/towers/turret_deployed.png",
"images/towers/fire_tower_atlas.png",
"images/towers/stun_tower.png",
"images/background/building2.png",
"images/mobs/robot.png",
"images/mobs/Attack_1.png",
Expand All @@ -94,6 +95,7 @@ public class ForestGameArea extends GameArea {
"images/towers/turret.atlas",
"images/towers/turret01.atlas",
"images/towers/fire_tower_atlas.atlas",
"images/towers/stun_tower.atlas",
"images/mobs/xenoGruntRunning.atlas",
"images/mobs/robot.atlas",
"images/mobs/rangeBossRight.atlas"
Expand Down Expand Up @@ -136,26 +138,26 @@ public void create() {
displayUI();

spawnTerrain();
spawnBuilding1();
spawnBuilding2();
spawnMountains();
// spawnBuilding1();
// spawnBuilding2();
// spawnMountains();
player = spawnPlayer();

playMusic();

// Types of projectile
spawnAoeProjectile(new Vector2(0, 10), player, towardsMobs, new Vector2(2f, 2f), 1);
spawnProjectile(new Vector2(0, 10), player, towardsMobs, new Vector2(2f, 2f));
spawnMultiProjectile(new Vector2(0, 10), player, towardsMobs, 20, new Vector2(2f, 2f), 7);
// spawnMultiProjectile(new Vector2(0, 10), player, towardsMobs, 20, new Vector2(2f, 2f), 7);
spawnXenoGrunts();

spawnGhosts();
spawnWeaponTower();
spawnIncome();
spawnScrap();
// spawnScrap();

bossKing1 = spawnBossKing1();
bossKing2 = spawnBossKing2();
// bossKing2 = spawnBossKing2();

playMusic();
}
Expand Down Expand Up @@ -196,40 +198,40 @@ private void spawnTerrain() {
spawnEntityAt(
ObstacleFactory.createWall(worldBounds.x, WALL_WIDTH), GridPoint2Utils.ZERO, false, false);
}
private void spawnBuilding1() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);

for (int i = 0; i < NUM_BUILDINGS; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity building1 = ObstacleFactory.createBuilding1();
spawnEntityAt(building1, randomPos, true, false);
}
}
private void spawnBuilding2() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);

for (int i = 0; i < NUM_BUILDINGS; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity building2 = ObstacleFactory.createBuilding2();
spawnEntityAt(building2, randomPos, true, false);
}
}

private void spawnMountains() {
ArrayList<GridPoint2> fixedPositions = new ArrayList<>(); //Generating ArrayList

fixedPositions.add(new GridPoint2(5, 8));
fixedPositions.add(new GridPoint2(12, 4));
fixedPositions.add(new GridPoint2(20, 10));
fixedPositions.add(new GridPoint2(33, 17));

for (GridPoint2 fixedPos : fixedPositions) {
Entity tree = ObstacleFactory.createMountain();
spawnEntityAt(tree, fixedPos, true, false);
}
}
// private void spawnBuilding1() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
//
// for (int i = 0; i < NUM_BUILDINGS; i++) {
// GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
// Entity building1 = ObstacleFactory.createBuilding1();
// spawnEntityAt(building1, randomPos, true, false);
// }
// }
// private void spawnBuilding2() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
//
// for (int i = 0; i < NUM_BUILDINGS; i++) {
// GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
// Entity building2 = ObstacleFactory.createBuilding2();
// spawnEntityAt(building2, randomPos, true, false);
// }
// }

// private void spawnMountains() {
// ArrayList<GridPoint2> fixedPositions = new ArrayList<>(); //Generating ArrayList
//
// fixedPositions.add(new GridPoint2(5, 8));
// fixedPositions.add(new GridPoint2(12, 4));
// fixedPositions.add(new GridPoint2(20, 10));
// fixedPositions.add(new GridPoint2(33, 17));
//
// for (GridPoint2 fixedPos : fixedPositions) {
// Entity tree = ObstacleFactory.createMountain();
// spawnEntityAt(tree, fixedPos, true, false);
// }
// }

private Entity spawnPlayer() {
Entity newPlayer = PlayerFactory.createPlayer();
Expand Down Expand Up @@ -324,34 +326,34 @@ private void spawnXenoGrunts() {
}
}

private Entity spawnGhostKing() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(0, 0);
GridPoint2 randomPos
= RandomUtils.random(minPos, maxPos);
// = new GridPoint2(26, 26);
Entity ghostKing = NPCFactory.createGhostKing(player);
spawnEntityAt(ghostKing, randomPos, true, true);
return ghostKing;

}

private Entity spawnBossKing2() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);

for (int i = 0; i < NUM_BOSS; i++) {
int fixedX = terrain.getMapBounds(0).x - 1; // Rightmost x-coordinate
int randomY = MathUtils.random(0, maxPos.y);
GridPoint2 randomPos = new GridPoint2(fixedX, randomY);
bossKing2 = BossKingFactory.createBossKing2(player);
spawnEntityAt(bossKing2,
randomPos,
true,
false);
}
return bossKing2;
}
// private Entity spawnGhostKing() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(0, 0);
// GridPoint2 randomPos
// = RandomUtils.random(minPos, maxPos);
// // = new GridPoint2(26, 26);
// Entity ghostKing = NPCFactory.createGhostKing(player);
// spawnEntityAt(ghostKing, randomPos, true, true);
// return ghostKing;
//
// }

// private Entity spawnBossKing2() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
//
// for (int i = 0; i < NUM_BOSS; i++) {
// int fixedX = terrain.getMapBounds(0).x - 1; // Rightmost x-coordinate
// int randomY = MathUtils.random(0, maxPos.y);
// GridPoint2 randomPos = new GridPoint2(fixedX, randomY);
// bossKing2 = BossKingFactory.createBossKing2(player);
// spawnEntityAt(bossKing2,
// randomPos,
// true,
// false);
// }
// return bossKing2;
// }

/**
* Creates multiple projectiles that travel simultaneous. They all have same
Expand All @@ -364,13 +366,13 @@ private Entity spawnBossKing2() {
* @param speed The speed of the projectiles.
* @param quantity The amount of projectiles to spawn.
*/
private void spawnMultiProjectile(Vector2 position, Entity target, int direction, int space, Vector2 speed, int quantity) {
int half = quantity / 2;
for (int i = 0; i < quantity; i++) {
spawnProjectile(position, target, space * half, direction, speed);
--half;
}
}
// private void spawnMultiProjectile(Vector2 position, Entity target, int direction, int space, Vector2 speed, int quantity) {
// int half = quantity / 2;
// for (int i = 0; i < quantity; i++) {
// spawnProjectile(position, target, space * half, direction, speed);
// --half;
// }
// }

/**
* Returns projectile that can do an area of effect damage
Expand All @@ -393,11 +395,13 @@ private void spawnWeaponTower() {

for (int i = 0; i < NUM_WEAPON_TOWERS; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity weaponTower = TowerFactory.createWeaponTower();
//Entity weaponTower = TowerFactory.createWeaponTower();
Entity wallTower = TowerFactory.createWallTower();
Entity fireTower = TowerFactory.createFireTower();
spawnEntityAt(weaponTower, randomPos, true, true);
Entity stunTower = TowerFactory.createStunTower();
//spawnEntityAt(weaponTower, randomPos, true, true);
spawnEntityAt(fireTower, randomPos, true, true);
spawnEntityAt(stunTower, randomPos, true, true);
spawnEntityAt(wallTower, new GridPoint2(randomPos.x + 3, randomPos.y), true, true);
}
}
Expand Down Expand Up @@ -440,16 +444,16 @@ public void dispose() {
this.unloadAssets();
}

private void spawnScrap() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);

for (int i = 0; i < 50; i++) {
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
Entity scrap = DropFactory.createScrapDrop();
spawnEntityAt(scrap, randomPos, true, false);
}
}
// private void spawnScrap() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
//
// for (int i = 0; i < 50; i++) {
// GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
// Entity scrap = DropFactory.createScrapDrop();
// spawnEntityAt(scrap, randomPos, true, false);
// }
// }

private void spawnIncome() {
GridPoint2 minPos = new GridPoint2(0, 0);
Expand Down
Loading

0 comments on commit 4bbef11

Please sign in to comment.