Skip to content

Commit c7cc305

Browse files
committed
Bosses and progression, LD release
1 parent 2f46c98 commit c7cc305

File tree

12 files changed

+218
-57
lines changed

12 files changed

+218
-57
lines changed

core/assets/door_closed.png

4.75 KB
Loading

core/assets/door_open.png

9.57 KB
Loading

core/assets/maps/world1/world1.tmx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</layer>
2222
<layer name="doortop" width="32" height="32">
2323
<properties>
24-
<property name="door" value="true"/>
24+
<property name="hidden" value=""/>
2525
<property name="z" value="1"/>
2626
</properties>
2727
<data encoding="base64">
@@ -31,6 +31,7 @@
3131
<layer name="doorbot" width="32" height="32">
3232
<properties>
3333
<property name="door" value="true"/>
34+
<property name="hidden" value=""/>
3435
<property name="solid" value="true"/>
3536
</properties>
3637
<data encoding="base64">
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
So that old man was really working in collaberation with those wizards all along?
2-
He is actually some crazy flying demon man?
1+
So that old man was really working in collaboration with those wizards all along?
2+
He's actually some crazy flying demon man?
33
Who could have guessed that amazing plot twist?
44
Time to put that slime slaying training to good use and slay this foul beast!

core/assets/maps/world7/world7.tmx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</layer>
2929
<layer name="npc2" width="8" height="8">
3030
<properties>
31+
<property name="finalwiz" value="true"/>
3132
<property name="npc" value="true"/>
3233
<property name="solid" value="true"/>
3334
</properties>
@@ -42,7 +43,7 @@
4243
<property name="solid" value="true"/>
4344
</properties>
4445
<data encoding="base64">
45-
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
46+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
4647
</data>
4748
</layer>
4849
<layer name="solidobs" width="8" height="8">

core/src/uk/org/ulcompsoc/tesseract/MusicManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public MusicManager(String[] files) {
3030
}
3131

