Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 2 sprint 3 #207

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1ce6676
added health bar
WW7796332 Sep 22, 2022
cdd0262
Delete health bar_1.png.jpg
WW7796332 Sep 22, 2022
54cb66b
Delete health bar_2.png.jpg
WW7796332 Sep 22, 2022
76d237a
Delete health bar_3.png.jpg
WW7796332 Sep 22, 2022
9c05673
Delete health bar_4.png.jpg
WW7796332 Sep 22, 2022
e895c06
Delete health bar_5.png.jpg
WW7796332 Sep 22, 2022
1accb64
added health bar
WW7796332 Sep 22, 2022
ee9d079
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
WW7796332 Sep 22, 2022
c3a9a9d
added loading bar
WW7796332 Sep 22, 2022
3d52a3a
add init tutorial screen, tutorial actions and tutorial display. Scre…
alyshaziya Sep 26, 2022
3ff602d
Moved dialogue box from TutorialDisplay to TutorialScreen
Sep 27, 2022
2fa16d2
Added skeleton game area for tutorial
Sep 27, 2022
cdaeb78
Added generic constructor
Sep 27, 2022
297a848
Remove unused dialogue box
Sep 27, 2022
365058c
dialogue box show now sets appropriately
Sep 27, 2022
f8ce585
got it working but dialogue doesnt show up :(
alyshaziya Sep 27, 2022
a73b811
removed custom dialogue box display constructor
Sep 27, 2022
a79df2e
Add dialogue box to tutorial game area
Sep 27, 2022
625c95a
Added HealthBarComponent to entities in the game. HealthBar distingui…
hugh5 Sep 27, 2022
107c68d
Merge remote-tracking branch 'origin/team-2-sprint-3' into team-2-spr…
hugh5 Sep 27, 2022
53052d7
Health bar can be set to visible using debug command. Weather events …
hugh5 Sep 28, 2022
96d7d31
fixed imports
hugh5 Sep 28, 2022
d1942e3
Merge branch 'team5-tutorial' into team-2-sprint-3
hugh5 Sep 28, 2022
a57ca98
Loading screen and loading bar displays after tutorial
hugh5 Oct 1, 2022
99cec8b
Added building health bar to info box display
hugh5 Oct 2, 2022
c799cf0
Added all orientations for beach and waves tiles, plus all frames for…
Oct 2, 2022
268ceb6
combine the frames into a large image for each animation
nicococole Oct 2, 2022
48f6823
adding two type figures of grass and one figure of rain
nicococole Oct 2, 2022
96b2d83
Snowy animation completed and scaled to full screen size
Spooey Oct 3, 2022
50b1142
Health Bar uses game time instead of system time
hugh5 Oct 3, 2022
62fe2e2
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Spooey Oct 3, 2022
0a1bade
Added usefule function to health bar and created unit tests
hugh5 Oct 3, 2022
f63b3ef
Added individual waves frame
Oct 3, 2022
544a5f9
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Spooey Oct 3, 2022
e599bf0
Added animations for rain
Spooey Oct 3, 2022
7ef3a08
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Oct 3, 2022
3c7db2e
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Spooey Oct 3, 2022
241f766
adding animitions of grass and rain
nicococole Oct 3, 2022
df72ea2
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
nicococole Oct 3, 2022
d29af24
Added images for snowfall effect
Oct 3, 2022
25556a4
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Oct 3, 2022
3f1b49e
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Spooey Oct 3, 2022
ac63be5
Changed ocean tiles
Spooey Oct 3, 2022
9c642fc
Added aniamations for stormy weather
Spooey Oct 3, 2022
392cc53
adding thunder and snow
nicococole Oct 3, 2022
dd75645
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
nicococole Oct 3, 2022
cbe6212
Updated images for ocean tiles
Oct 3, 2022
5e12698
Fixed rain animations scaling issue and slowed down the ocean animati…
Spooey Oct 3, 2022
7ebe73d
merge conflict for atlantis factory
Spooey Oct 3, 2022
2f73fe5
Added updated ocean tiles, better orientation
Oct 3, 2022
a1cedd2
adding snow and thunder
nicococole Oct 3, 2022
528ea20
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
nicococole Oct 3, 2022
2abcd65
adding figure of weather change to wiki'
nicococole Oct 3, 2022
cebe1e7
adding grass figure to wiki
nicococole Oct 3, 2022
af88a86
adding figure to weather change file
nicococole Oct 3, 2022
4da17ae
adding figure to wiki
nicococole Oct 3, 2022
bf5826b
Added images for sand to grass tiles
Oct 3, 2022
2885919
Chaned snow animation position
Spooey Oct 3, 2022
6629fe5
Merge branch 'team-2-sprint-3' of https://github.com/UQdeco2800/2022-…
Spooey Oct 3, 2022
141a3c3
merge conflicts
hugh5 Oct 4, 2022
efad884
loading screen loads new assets
hugh5 Oct 4, 2022
fc71150
fixed failing unit test
hugh5 Oct 4, 2022
bcf35e9
Merge branch 'main' into team-2-sprint-3
hugh5 Oct 4, 2022
1761ebf
imports
hugh5 Oct 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/wiki/Beach tile/Beach_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Beach tile/Beach_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Beach tile/Beach_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Beach tile/Beach_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Grass/grass1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Grass/grass1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Grass/grass2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Grass/grass2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Waves tile/Corner_waves_top_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Waves tile/Waves_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Waves tile/Waves_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Waves tile/Waves_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/Waves tile/Waves_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/weather_change/Rain.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wiki/weather_change/Rain.png
Binary file added assets/wiki/weather_change/snow.gif
Binary file added assets/wiki/weather_change/snow.png
Binary file added assets/wiki/weather_change/thunder.gif
Binary file added assets/wiki/weather_change/thunder.png
Binary file added source/core/assets/images/Rain.png
Binary file added source/core/assets/images/Waves tile/wave_1.png
Binary file added source/core/assets/images/Waves tile/wave_2.png
Binary file added source/core/assets/images/Waves tile/wave_3.png
Binary file added source/core/assets/images/Waves tile/wave_4.png
Binary file added source/core/assets/images/Waves tile/wave_5.png
Binary file added source/core/assets/images/Waves tile/wave_6.png
Binary file added source/core/assets/images/Waves tile/wave_7.png
Binary file modified source/core/assets/images/barracks_level_1.1.png
Binary file modified source/core/assets/images/barracks_level_1.1_highlight.png
Binary file modified source/core/assets/images/barracks_level_1.2.png
Binary file modified source/core/assets/images/barracks_level_1.2_highlight.png
Binary file added source/core/assets/images/grass1.png
Binary file added source/core/assets/images/grass2.png
Binary file added source/core/assets/images/health bar_1.png
Binary file added source/core/assets/images/health bar_2.png
Binary file added source/core/assets/images/health bar_3.png
Binary file added source/core/assets/images/health bar_4.png
Binary file added source/core/assets/images/health bar_5.png
Binary file added source/core/assets/images/health bar_6.png
Binary file added source/core/assets/images/loading bar_1.png
Binary file added source/core/assets/images/loading bar_2.png
Binary file added source/core/assets/images/loading bar_3.png
Binary file added source/core/assets/images/loading bar_4.png
Binary file added source/core/assets/images/loading bar_5.png
Binary file added source/core/assets/images/snow.png
Binary file added source/core/assets/images/thunder.png
Binary file added source/core/assets/images/weather-filter/Rain.png
19 changes: 19 additions & 0 deletions source/core/assets/images/weather-filter/rain_effect.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rainEffects.png
size: 200, 100
format: RGBA8888
filter: Linear,Linear
repeat: none
rain_first
rotate: false
xy: 0, 0
size: 1000, 1000
orig: 1000, 1000
offset: 0, 0
index: 0
rain_first
rotate: false
xy: 100, 0
size: 1000, 1000
orig: 1000, 1000
offset: 0, 0
index: 1
Binary file added source/core/assets/images/weather-filter/snow.png
11 changes: 6 additions & 5 deletions source/core/src/main/com/deco2800/game/GdxGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.deco2800.game.files.UserSettings;
import com.deco2800.game.screens.MainGameScreen;
import com.deco2800.game.screens.MainMenuScreen;
import com.deco2800.game.screens.StoryScreen;
import com.deco2800.game.screens.SettingsScreen;
import com.deco2800.game.screens.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -76,14 +73,18 @@ private Screen newScreen(ScreenType screenType) {
return new MainGameScreen(this);
case SETTINGS:
return new SettingsScreen(this);
case TUTORIAL:
return new TutorialScreen(this);
case LOADING:
return new LoadingScreen(this);

default:
return null;
}
}

