diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index 422057ab1..d2074a66e 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -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); } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java index e6a83c610..0c5494c04 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java @@ -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"; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java similarity index 99% rename from source/core/src/main/com/csse3200/game/components/tasks/EngineerCombatTask.java rename to source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index 40e91edea..1487fa714 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -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; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/HumanWanderTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/HumanWanderTask.java index be2c570f7..a9b497130 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/HumanWanderTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/HumanWanderTask.java @@ -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; diff --git a/source/core/src/test/com/csse3200/game/components/player/HumanAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/player/HumanAnimationControllerTest.java index bf104bfbb..99019845a 100644 --- a/source/core/src/test/com/csse3200/game/components/player/HumanAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/player/HumanAnimationControllerTest.java @@ -1,15 +1,63 @@ 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 @@ -17,34 +65,51 @@ 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'"); +// } } \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java index 7be8641f4..3d80accb0 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java @@ -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",