3232
public void play(int index) {
33-
Gdx.app.debug("PLAY", "");
3433
if (playingIndex != -1) {
3534
loadedMusic[playingIndex].stop();
3635
}
@@ -80,7 +79,6 @@ public void update(float deltaTime) {
8079
remainingFadeTime -= deltaTime;
8180

8281
if (remainingFadeTime <= 0.0f) {
83-
Gdx.app.debug("FADE_COMPLETE", "");
8482
fadeDuration = -1.0f;
8583
remainingFadeTime = -1.0f;
8684
loadedMusic[playingIndex].setVolume(DEFAULT_VOLUME);

core/src/uk/org/ulcompsoc/tesseract/TesseractMain.java

Lines changed: 111 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
import com.badlogic.ashley.core.ComponentMapper;
4242
import com.badlogic.ashley.core.Engine;
4343
import com.badlogic.ashley.core.Entity;
44+
import com.badlogic.ashley.core.Family;
4445
import com.badlogic.ashley.signals.Listener;
4546
import com.badlogic.ashley.signals.Signal;
47+
import com.badlogic.ashley.utils.ImmutableArray;
4648
import com.badlogic.gdx.Application;
4749
import com.badlogic.gdx.ApplicationAdapter;
4850
import com.badlogic.gdx.Gdx;
@@ -92,19 +94,22 @@ public class TesseractMain extends ApplicationAdapter {
9294

9395
private Engine currentEngine = null;
9496

95-
private Engine battleEngine = null;
96-
private Engine worldSelectEngine = null;
97-
private Engine[] worldEngines = null;
97+
private static Engine battleEngine = null;
98+
private static Engine worldSelectEngine = null;
99+
private static Engine[] worldEngines = null;
98100

99101
public static Entity battlePlayerEntity = null;
100102
public static Entity worldPlayerEntity = null;
101103
public static Stats playerStats = null;
102104

103-
BattleVictoryListener battleVictoryListener = null;
105+
private BattleVictoryListener battleVictoryListener = null;
106+
private BattleDefeatListener battleDefeatListener = null;
104107

105108
private static boolean bossIncomingFlag = false;
106109
private static boolean battleChangeFlag = false;
107110
private static boolean worldChangeFlag = false;
111+
112+
private boolean healOnTransition = false;
108113
private static boolean worldSelectChangeFlag = false;
109114
private static int diffWorldFlag = -1;
110115
private float transitionTime = -1.0f;
@@ -133,11 +138,14 @@ public class TesseractMain extends ApplicationAdapter {
133138
private Texture[] bossTextures = null;
134139
private Animation[] bossAnims = null;
135140
private Stats[] bossStats = { new Stats(20, 15, 10, 3),
136-
new Stats(10, 15, 10, 5), new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5),
137-
new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5) };
141+
new Stats(100, 15, 10, 1), new Stats(150, 20, 10, 5), new Stats(150, 25, 10, 5), new Stats(150, 30, 10, 2),
142+
new Stats(150, 35, 10, 5), new Stats(100, 40, 5, 2) };
138143

139144
private Texture[] worldSelectTextures = null;
140145

146+
private Texture openDoorTex = null;
147+
private Texture closedDoorTex = null;
148+
141149
private DialogueFinishListener healNPCListener = null;
142150
private DialogueFinishListener bossBattleListener = null;
143151
private DialogueFinishListener doorOpenListener = null;
@@ -193,6 +201,8 @@ public class TesseractMain extends ApplicationAdapter {
193201
private static TesseractMap[] maps = null;
194202
public static int currentMapIndex = 0;
195203

204+
final float yTile = 12 * WorldConstants.TILE_HEIGHT;
205+
196206
@SuppressWarnings("unused")
197207
private GameState gameState = null;
198208

@@ -258,10 +268,14 @@ public void create() {
258268

259269
loadBossFiles();
260270

271+
openDoorTex = new Texture(Gdx.files.internal("door_open.png"));
272+
closedDoorTex = new Texture(Gdx.files.internal("door_closed.png"));
273+
261274
playerStats = new Stats(100, 30, 5, 70);
262275

263276
monsterTileHandler = new MonsterTileHandler();
264277
battleVictoryListener = new BattleVictoryListener();
278+
battleDefeatListener = new BattleDefeatListener();
265279

266280
healNPCListener = new DialogueFinishListener();
267281
bossBattleListener = new DialogueFinishListener();
@@ -287,10 +301,12 @@ public void render() {
287301
mapColors[currentMapIndex].a);
288302
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
289303

290-
if (Gdx.input.isKeyJustPressed(Keys.F5)) {
291-
changeToWorld((currentMapIndex + 1));
292-
} else if (Gdx.input.isKeyJustPressed(Keys.F1)) {
293-
doPlayerPowerUp();
304+
if (Gdx.app.getLogLevel() == Application.LOG_DEBUG) {
305+
if (Gdx.input.isKeyJustPressed(Keys.F5)) {
306+
changeToWorld((currentMapIndex + 1));
307+
} else if (Gdx.input.isKeyJustPressed(Keys.F1)) {
308+
doPlayerPowerUp();
309+
}
294310
}
295311

296312
if (isTransitioning()) {
@@ -302,6 +318,10 @@ public void render() {
302318

303319
if (transitionTime <= 0.0f) {
304320
transitionTime = -1.0f;
321+
if (healOnTransition) {
322+
healToFull();
323+
healOnTransition = false;
324+
}
305325

306326
if (worldChangeFlag) {
307327
changeToWorld(diffWorldFlag);
@@ -345,16 +365,22 @@ public void flagWorldReturn(boolean bossBattleJustHappened) {
345365
int bossesRemaining = 0;
346366

347367
for (TesseractMap map : maps) {
348-
if (!map.bossBeaten) {
368+
if (!map.bossBeaten && map.bossEntity != null) {
349369
bossesRemaining++;
350370
}
351371
}
352372

353-
if (bossesRemaining == 0) {
373+
Gdx.app.debug("BOSSES_REMAINING", "" + bossesRemaining + " bosses remaining.");
374+
375+
if (bossesRemaining == 1) { // 1 because of the last boss
354376
Gdx.app.debug("ALL_BOSSES", "All bosses defeated, opening final world.");
355377
Engine world1 = worldEngines[0];
356378
world1.removeEntity(maps[0].doorEntity);
357379
world1.addEntity(maps[0].openDoorEntity);
380+
} else if (bossesRemaining == 0) {
381+
finished = true;
382+
flagWorldChange(0);
383+
return;
358384
}
359385

360386
doPlayerPowerUp();
@@ -377,6 +403,15 @@ public void changeToBattle(boolean boss) {
377403
Gdx.app.debug("BATTLE_CHANGE", "Changing to battle view.");
378404

379405
this.currentEngine = battleEngine;
406+
@SuppressWarnings("unchecked")
407+
ImmutableArray<Entity> ents = currentEngine.getEntitiesFor(Family.getFor(Enemy.class));
408+
if (ents.size() > 0) {
409+
while (ents.size() > 0) {
410+
currentEngine.removeEntity(ents.get(0));
411+
}
412+
413+
makeBattlePlayerEntity(currentEngine);
414+
}
380415

381416
((OrthographicCamera) camera).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
382417
camera.update();
@@ -452,8 +487,8 @@ public void initWorldEngines(Engine[] engines) {
452487
Engine engine = new Engine();
453488

454489
maps[i] = new TesseractMap(mapLoader.load(Gdx.files.internal("maps/" + mapNames[i]).path()), batch,
455-
(i == mapNames.length - 1 ? null : torchAnims[i]), healNPCListener, bossBattleListener,
456-
doorOpenListener);
490+
(i == mapNames.length - 1 ? null : torchAnims[i]), new TextureRegion(openDoorTex),
491+
new TextureRegion(closedDoorTex), healNPCListener, bossBattleListener, doorOpenListener);
457492

458493
engine.addEntity(maps[i].baseLayerEntity);
459494

@@ -475,6 +510,10 @@ public void initWorldEngines(Engine[] engines) {
475510
engine.addEntity(maps[i].bossEntity);
476511
}
477512

513+
if (maps[i].doorEntity != null) {
514+
engine.addEntity(maps[i].doorEntity);
515+
}
516+
478517
engine.addSystem(new WorldPlayerInputSystem(worldSelectChangeListener, 100));
479518
engine.addSystem(new MovementSystem(maps[i], 500));
480519
engine.addSystem(new FocusTakingSystem(750));
@@ -488,26 +527,14 @@ public void initWorldEngines(Engine[] engines) {
488527
}
489528

490529
public void initBattleEngine(Engine engine) {
491-
final float yTile = 12 * WorldConstants.TILE_HEIGHT;
492-
493-
battlePlayerEntity = new Entity();
494-
495-
battlePlayerEntity.add(new Position(17 * WorldConstants.TILE_WIDTH, yTile));
496-
battlePlayerEntity.add(getBattlePlayerPowerLevelRenderable());
497-
battlePlayerEntity.add(playerStats);
498-
Gdx.app.debug("PLAYER_THINK_TIME", "Player has " + playerStats.getThinkTime() + "s think time.");
499-
500-
Player playerComp = new Player(PLAYER_NAME);
501-
battlePlayerEntity.add(playerComp);
502-
Combatant playerCombatant = new Combatant();
503-
battlePlayerEntity.add(playerCombatant);
504-
battlePlayerEntity.add(new Named(playerComp.name));
530+
makeBattlePlayerEntity(engine);
531+
Combatant playerCom = ComponentMapper.getFor(Combatant.class).get(battlePlayerEntity);
505532

506533
Rectangle screenRect = new Rectangle(0.0f, 0.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
507534

508535
statusDialog = new Entity();
509536
statusDialog.add(new RelativePosition(new Rectangle(0.0f, 0.0f, 0.3f, 0.2f), screenRect));
510-
statusDialog.add(new BattleDialog(Color.BLUE, Color.DARK_GRAY, playerCombatant));
537+
statusDialog.add(new BattleDialog(Color.BLUE, Color.DARK_GRAY, playerCom));
511538

512539
final int menuDialogCount = 4;
513540
final String[] dialogStrings = { "Attack", "Defend", "Quaff", "Flee" };
@@ -526,7 +553,7 @@ public void initBattleEngine(Engine engine) {
526553
RelativePosition menuPos = new RelativePosition(new Rectangle(menuX, 0.0f, menuW, 0.2f), screenRect);
527554

528555
menuDialogs[i].add(menuPos);
529-
menuDialogs[i].add(new BattleDialog(Color.NAVY, Color.DARK_GRAY, playerCombatant));
556+
menuDialogs[i].add(new BattleDialog(Color.NAVY, Color.DARK_GRAY, playerCom));
530557
menuDialogs[i].add(new MouseClickListener(menuPos.pos, BattlePerformers.performers[i]));
531558

532559
menuTexts[i] = new Entity();
@@ -566,13 +593,31 @@ public void initBattleEngine(Engine engine) {
566593
engine.addSystem(new BuffSystem(50));
567594
engine.addSystem(new BattleAISystem(75));
568595
engine.addSystem(new BattleInputSystem(camera, 100));
569-
engine.addSystem(battleAttackSystem.addVictoryListener(battleVictoryListener));
596+
engine.addSystem(battleAttackSystem.addVictoryListener(battleVictoryListener).addDefeatListener(
597+
battleDefeatListener));
570598
engine.addSystem(battleMessageSystem);
571599
engine.addSystem(new RenderSystem(batch, camera, 1000));
572600
engine.addSystem(new BattleDialogRenderSystem(camera, 2000));
573601
engine.addSystem(new TextRenderSystem(batch, font16, 3000));
574602
}
575603

604+
public void makeBattlePlayerEntity(Engine engine) {
605+
battlePlayerEntity = new Entity();
606+
607+
battlePlayerEntity.add(new Position(17 * WorldConstants.TILE_WIDTH, yTile));
608+
battlePlayerEntity.add(getBattlePlayerPowerLevelRenderable());
609+
battlePlayerEntity.add(playerStats);
610+
Gdx.app.debug("PLAYER_THINK_TIME", "Player has " + playerStats.getThinkTime() + "s think time.");
611+
612+
Player playerComp = new Player(PLAYER_NAME);
613+
battlePlayerEntity.add(playerComp);
614+
Combatant playerCombatant = new Combatant();
615+
battlePlayerEntity.add(playerCombatant);
616+
battlePlayerEntity.add(new Named(playerComp.name));
617+
618+
engine.addEntity(battlePlayerEntity);
619+
}
620+
576621
public void initWorldSelectEngine(Engine engine) {
577622
worldSelectTextures = new Texture[worldSelectTexFiles.length];
578623

@@ -649,12 +694,12 @@ private void addSlimes(Engine engine, int count) {
649694
slimeEntity.add(positions[i]).add(
650695
new Renderable(slimeAnims[currentMapIndex]).setPrioritity(50).setAnimationResolver(
651696
new SlimeFrameResolver()));
652-
Stats slimeStats = new Stats(50, 10, 1, 2 + (random.nextInt(3) + 1) * 5);
697+
Stats slimeStats = new Stats(50 + 10 * playerPowerLevel, 10, 10, 5 + (random.nextInt(3) + 1) * 5);
653698
slimeEntity.add(slimeStats);
654699
Gdx.app.debug("SLIME_THINK_TIME", "Slimes think for " + slimeStats.getThinkTime() + "s.");
655700
slimeEntity.add(new Combatant().setThinkingTime(0.0f + random.nextFloat()));
656701

657-
Enemy slime1 = new Enemy("Green Ooze");
702+
Enemy slime1 = new Enemy("Slime");
658703
slimeEntity.add(slime1);
659704
slimeEntity.add(new Named(slime1.speciesName + " " + (i + 1)));
660705
engine.addEntity(slimeEntity);
@@ -766,6 +811,7 @@ public Renderable getBattlePlayerPowerLevelRenderable() {
766811

767812
public void doPlayerPowerUp() {
768813
playerPowerLevel++;
814+
playerStats.addExperience(10);
769815

770816
if (playerPowerLevel >= playerFiles.length) {
771817
playerPowerLevel = playerFiles.length - 1;
@@ -824,6 +870,11 @@ public void healToFull() {
824870

825871
public void moveToLastWorld() {
826872
Gdx.app.debug("LAST_WORLD", "Last world teleport activated.");
873+
flagWorldChange(6);
874+
}
875+
876+
public static void doFinalFight() {
877+
worldEngines[6].getSystem(DialogueSystem.class).add(getCurrentMap().bossEntity);
827878
}
828879

829880
@Override
@@ -840,6 +891,14 @@ public void dispose() {
840891
}
841892
}
842893

894+
if (openDoorTex != null) {
895+
openDoorTex.dispose();
896+
}
897+
898+
if (closedDoorTex != null) {
899+
closedDoorTex.dispose();
900+
}
901+
843902
for (int i = 0; i < worldSelectTexFiles.length; i++) {
844903
if (worldSelectTextures[i] != null) {
845904
worldSelectTextures[i].dispose();
@@ -894,6 +953,16 @@ public void dispose() {
894953
}
895954
}
896955

956+
public static boolean finished = false;
957+
public static Listener<Entity> finalFightListener = new Listener<Entity>() {
958+
@Override
959+
public void receive(Signal<Entity> signal, Entity object) {
960+
if (!finished) {
961+
TesseractMain.doFinalFight();
962+
}
963+
}
964+
};
965+
897966
public class WorldSelectChangeListener implements Listener<Boolean> {
898967
@Override
899968
public void receive(Signal<Boolean> signal, Boolean object) {
@@ -909,6 +978,15 @@ public void receive(Signal<Boolean> signal, Boolean object) {
909978
}
910979
}
911980

981+
public class BattleDefeatListener implements Listener<Boolean> {
982+
@Override
983+
public void receive(Signal<Boolean> signal, Boolean object) {
984+
Gdx.app.debug("BATTLE_DEFEAT", "Battle defeat detected :(");
985+
healOnTransition = true;
986+
flagWorldChange(0);
987+
}
988+
}
989+
912990
public class DialogueFinishListener implements Listener<Entity> {
913991
@Override
914992
public void receive(Signal<Entity> signal, Entity object) {

core/src/uk/org/ulcompsoc/tesseract/TesseractStrings.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ public static BattleMessage getVictoryMessage() {
6161
}
6262
}
6363

64+
private static BattleMessage defeatMessage = new BattleMessage("That's going to hurt in the morning!",
65+
VICTORY_MESSAGE_TIME);
66+
67+
public static BattleMessage getDefeatMessage() {
68+
return defeatMessage;
69+
}
70+
6471
private static BattleMessage attackNotReady = new BattleMessage("Not ready yet!", 0.5f);
6572

6673
public static BattleMessage getAttackNotReadyMessage() {

0 commit comments

Comments
 (0)