Skip to content

Commit

Permalink
Merge pull request #123 from UQcsse3200/Team-2--Engineers
Browse files Browse the repository at this point in the history
Team 2  engineers - Fixed mob ball bug
  • Loading branch information
The-AhmadAA authored Sep 9, 2023
2 parents 402476c + 786bae7 commit 7835e08
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,5 @@ private void spawnEngineer() {
Entity engineer = EngineerFactory.createEngineer();
spawnEntityAt(engineer, new GridPoint2(1, i), true, true);
}
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = new GridPoint2(5, terrain.getMapBounds(0).sub(2, 2).y);
// GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
//
// Entity engineer = EngineerFactory.createEngineer();
// spawnEntityAt(engineer, randomPos, true, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class MobAttackTask extends DefaultTask implements PriorityTask {
private static final int INTERVAL = 1; // time interval to scan for towers in
private static final short TARGET = PhysicsLayer.OBSTACLE; // mobs detecting for towers
private static final short TARGET = PhysicsLayer.HUMANS; // mobs detecting for towers
// ^ fix this

private static final String STOW = "stowStart";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.csse3200.game.components.tasks;
package com.csse3200.game.components.tasks.human;

import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.ai.tasks.DefaultTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.ai.tasks.Task;
import com.csse3200.game.components.CombatStatsComponent;
import com.csse3200.game.components.tasks.EngineerCombatTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.physics.components.ColliderComponent;
import com.csse3200.game.physics.components.HitboxComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,115 @@
package com.csse3200.game.components.player;

import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.EngineerFactory;
import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.physics.PhysicsService;
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.rendering.DebugRenderer;
import com.csse3200.game.rendering.RenderService;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

@ExtendWith(GameExtension.class)
class HumanAnimationControllerTest {
private final String[] atlas = {"images/engineers/engineer.atlas"};
private static final String[] sounds = {
"sounds/engineers/firing_auto.mp3",
"sounds/engineers/firing_single.mp3"
};

private final String[] animations = {
"idle_right",
"walk_left",
"walk_right",
"walk_prep",
"prep",
"firing_auto",
"firing_single",
"hit",
"death"
};

private Entity engineer;

@Mock
GameTime gameTime;

@BeforeEach
void setUp() {
gameTime = mock(GameTime.class);
ServiceLocator.registerTimeSource(gameTime);
ServiceLocator.registerPhysicsService(new PhysicsService());
RenderService render = new RenderService();
render.setDebug(mock(DebugRenderer.class));
ServiceLocator.registerRenderService(render);
ResourceService resourceService = new ResourceService();
ServiceLocator.registerResourceService(resourceService);
resourceService.loadTextureAtlases(atlas);
resourceService.loadSounds(sounds);
resourceService.loadAll();
engineer = EngineerFactory.createEngineer();
}

@AfterEach
void tearDown() {
}

@Test
void create() {
}

@Test
void animateIdleLeft() {
}

@Test
void animateIdleRight() {
}

@Test
void animateLeftWalk() {
void shouldHaveAnimationController() {
assertNotNull(engineer.getComponent(HumanAnimationController.class),
"Created Engineer entity should have a HumanAnimationController");
}

@Test
void animateRightWalk() {
}

@Test
void animateFiring() {
}

@Test
void animateHit() {
}

@Test
void animateDeath() {
}
// @Test
// void shouldAnimateIdleRight() {
// engineer.getEvents().trigger("idleStart");
// when(gameTime.getDeltaTime()).thenReturn(0.1f);
// assertEquals("idle_right", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'idleStart' event should trigger 'idle_right' animation'");
// }
//
// @Test
// void animateLeftWalk() {
// engineer.getEvents().trigger("walkLeftStart");
// assertEquals("walk_left", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'walkLeftStart' event should trigger 'walk_left' animation'");
// }
//
// @Test
// void animateRightWalk() {
// engineer.getEvents().trigger("walkRightStart");
// assertEquals("walk_right", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'walkRightStart' event should trigger 'walk_right' animation'");
// }
//
// @Test
// void animateFiring() {
// engineer.getEvents().trigger("firingSingleStart");
// assertEquals("firing_single", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'firingSingleStart' event should trigger 'firing_single' animation'");
// }
//
// @Test
// void animateHit() {
// engineer.getEvents().trigger("hitStart");
// assertEquals("hit", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'hitStart' event should trigger 'hit' animation'");
// }
//
// @Test
// void animateDeath() {
// engineer.getEvents().trigger("hitStart");
// assertEquals("death", engineer.getComponent(AnimationRenderComponent.class).getCurrentAnimation(),
// "'deathStart' event should trigger 'death' animation'");
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
@ExtendWith(GameExtension.class)
class EngineerFactoryTest {

private String[] atlas = {"images/engineers/engineer.atlas"};
private final String[] atlas = {"images/engineers/engineer.atlas"};
private static final String[] sounds = {
"sounds/engineers/firing_auto.mp3",
"sounds/engineers/firing_single.mp3"
};

private String[] animations = {
private final String[] animations = {
"idle_right",
"walk_left",
"walk_right",
Expand Down

0 comments on commit 7835e08

Please sign in to comment.