Skip to content

Commit

Permalink
Bosses and progression, LD release
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtCoDFish committed Aug 26, 2014
1 parent 2f46c98 commit c7cc305
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 57 deletions.
Binary file added core/assets/door_closed.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 core/assets/door_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion core/assets/maps/world1/world1.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</layer>
<layer name="doortop" width="32" height="32">
<properties>
<property name="door" value="true"/>
<property name="hidden" value=""/>
<property name="z" value="1"/>
</properties>
<data encoding="base64">
Expand All @@ -31,6 +31,7 @@
<layer name="doorbot" width="32" height="32">
<properties>
<property name="door" value="true"/>
<property name="hidden" value=""/>
<property name="solid" value="true"/>
</properties>
<data encoding="base64">
Expand Down
4 changes: 2 additions & 2 deletions core/assets/maps/world7/boss_start.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
So that old man was really working in collaberation with those wizards all along?
He is actually some crazy flying demon man?
So that old man was really working in collaboration with those wizards all along?
He's actually some crazy flying demon man?
Who could have guessed that amazing plot twist?
Time to put that slime slaying training to good use and slay this foul beast!
3 changes: 2 additions & 1 deletion core/assets/maps/world7/world7.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</layer>
<layer name="npc2" width="8" height="8">
<properties>
<property name="finalwiz" value="true"/>
<property name="npc" value="true"/>
<property name="solid" value="true"/>
</properties>
Expand All @@ -42,7 +43,7 @@
<property name="solid" value="true"/>
</properties>
<data encoding="base64">
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
</data>
</layer>
<layer name="solidobs" width="8" height="8">
Expand Down
2 changes: 0 additions & 2 deletions core/src/uk/org/ulcompsoc/tesseract/MusicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public MusicManager(String[] files) {
}