public enum ScreenType {
MAIN_MENU, MAIN_GAME, SETTINGS, GAME_STORY;
MAIN_MENU, MAIN_GAME, SETTINGS, GAME_STORY, TUTORIAL, LOADING;
}

/**
Expand Down
55 changes: 25 additions & 30 deletions source/core/src/main/com/deco2800/game/areas/AtlantisGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import com.deco2800.game.areas.MapGenerator.Buildings.Building;
import com.deco2800.game.areas.MapGenerator.Buildings.BuildingGenerator;
import com.deco2800.game.areas.MapGenerator.Buildings.CityRow;
import com.deco2800.game.areas.MapGenerator.pathBuilding.PathGenerator;
import com.deco2800.game.areas.MapGenerator.Coordinate;
import com.deco2800.game.areas.MapGenerator.MapGenerator;
import com.deco2800.game.areas.MapGenerator.ResourceSpecification;
import com.deco2800.game.areas.terrain.AtlantisTerrainFactory;
import com.deco2800.game.areas.terrain.MinimapComponent;
import com.deco2800.game.components.UnitSpawningComponent;
import com.deco2800.game.areas.terrain.TerrainTile;
import com.deco2800.game.components.building.BuildingActions;
import com.deco2800.game.components.building.TextureScaler;
import com.deco2800.game.components.friendlyunits.GestureDisplay;
Expand All @@ -30,8 +30,6 @@
import com.deco2800.game.components.maingame.DialogueBoxDisplay;
import com.deco2800.game.components.maingame.Explosion;
import com.deco2800.game.components.maingame.InfoBoxDisplay;
import com.deco2800.game.areas.terrain.MinimapComponent;
import com.deco2800.game.areas.terrain.TerrainTile;
import com.deco2800.game.entities.Entity;
import com.deco2800.game.entities.UnitType;
import com.deco2800.game.entities.factories.BuildingFactory;
Expand All @@ -43,23 +41,17 @@
import com.deco2800.game.entities.factories.*;
import com.deco2800.game.input.CameraInputComponent;
import com.deco2800.game.map.MapComponent;
import com.deco2800.game.rendering.TextureRenderComponent;
import com.deco2800.game.services.ResourceService;
import com.deco2800.game.services.ServiceLocator;
import com.deco2800.game.components.gamearea.GameAreaDisplay;
import com.deco2800.game.physics.components.ColliderComponent;
import com.deco2800.game.services.ResourceService;
import com.deco2800.game.services.ServiceLocator;
import com.deco2800.game.worker.WorkerBaseFactory;
import com.deco2800.game.worker.resources.MiningCampFactory;
import com.deco2800.game.worker.resources.StoneFactory;
import com.deco2800.game.worker.resources.TreeFactory;
import com.deco2800.game.worker.type.BuilderFactory;
import com.deco2800.game.worker.type.ForagerFactory;
import com.deco2800.game.worker.type.MinerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Text;

import java.lang.annotation.Target;
import java.util.List;
Expand All @@ -74,28 +66,32 @@ public class AtlantisGameArea extends GameArea {
private static final Logger logger = LoggerFactory.getLogger(ForestGameArea.class);
private static final int NUM_TREES = 5;
private static final int NUM_STONE = 10;
private static final String[] forestTextures = {
public static final String[] forestTextures = {
"test/files/dummyTexture.png",
"test/files/dummyOcean.png",
"images/Ocean.png",
"images/Sand.png",
"images/Grass.png",
"images/city_tile.png",
"images/box_boy_leaf.png",
"images/box_boy.png",
"images/Base_Highlight.png",
"images/box_boy_highlight.png",
// "images/box_boy_leaf.png",
// "images/box_boy.png",
// "images/Base_Highlight.png",
// "images/box_boy_highlight.png",
"images/tree.png",
"images/iso_grass_1.png",
"images/ghost_king.png",
"images/ghost_1.png",
// "images/ghost_king.png",
// "images/ghost_1.png",
"images/grass_1.png",
"images/grass_2.png",
"images/grass_3.png",
"images/sea_1.png",
"images/sea_2.png",
"images/sea_3.png",
"images/sea_4.png",
"images/Waves tile/wave_1.png",
"images/Waves tile/wave_2.png",
"images/Waves tile/wave_3.png",
"images/Waves tile/wave_4.png",
"images/hex_grass_1.png",
"images/hex_grass_2.png",
"images/hex_grass_3.png",
Expand All @@ -110,6 +106,7 @@ public class AtlantisGameArea extends GameArea {
/* Building assets */
// TownHall
"images/base.png",
"images/level 1 town hall.png",
// Barracks
"images/barracks_level_1.0.png",
"images/barracks_level_1.0_Highlight.png",
Expand Down Expand Up @@ -140,6 +137,7 @@ public class AtlantisGameArea extends GameArea {
"images/stone_wall_2_.png",
"images/stone_wall_3.png",
"images/Base_Highlight",
"images/level_1_town_hall_Highlight.png",
"images/stone.png",
"images/archer.png",
"images/swordsman.png",
Expand All @@ -160,25 +158,25 @@ public class AtlantisGameArea extends GameArea {
"images/pathTile.png",
"images/spellbox-zeus.png",
"images/spell-btn-unclickable.png",
"images/spell-btn.png"

"images/spell-btn.png",
"images/health bar_6.png",
};

/* TODO: remove unused textures wasting precious resources */
private static final String[] uiTextures = {
public static final String[] uiTextures = {
"images/dialogue_box_pattern2_background.png",
"images/dialogue_box_image_default.png",
"images/exit-button.PNG",
"images/dialogue_box_background_Deep_Sea.png"
};

private final String[] buildingPlacementTextures = {
public static final String[] buildingPlacementTextures = {
"images/barracks_highlight_red.png",
"images/barracks_highlight_green.png",
"images/wooden_wall_green.png",
"images/wooden_wall_red.png"
};
private static final String[] forestTextureAtlases = {
public static final String[] forestTextureAtlases = {
"images/terrain_iso_grass.atlas", "images/ghost.atlas", "images/ghostKing.atlas",
"images/forager.atlas", "images/miner.atlas", "images/builder.atlas",
"images/duration-bar.atlas", "images/archer.atlas", "images/swordsman.atlas",
Expand All @@ -188,7 +186,7 @@ public class AtlantisGameArea extends GameArea {
"images/newwolf.atlas", "images/forager.atlas","images/tree_.atlas",
"images/spell.atlas", "images/titanshrine.atlas", "images/ship2.atlas"
};
private static final String[] atlantisSounds = {"sounds/Impact4.ogg"};
public static final String[] atlantisSounds = {"sounds/Impact4.ogg"};

Music music = Gdx.audio.newMusic(Gdx.files.internal("sounds/in-game-v3.wav"));

Expand Down Expand Up @@ -220,7 +218,7 @@ public void create() {
gameAreaEventHandle.addListener("spawnTitan", this::spawnTitan);
gameAreaEventHandle.addListener("spawnBlueJoker", this::spawnBlueJokers);

loadAssets();
// loadAssets();
displayUI();
spawnTerrain();

Expand All @@ -235,7 +233,7 @@ public void create() {
spawnMiner();

//playMusic();
player = spawnPlayer();
// player = spawnPlayer();
centreCameraOnCity();

// Spawn Buildings in the city
Expand Down Expand Up @@ -362,12 +360,9 @@ private void displayUI() {
spawnEntity(gestureDisplay);

Entity dialogueBox = new Entity();
/* FIXME: temporary infobox width value */
this.dialogueBoxDisplay = new DialogueBoxDisplay(537f);
dialogueBoxDisplay.setDialogue("This is example dialogue text");
dialogueBoxDisplay.setTitle("example title");
dialogueBox.addComponent(dialogueBoxDisplay);
dialogueBox.addComponent(new DialogueBoxActions(dialogueBoxDisplay));
this.dialogueBoxDisplay = new DialogueBoxDisplay();
dialogueBox.addComponent(this.dialogueBoxDisplay);
dialogueBox.addComponent(new DialogueBoxActions(this.dialogueBoxDisplay));

//spawnEntity(dialogueBox);
}
Expand Down
67 changes: 67 additions & 0 deletions source/core/src/main/com/deco2800/game/areas/TutorialGameArea.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.deco2800.game.areas;

import com.deco2800.game.components.maingame.DialogueBoxActions;
import com.deco2800.game.components.maingame.DialogueBoxDisplay;
import com.deco2800.game.entities.Entity;
import com.deco2800.game.services.ResourceService;
import com.deco2800.game.services.ServiceLocator;

public class TutorialGameArea extends GameArea {

/** dialogue box */
private DialogueBoxDisplay dialogueBoxDisplay;

/** textures needed to load */
private String[] tutorialTextures = {
"images/dialogue_box_pattern2_background.png",
"images/dialogue_box_image_default.png",
"images/exit-button.PNG",
"images/dialogue_box_background_Deep_Sea.png"
};

/**
* On init load needed textures
*/
private void loadAssets() {

ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.loadTextures(this.tutorialTextures);
resourceService.loadAll();
}

/**
* On exit clean-up loaded textures
*/
private void unloadAssets() {

ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.unloadAssets(this.tutorialTextures);
}

/**
* Create and spawn entities to this area
*/
private void displayUI() {

Entity dialogueBox = new Entity();
this.dialogueBoxDisplay = new DialogueBoxDisplay();
dialogueBox.addComponent(this.dialogueBoxDisplay)
.addComponent(new DialogueBoxActions(this.dialogueBoxDisplay));

spawnEntity(dialogueBox);
}

@Override
public void create() {

this.loadAssets();
this.displayUI();
}

@Override
public void dispose() {

super.dispose();
this.unloadAssets();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ private void fillTiles(TiledMapTileLayer layer) {
oceanFrames.add(new StaticTiledMapTile(textures.get("Sea2")));
oceanFrames.add(new StaticTiledMapTile(textures.get("Sea3")));
oceanFrames.add(new StaticTiledMapTile(textures.get("Sea4")));
AnimatedTiledMapTile animatedOceanTile = new AnimatedTiledMapTile(1/3f, oceanFrames);
AnimatedTiledMapTile animatedOceanTile = new AnimatedTiledMapTile(1f/2f, oceanFrames);


//Set id for each tile - used for visualising minimap
cityTile.setId(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefe

public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed, int range) {
setTroops(troops);
setHealth(health);
setMaxHealth(health);
setHealth(health);
setBaseAttack(baseAttack);
setBaseDefence(baseDefence);
setLandSpeed(landSpeed);
Expand Down Expand Up @@ -142,6 +142,9 @@ public int getMaxHealth() {
public void setHealth(int health) {
if (health >= 0) {
this.health = health;
if (health > maxHealth) {
this.health = maxHealth;
}
} else {
this.health = 0;
}
Expand All @@ -151,12 +154,14 @@ public void setHealth(int health) {
}

/**
* Sets the entity's maximum health. Health has a minimum bound of 0.
*
* @param maxHealth maximum health
* Sets the entity's maximum health. Maximum Health must be greater than or equal to 0.
* @param maxHealth Maximum health an entity can have
*/
public void setMaxHealth(int maxHealth) {
this.maxHealth = maxHealth;
if (this.maxHealth < 0) {
this.maxHealth = 0;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.deco2800.game.components;

public enum EntityType {
FRIENDLY,
ENEMY,
BUILDING
}
Loading