Skip to content

Commit

Permalink
Merge branch 'team-2-ui' into Mohamad_Juice
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad11Dab committed Oct 16, 2023
2 parents f7e239f + dac4854 commit d22f925
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private void addActors() {
table.add(scrapsTb).width(scrapsTb.getWidth() * 0.5f).height(scrapsTb.getHeight() * 0.5f);
table.add(crystalsTb).width(crystalsTb.getWidth() * 0.5f).height(crystalsTb.getHeight() * 0.5f);
stage.addActor(table);

scrapsTb.addAction(new SequenceAction(Actions.fadeIn(4f)));
crystalsTb.addAction(new SequenceAction(Actions.fadeIn(8f)));
}

private TextButton createButton(String imageFilePath, int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private void addActors() {

table.add(engineerTb).width(engineerTb.getWidth() * 0.5f).height(engineerTb.getHeight() * 0.5f);
stage.addActor(table);

engineerTb.addAction(new SequenceAction(Actions.fadeIn(4f)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import com.badlogic.gdx.Input;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
Expand Down Expand Up @@ -86,6 +89,8 @@ private void addActors() {
towerTable.top().padTop(50f);
towerTable.setFillParent(true);

towerTable.setDebug(true);

// Contains other buttons (just pause at this stage)
buttonTable.top().right().padTop(50f).padRight(80f);
buttonTable.setFillParent(true);
Expand Down Expand Up @@ -141,14 +146,19 @@ private void addActors() {

TextButton pauseBtn = ButtonFactory.createButton("Pause");

// Starting animation for pause button
pauseBtn.setPosition(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 150);
pauseBtn.addAction(new SequenceAction(Actions.moveTo(Gdx.graphics.getWidth() - 200,
Gdx.graphics.getHeight() - 150, 1f, Interpolation.fastSlow)));

// Spawns a pause menu when the button is pressed.
pauseBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Pause button clicked");
openSound.play(0.4f);
PauseMenuFactory.createPauseMenu(game);
pauseMenu = PauseMenuFactory.createPauseMenu(game);
ServiceLocator.getTimeSource().setPaused(true);
}
});
Expand Down Expand Up @@ -325,6 +335,18 @@ public void clicked(InputEvent event, float x, float y) {
stage.addActor(towerTable);
stage.addActor(levelNameTable);

// Animate the tower select buttons
int tower1Gap = Gdx.graphics.getWidth() /2 + (int) towerTable.getX()/2 + 400;
int tower2Gap = Gdx.graphics.getWidth() /2 + (int) towerTable.getX()/2 + 240;
int tower3Gap = Gdx.graphics.getWidth() /2 + (int) towerTable.getX()/2 + 80;
int tower4Gap = Gdx.graphics.getWidth() /2 + (int) towerTable.getX()/2 - 80;
int tower5Gap = Gdx.graphics.getWidth() /2 + (int) towerTable.getX()/2 - 240;
animateTowerButton(tower1, tower1Gap, 230);
animateTowerButton(tower2, tower2Gap, 230);
animateTowerButton(tower3, tower3Gap, 230);
animateTowerButton(tower4, tower4Gap, 230);
animateTowerButton(tower5, tower5Gap, 230);

TooltipManager tm = TooltipManager.getInstance();
tm.initialTime = 3;
tm.hideAll();
Expand Down Expand Up @@ -415,4 +437,10 @@ public void loadSounds() {
public void unloadSounds() {
ServiceLocator.getResourceService().unloadAssets(sounds);
}
}

public void animateTowerButton(ImageButton button, float x, float y) {
button.setPosition(Gdx.graphics.getWidth() - x, Gdx.graphics.getHeight());
button.addAction(new SequenceAction(Actions.moveTo(Gdx.graphics.getWidth() - x,
Gdx.graphics.getHeight() - y, 1f, Interpolation.fastSlow)));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package com.csse3200.game.components.maingame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
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;

import javax.swing.event.ChangeEvent;
import java.security.Provider;


/**
* Displays a button to represent the remaining mobs left in the current wave and a button to skip to the next wave.
Expand All @@ -36,13 +42,17 @@ private void addActors() {

remainingMobsButton = ButtonFactory.createButton("Mobs:"
+ ServiceLocator.getWaveService().getEnemyCount());
buttonTable.top().right().padTop(130f).padRight(80f);

remainingMobsButton.setPosition(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 230);
remainingMobsButton.addAction(new SequenceAction(Actions.moveTo(Gdx.graphics.getWidth() - 218,
Gdx.graphics.getHeight() - 230, 1f, Interpolation.fastSlow)));

buttonTable.top().right().padTop(130f).padRight(80f);
buttonTable.setFillParent(true);

buttonTable.add(remainingMobsButton).right();//.padTop(10f).padRight(10f);
buttonTable.add(remainingMobsButton).right();
buttonTable.row();
buttonTable.add(timerButton);//.padRight(10f);
buttonTable.add(timerButton);

stage.addActor(buttonTable);

Expand All @@ -54,17 +64,26 @@ private void addActors() {
*/
public void updateMobCount() {
remainingMobsButton.setText("Mobs:" + ServiceLocator.getWaveService().getEnemyCount());
remainingMobsButton.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
ServiceLocator.getWaveService().toggleDelay();
}
}
);
}

/**
* This method creates the timer button.
*/
public void createTimerButton() {

// timerButton = new ButtonFactory().createButton("Next wave in:"
// + (ServiceLocator.getWaveService().getNextWaveTime() / 1000));
timerButton = ButtonFactory.createButton("Next wave in:"
+ (ServiceLocator.getWaveService().getNextWaveTime() / 1000));
timerButton.setPosition(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 300);
timerButton.addAction(new SequenceAction(Actions.moveTo(Gdx.graphics.getWidth() - 445,
Gdx.graphics.getHeight() - 300, 1f, Interpolation.fastSlow)));
buttonTable.row();
buttonTable.add(timerButton).padRight(10f);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.csse3200.game.components.npc;

import com.csse3200.game.components.Component;
import com.csse3200.game.components.tasks.mobtask.MobType;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.NPCFactory;
import com.csse3200.game.services.ServiceLocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,7 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
}
});