public void play(int index) {
Gdx.app.debug("PLAY", "");
if (playingIndex != -1) {
loadedMusic[playingIndex].stop();
}
Expand Down Expand Up @@ -80,7 +79,6 @@ public void update(float deltaTime) {
remainingFadeTime -= deltaTime;

if (remainingFadeTime <= 0.0f) {
Gdx.app.debug("FADE_COMPLETE", "");
fadeDuration = -1.0f;
remainingFadeTime = -1.0f;
loadedMusic[playingIndex].setVolume(DEFAULT_VOLUME);
Expand Down
144 changes: 111 additions & 33 deletions core/src/uk/org/ulcompsoc/tesseract/TesseractMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Engine;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
Expand Down Expand Up @@ -92,19 +94,22 @@ public class TesseractMain extends ApplicationAdapter {

private Engine currentEngine = null;

private Engine battleEngine = null;
private Engine worldSelectEngine = null;
private Engine[] worldEngines = null;
private static Engine battleEngine = null;
private static Engine worldSelectEngine = null;
private static Engine[] worldEngines = null;

public static Entity battlePlayerEntity = null;
public static Entity worldPlayerEntity = null;
public static Stats playerStats = null;

BattleVictoryListener battleVictoryListener = null;
private BattleVictoryListener battleVictoryListener = null;
private BattleDefeatListener battleDefeatListener = null;

private static boolean bossIncomingFlag = false;
private static boolean battleChangeFlag = false;
private static boolean worldChangeFlag = false;

private boolean healOnTransition = false;
private static boolean worldSelectChangeFlag = false;
private static int diffWorldFlag = -1;
private float transitionTime = -1.0f;
Expand Down Expand Up @@ -133,11 +138,14 @@ public class TesseractMain extends ApplicationAdapter {
private Texture[] bossTextures = null;
private Animation[] bossAnims = null;
private Stats[] bossStats = { new Stats(20, 15, 10, 3),
new Stats(10, 15, 10, 5), new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5),
new Stats(10, 40, 10, 5), new Stats(10, 40, 10, 5) };
new Stats(100, 15, 10, 1), new Stats(150, 20, 10, 5), new Stats(150, 25, 10, 5), new Stats(150, 30, 10, 2),
new Stats(150, 35, 10, 5), new Stats(100, 40, 5, 2) };

private Texture[] worldSelectTextures = null;

private Texture openDoorTex = null;
private Texture closedDoorTex = null;

private DialogueFinishListener healNPCListener = null;
private DialogueFinishListener bossBattleListener = null;
private DialogueFinishListener doorOpenListener = null;
Expand Down Expand Up @@ -193,6 +201,8 @@ public class TesseractMain extends ApplicationAdapter {
private static TesseractMap[] maps = null;
public static int currentMapIndex = 0;

final float yTile = 12 * WorldConstants.TILE_HEIGHT;

@SuppressWarnings("unused")
private GameState gameState = null;

Expand Down Expand Up @@ -258,10 +268,14 @@ public void create() {

loadBossFiles();

openDoorTex = new Texture(Gdx.files.internal("door_open.png"));
closedDoorTex = new Texture(Gdx.files.internal("door_closed.png"));

playerStats = new Stats(100, 30, 5, 70);

monsterTileHandler = new MonsterTileHandler();
battleVictoryListener = new BattleVictoryListener();
battleDefeatListener = new BattleDefeatListener();

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

if (Gdx.input.isKeyJustPressed(Keys.F5)) {
changeToWorld((currentMapIndex + 1));
} else if (Gdx.input.isKeyJustPressed(Keys.F1)) {
doPlayerPowerUp();
if (Gdx.app.getLogLevel() == Application.LOG_DEBUG) {
if (Gdx.input.isKeyJustPressed(Keys.F5)) {
changeToWorld((currentMapIndex + 1));
} else if (Gdx.input.isKeyJustPressed(Keys.F1)) {
doPlayerPowerUp();
}
}

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

if (transitionTime <= 0.0f) {
transitionTime = -1.0f;
if (healOnTransition) {
healToFull();
healOnTransition = false;
}

if (worldChangeFlag) {
changeToWorld(diffWorldFlag);
Expand Down Expand Up @@ -345,16 +365,22 @@ public void flagWorldReturn(boolean bossBattleJustHappened) {
int bossesRemaining = 0;

for (TesseractMap map : maps) {
if (!map.bossBeaten) {
if (!map.bossBeaten && map.bossEntity != null) {
bossesRemaining++;
}
}

if (bossesRemaining == 0) {
Gdx.app.debug("BOSSES_REMAINING", "" + bossesRemaining + " bosses remaining.");

if (bossesRemaining == 1) { // 1 because of the last boss
Gdx.app.debug("ALL_BOSSES", "All bosses defeated, opening final world.");
Engine world1 = worldEngines[0];
world1.removeEntity(maps[0].doorEntity);
world1.addEntity(maps[0].openDoorEntity);
} else if (bossesRemaining == 0) {
finished = true;
flagWorldChange(0);
return;
}

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

this.currentEngine = battleEngine;
@SuppressWarnings("unchecked")
ImmutableArray<Entity> ents = currentEngine.getEntitiesFor(Family.getFor(Enemy.class));
if (ents.size() > 0) {
while (ents.size() > 0) {
currentEngine.removeEntity(ents.get(0));
}

makeBattlePlayerEntity(currentEngine);
}

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

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

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

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

if (maps[i].doorEntity != null) {
engine.addEntity(maps[i].doorEntity);
}

engine.addSystem(new WorldPlayerInputSystem(worldSelectChangeListener, 100));
engine.addSystem(new MovementSystem(maps[i], 500));
engine.addSystem(new FocusTakingSystem(750));
Expand All @@ -488,26 +527,14 @@ public void initWorldEngines(Engine[] engines) {
}

public void initBattleEngine(Engine engine) {
final float yTile = 12 * WorldConstants.TILE_HEIGHT;

battlePlayerEntity = new Entity();

battlePlayerEntity.add(new Position(17 * WorldConstants.TILE_WIDTH, yTile));
battlePlayerEntity.add(getBattlePlayerPowerLevelRenderable());
battlePlayerEntity.add(playerStats);
Gdx.app.debug("PLAYER_THINK_TIME", "Player has " + playerStats.getThinkTime() + "s think time.");

Player playerComp = new Player(PLAYER_NAME);
battlePlayerEntity.add(playerComp);
Combatant playerCombatant = new Combatant();
battlePlayerEntity.add(playerCombatant);
battlePlayerEntity.add(new Named(playerComp.name));
makeBattlePlayerEntity(engine);
Combatant playerCom = ComponentMapper.getFor(Combatant.class).get(battlePlayerEntity);

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

statusDialog = new Entity();
statusDialog.add(new RelativePosition(new Rectangle(0.0f, 0.0f, 0.3f, 0.2f), screenRect));
statusDialog.add(new BattleDialog(Color.BLUE, Color.DARK_GRAY, playerCombatant));
statusDialog.add(new BattleDialog(Color.BLUE, Color.DARK_GRAY, playerCom));

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

menuDialogs[i].add(menuPos);
menuDialogs[i].add(new BattleDialog(Color.NAVY, Color.DARK_GRAY, playerCombatant));
menuDialogs[i].add(new BattleDialog(Color.NAVY, Color.DARK_GRAY, playerCom));
menuDialogs[i].add(new MouseClickListener(menuPos.pos, BattlePerformers.performers[i]));

menuTexts[i] = new Entity();
Expand Down Expand Up @@ -566,13 +593,31 @@ public void initBattleEngine(Engine engine) {
engine.addSystem(new BuffSystem(50));
engine.addSystem(new BattleAISystem(75));
engine.addSystem(new BattleInputSystem(camera, 100));
engine.addSystem(battleAttackSystem.addVictoryListener(battleVictoryListener));
engine.addSystem(battleAttackSystem.addVictoryListener(battleVictoryListener).addDefeatListener(
battleDefeatListener));
engine.addSystem(battleMessageSystem);
engine.addSystem(new RenderSystem(batch, camera, 1000));
engine.addSystem(new BattleDialogRenderSystem(camera, 2000));
engine.addSystem(new TextRenderSystem(batch, font16, 3000));
}

public void makeBattlePlayerEntity(Engine engine) {
battlePlayerEntity = new Entity();

battlePlayerEntity.add(new Position(17 * WorldConstants.TILE_WIDTH, yTile));
battlePlayerEntity.add(getBattlePlayerPowerLevelRenderable());
battlePlayerEntity.add(playerStats);
Gdx.app.debug("PLAYER_THINK_TIME", "Player has " + playerStats.getThinkTime() + "s think time.");

Player playerComp = new Player(PLAYER_NAME);
battlePlayerEntity.add(playerComp);
Combatant playerCombatant = new Combatant();
battlePlayerEntity.add(playerCombatant);
battlePlayerEntity.add(new Named(playerComp.name));

engine.addEntity(battlePlayerEntity);
}

public void initWorldSelectEngine(Engine engine) {
worldSelectTextures = new Texture[worldSelectTexFiles.length];

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

Enemy slime1 = new Enemy("Green Ooze");
Enemy slime1 = new Enemy("Slime");
slimeEntity.add(slime1);
slimeEntity.add(new Named(slime1.speciesName + " " + (i + 1)));
engine.addEntity(slimeEntity);
Expand Down Expand Up @@ -766,6 +811,7 @@ public Renderable getBattlePlayerPowerLevelRenderable() {

public void doPlayerPowerUp() {
playerPowerLevel++;
playerStats.addExperience(10);

if (playerPowerLevel >= playerFiles.length) {
playerPowerLevel = playerFiles.length - 1;
Expand Down Expand Up @@ -824,6 +870,11 @@ public void healToFull() {

public void moveToLastWorld() {
Gdx.app.debug("LAST_WORLD", "Last world teleport activated.");
flagWorldChange(6);
}

public static void doFinalFight() {
worldEngines[6].getSystem(DialogueSystem.class).add(getCurrentMap().bossEntity);
}

@Override
Expand All @@ -840,6 +891,14 @@ public void dispose() {
}
}

if (openDoorTex != null) {
openDoorTex.dispose();
}

if (closedDoorTex != null) {
closedDoorTex.dispose();
}

for (int i = 0; i < worldSelectTexFiles.length; i++) {
if (worldSelectTextures[i] != null) {
worldSelectTextures[i].dispose();
Expand Down Expand Up @@ -894,6 +953,16 @@ public void dispose() {
}
}

public static boolean finished = false;
public static Listener<Entity> finalFightListener = new Listener<Entity>() {
@Override
public void receive(Signal<Entity> signal, Entity object) {
if (!finished) {
TesseractMain.doFinalFight();
}
}
};

public class WorldSelectChangeListener implements Listener<Boolean> {
@Override
public void receive(Signal<Boolean> signal, Boolean object) {
Expand All @@ -909,6 +978,15 @@ public void receive(Signal<Boolean> signal, Boolean object) {
}
}

public class BattleDefeatListener implements Listener<Boolean> {
@Override
public void receive(Signal<Boolean> signal, Boolean object) {
Gdx.app.debug("BATTLE_DEFEAT", "Battle defeat detected :(");
healOnTransition = true;
flagWorldChange(0);
}
}

public class DialogueFinishListener implements Listener<Entity> {
@Override
public void receive(Signal<Entity> signal, Entity object) {
Expand Down
7 changes: 7 additions & 0 deletions core/src/uk/org/ulcompsoc/tesseract/TesseractStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public static BattleMessage getVictoryMessage() {
}
}

private static BattleMessage defeatMessage = new BattleMessage("That's going to hurt in the morning!",
VICTORY_MESSAGE_TIME);

public static BattleMessage getDefeatMessage() {
return defeatMessage;
}

private static BattleMessage attackNotReady = new BattleMessage("Not ready yet!", 0.5f);

public static BattleMessage getAttackNotReadyMessage() {
Expand Down
Loading

0 comments on commit c7cc305

Please sign in to comment.