Skip to content

Commit

Permalink
Warning signal effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
praneetdhoolia committed Oct 16, 2023
1 parent 54b3df8 commit be41a1d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,6 @@ private void spawnGapScanners() {

private void flashWarning(String mobType, GridPoint2 position) {
Entity warning = WarningFactory.createWarning(mobType, position);
spawnEntity(warning);
spawnEntityAt(warning, position, true, true);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.csse3200.game.components;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Interpolation;
Expand All @@ -9,13 +11,17 @@
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WarningComponent extends UIComponent {
long startTime = ServiceLocator.getTimeSource().getTime();
private static final Logger logger = LoggerFactory.getLogger(WarningComponent.class);
TextButton warning;
long spawnTime;
Expand All @@ -29,17 +35,23 @@ public void create() {
addActors();
}
public void addActors() {
warning = new TextButton("ENEMY", getSkin());
warning.pad(20f);
warning.addAction(new SequenceAction(
Actions.color(new Color(Color.RED)),
Actions.parallel(Actions.fadeOut(2f), Actions.sizeBy(1000, 0, 2f)),
Actions.removeActor()));
warning.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
logger.info(String.format("%d, %d", position.x, position.y));

stage.addActor(warning);
}

public void config(String mobType, GridPoint2 position) {
this.position = position;
this.spawnTime = ServiceLocator.getTimeSource().getTime();
this.severity = mobType.contains("Boss") ? 5f : 1.5f;
}
@Override
public void update() {
}
@Override
public void dispose() {
this.warning.clear();
super.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public class WarningTask extends DefaultTask implements PriorityTask {
@Override
public void start() {
super.start();
logger.info("WarningFlashTask started.");
logger.info("WarningTask started.");
startTime = ServiceLocator.getTimeSource().getTime();
}

@Override
public void update() {
owner.getEntity().getComponent(WarningComponent.class).update();
if (ServiceLocator.getTimeSource().getTime() > startTime + 2000) {
stop();
if (ServiceLocator.getTimeSource().getTime() > startTime + 5000) {
owner.getEntity().dispose();
}
}

Expand Down

0 comments on commit be41a1d

Please sign in to comment.