// window.addListener(
// new InputListener() {
//
// @Override
// public boolean keyUp (InputEvent event, int keycode) {
// if (keycode == Input.Keys.ESCAPE && ServiceLocator.getTimeSource().getPaused()) {
// logger.debug("Closing pause menu with escape key");
// click.play(0.5f);
// closeSound.play(0.5f);
// ServiceLocator.getTimeSource().setPaused(false);
// entity.dispose();
// return true;
// }
// return false;
// }
// }
// );

// window.setKeepWithinStage(true);
window.setResizable(true);
window.setModal(true);
window.setTouchable(Touchable.enabled);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.csse3200.game.components.tasks;

import com.csse3200.game.components.tasks.mobtask.MobTask;
import com.csse3200.game.components.tasks.mobtask.MobType;
import com.csse3200.game.components.tasks.MobTask.MobTask;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.csse3200.game.components.tasks.mobtask;
package com.csse3200.game.components.tasks.MobTask;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Timer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.csse3200.game.components.tasks.mobtask;
package com.csse3200.game.components.tasks.MobTask;

public enum MobType {
SKELETON(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import com.csse3200.game.components.tasks.MobMeleeAttackTask;
import com.csse3200.game.components.tasks.MobRangedAttackTask;
import com.csse3200.game.components.tasks.MobWanderTask;
import com.csse3200.game.components.tasks.mobtask.MobTask;
import com.csse3200.game.components.tasks.mobtask.MobType;
import com.csse3200.game.components.tasks.MobTask.MobTask;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.Melee;
import com.csse3200.game.entities.PredefinedWeapons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import com.csse3200.game.components.npc.DodgingComponent;
import com.csse3200.game.components.tasks.MobDodgeTask;
import com.csse3200.game.components.tasks.MobWanderTask;
import com.csse3200.game.components.tasks.mobtask.MobTask;
import com.csse3200.game.components.tasks.mobtask.MobType;
import com.csse3200.game.components.tasks.MobTask.MobTask;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.EntityService;
import com.csse3200.game.entities.factories.NPCFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.components.npc.SplitMoblings;
import com.csse3200.game.components.tasks.mobtask.MobType;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.EntityService;
import com.csse3200.game.entities.factories.NPCFactory;
Expand Down

0 comments on commit d22f925

Please sign in to comment.