Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandmcneilly committed Oct 2, 2023
2 parents e4fab8b + 4288607 commit 12b8b43
Show file tree
Hide file tree
Showing 37 changed files with 595 additions and 93 deletions.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.csse3200.game.ai.tasks;

import com.csse3200.game.components.Component;
import com.csse3200.game.components.ComponentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -35,6 +36,24 @@ public AITaskComponent addTask(PriorityTask task) {
return this;
}

/**
* Get a task from the list of tasks. This can be used to get a reference to
* a task to modify it. This is inspired from Entity.getComponent().
*
* @param task The task to get
* @return A reference to a task with the given class
* @param <T> The type of task to get
*/
public <T extends PriorityTask> T getTask(Class<T> task) {
for (PriorityTask priorityTask : priorityTasks) {
if (priorityTask.getClass() == task) {
return (T) priorityTask;
}
}
logger.info("Task {} not found", task);
return null;
}

/**
* On update, run the current highest priority task. If it's a different one, stop the old one and
* start the new one. If the highest priority task has negative priority, no task will be run.
Expand Down
13 changes: 11 additions & 2 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class ForestGameArea extends GameArea {
"images/mobs/Hurt.png",
"images/mobs/Idle.png",
"images/mobs/rangeBossRight.png",
"images/towers/WallTower.png",
"images/towers/wall_tower.png",
"images/background/building2.png",
"images/iso_grass_3.png",
"images/terrain_use.png",
Expand Down Expand Up @@ -276,13 +276,22 @@ public void create() {
// spawnTNTTower();
// spawnIncome();
spawnIncome();
playMusic();
spawnXenoGrunts();
startWaveTimer();
spawnScrap();
spawnDeflectXenoGrunt(15, 5);
spawnSplittingXenoGrunt(15, 4);
spawnScrap();
spawnTNTTower();
spawnWeaponTower();
spawnGapScanners();
spawnDroidTower();

}

private void displayUI() {
Entity ui = new Entity();
ui.addComponent(new GameAreaDisplay("Box Forest"));
ui.addComponent(ServiceLocator.getGameEndService().getDisplay());
ui.addComponent(ServiceLocator.getCurrencyService().getDisplay());
spawnEntity(ui);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void create() {
for (int i = 0; i < 2; i++) {
// Use "building1" for the first tower and "building2" for the second tower
skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("building1", new Texture("images/towers/WallTower.png"));
skin.add("building1", new Texture("images/towers/wall_tower.png"));
// Load textures for building1 and building2
towers1[i] = new Image(skin, "building1");
towers1[i].setBounds(Gdx.graphics.getWidth() * 40f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
Expand Down Expand Up @@ -131,7 +131,7 @@ public void touchUp(InputEvent event, float x, float y, int pointer, int button)
for (int i = 0; i < 2; i++) {
// Use "building1" for the first tower and "building2" for the second tower
skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("building2", new Texture("images/towers/WallTower.png"));
skin.add("building2", new Texture("images/towers/wall_tower.png"));
towers2[i] = new Image(skin, "building2");
towers2[i].setBounds(Gdx.graphics.getWidth() * 50f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
stage.addActor(towers2[i]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.csse3200.game.components.npc;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import com.csse3200.game.components.player.HumanAnimationController;
import com.csse3200.game.components.tower.TowerUpgraderComponent;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.EntityService;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.input.EngineerInputComponent;
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EngineerMenuComponent extends UIComponent {
private Logger logger = LoggerFactory.getLogger(EngineerMenuComponent.class);
Table table;

@Override
public void create() {
super.create();
}

@Override
public void draw(SpriteBatch batch) {
// draw is handled by the stage
}

/**
* Creates a menu for the engineer
* @param x cursor x coordinate
* @param y cursor y coordinate
* @param camera camera of the game
*/
public void createMenu(float x, float y, Camera camera) {
this.table = createTable(x, y, camera);

// add buttons
TextButton moveButton = createButton("Move");
TextButton repairButton = createButton("Repair");

// add listeners to buttons
AnimationRenderComponent animator = getEntity().getComponent(AnimationRenderComponent.class);
HumanAnimationController controller = getEntity().getComponent(HumanAnimationController.class);
EngineerInputComponent input = ServiceLocator.getInputService().getEngineerInput();

moveButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
input.setMoveClicked(true);
controller.deselectEngineer(animator.getCurrentAnimation());

//logger.info("Move button clicked");
}
});

repairButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
controller.deselectEngineer(animator.getCurrentAnimation());
EntityService entityService = ServiceLocator.getEntityService();
Array<Entity> tower = entityService.getEntitiesInLayer(getEntity(), 0.1f, PhysicsLayer.TOWER);
if (tower.size == 0) {
logger.info("No tower to repair");
return;
}
logger.info("repairing");
tower.get(0).getComponent(TowerUpgraderComponent.class).repairTower();
//logger.info("Repair button clicked");
}
});

table.add(moveButton).grow();
table.row();
table.add(repairButton).grow();
table.row();
stage.addActor(table);

}

/**
* Creates a table for the menu
* @param x cursor x coordinate
* @param y cursor y coordinate
* @param camera camera of the game
* @return table for the menu
*/
private Table createTable(float x, float y, Camera camera) {
Table table = new Table();
table.top();
table.defaults().pad(0).space(0);
table.setSize(90, 60); // fixed table size

// convert cursor position to stage coordinates
Vector3 entityCoordinates = new Vector3(x, y, 0);
Vector3 entityScreenCoordinate = camera.project(entityCoordinates);
Vector2 stageCoordinates = stage.screenToStageCoordinates(
new Vector2(entityScreenCoordinate.x, entityScreenCoordinate.y));
stage.getViewport().unproject(stageCoordinates);
table.setPosition(stageCoordinates.x, stageCoordinates.y);

// set table background
String imageFilePath = "images/ui/Sprites/UI_Glass_Frame_Standard_01a.png";
Drawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(imageFilePath)));
table.setBackground(drawable);

return table;
}

/**
* Creates a button for the menu
* @param text text to be displayed on the button
* @return the button
*/
private TextButton createButton(String text) {
String upImageFilePath = "images/ui/Sprites/UI_Glass_Button_Medium_Lock_01a2.png";
String downImageFilePath = "images/ui/Sprites/UI_Glass_Button_Medium_Press_01a2.png";

Drawable upDrawable = new TextureRegionDrawable(new TextureRegion(new Texture(upImageFilePath)));
Drawable downDrawable = new TextureRegionDrawable(new TextureRegion(new Texture(downImageFilePath)));
TextButton button = new TextButton(text,
new TextButton.TextButtonStyle(upDrawable, downDrawable, null, new BitmapFont()));

button.setTransform(true);
return button;
}

/**
* Removes the menu from the stage
*/
public void removeMenu() {
table.clear();
table.remove();
}

}
Loading

0 comments on commit 12b8b43

Please sign in to comment.