use of util.DungeonTileModelInstance in project ultimate-java by pantinor.
the class DungeonScreen method render.
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
lightFactor += Gdx.graphics.getDeltaTime();
float lightSize = 4.75f + 0.25f * (float) Math.sin(lightFactor) + .2f * MathUtils.random();
Vector3 ll = isTorchOn ? nll : vdll;
ll = isTorchOn ? nll2 : vdll;
fixedLight.set(ll.x, ll.y, ll.z, currentPos.x, currentPos.y + .35f, currentPos.z, lightSize);
((ColorAttribute) pLight.material.get(ColorAttribute.Diffuse)).color.set(fixedLight.color);
pLight.worldTransform.setTranslation(fixedLight.position);
Gdx.gl.glViewport(32, 64, Ultima4.MAP_WIDTH, Ultima4.MAP_HEIGHT);
camera.update();
modelBatch.begin(camera);
modelBatch.render(pLight);
for (ModelInstance i : floor) {
modelBatch.render(i, environment);
}
for (ModelInstance i : ceiling) {
modelBatch.render(i, environment);
}
for (DungeonTileModelInstance i : modelInstances) {
if (i.getLevel() == currentLevel) {
modelBatch.render(i.getInstance(), environment);
}
}
modelBatch.end();
for (Creature cr : dngMap.getMap().getCreatures()) {
decalBatch.add(cr.getDecal());
}
decalBatch.flush();
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.begin();
batch.draw(Ultima4.backGround, 0, 0);
if (showMiniMap) {
batch.draw(MINI_MAP_TEXTURE, xalignMM, yalignMM);
batch.draw(miniMap, xalignMM, yalignMM);
}
Ultima4.hud.render(batch, context.getParty());
Ultima4.font.draw(batch, this.dngMap.getLabel(), 315, Ultima4.SCREEN_HEIGHT - 7);
Ultima4.font.draw(batch, "Level " + (currentLevel + 1), 515, Ultima4.SCREEN_HEIGHT - 7);
if (showZstats > 0) {
context.getParty().getSaveGame().renderZstats(showZstats, Ultima4.font, batch, Ultima4.SCREEN_HEIGHT);
}
batch.end();
stage.act();
stage.draw();
}
use of util.DungeonTileModelInstance in project ultimate-java by pantinor.
the class DungeonScreen method dungeonTouchOrb.
public void dungeonTouchOrb(int index) {
if (index >= context.getParty().getMembers().size()) {
return;
}
PartyMember pm = context.getParty().getMember(index);
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
int stats = 0;
int damage = 0;
switch(dngMap) {
case DECEIT:
stats = STATSBONUS_INT;
break;
case DESPISE:
stats = STATSBONUS_DEX;
break;
case DESTARD:
stats = STATSBONUS_STR;
break;
case WRONG:
stats = STATSBONUS_INT | STATSBONUS_DEX;
break;
case COVETOUS:
stats = STATSBONUS_DEX | STATSBONUS_STR;
break;
case SHAME:
stats = STATSBONUS_INT | STATSBONUS_STR;
break;
case HYTHLOTH:
stats = STATSBONUS_INT | STATSBONUS_DEX | STATSBONUS_STR;
break;
default:
break;
}
if ((stats & STATSBONUS_STR) > 0) {
log("Strength + 5");
int n = Utils.adjustValueMax(pm.getPlayer().str, 5, 50);
pm.getPlayer().str = n;
damage += 200;
}
if ((stats & STATSBONUS_DEX) > 0) {
log("Dexterity + 5");
int n = Utils.adjustValueMax(pm.getPlayer().dex, 5, 50);
pm.getPlayer().dex = n;
damage += 200;
}
if ((stats & STATSBONUS_INT) > 0) {
log("Intelligence + 5");
int n = Utils.adjustValueMax(pm.getPlayer().intel, 5, 50);
pm.getPlayer().intel = n;
damage += 200;
}
Sounds.play(Sound.LIGHTNING);
try {
pm.applyDamage(damage, false);
} catch (PartyDeathException pde) {
partyDeath();
return;
}
// remove orb model instance
DungeonTileModelInstance orb = null;
for (DungeonTileModelInstance dmi : modelInstances) {
if (dmi.getTile() == DungeonTile.ORB) {
if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
orb = dmi;
break;
}
}
}
modelInstances.remove(orb);
dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
}
use of util.DungeonTileModelInstance in project ultimate-java by pantinor.
the class StaticGeneratedDungeonScreen method getChest.
public void getChest(int index, int x, int y) {
try {
DungeonTileModelInstance chest = null;
for (DungeonTileModelInstance dmi : modelInstances) {
if (dmi.getTile() == DungeonTile.CHEST) {
if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
chest = dmi;
break;
}
}
}
if (chest != null) {
PartyMember pm = context.getParty().getMember(index);
context.getChestTrapHandler(pm);
log(String.format("The Chest Holds: %d Gold", context.getParty().getChestGold()));
// remove chest model instance
modelInstances.remove(chest);
dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
} else {
log("Not Here!");
}
} catch (PartyDeathException e) {
partyDeath();
}
}
use of util.DungeonTileModelInstance in project ultimate-java by pantinor.
the class StaticGeneratedDungeonScreen method endCombat.
@Override
public void endCombat(boolean isWon, BaseMap combatMap, boolean wounded) {
mainGame.setScreen(this);
if (isWon) {
if (currentEncounter != null) {
log("Victory!");
context.getParty().adjustKarma(KarmaAction.KILLED_EVIL);
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
/* add a chest, if the creature leaves one */
if (!currentEncounter.getNochest() && dungeonTiles[currentLevel][x][y] == DungeonTile.NOTHING) {
ModelInstance instance = new ModelInstance(chestModel, x + .5f, 0, y + .5f);
instance.nodes.get(0).scale.set(.010f, .010f, .010f);
instance.calculateTransforms();
DungeonTileModelInstance in = new DungeonTileModelInstance(instance, DungeonTile.CHEST, currentLevel);
in.x = x;
in.y = y;
modelInstances.add(in);
dungeonTiles[currentLevel][x][y] = DungeonTile.CHEST;
}
}
} else {
if (combatMap.getType() == MapType.combat && context.getParty().didAnyoneFlee()) {
log("Battle is lost!");
// no flee penalty in dungeons
} else if (!context.getParty().isAnyoneAlive()) {
partyDeath();
}
}
if (currentEncounter != null) {
dngMap.getMap().removeCreature(currentEncounter);
currentEncounter = null;
}
}
use of util.DungeonTileModelInstance in project ultimate-java by pantinor.
the class StaticGeneratedDungeonScreen method dungeonTouchOrb.
public void dungeonTouchOrb(int index) {
try {
if (index >= context.getParty().getMembers().size()) {
return;
}
PartyMember pm = context.getParty().getMember(index);
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
int stats = 0;
int damage = 0;
if (dngMap == Maps.DELVE_SORROWS) {
if (currentLevel == 1) {
stats = STATSBONUS_INT | STATSBONUS_DEX;
} else {
stats = STATSBONUS_INT | STATSBONUS_DEX | STATSBONUS_STR;
}
} else {
stats = STATSBONUS_STR;
}
if ((stats & STATSBONUS_STR) > 0) {
log("Strength + 5");
int n = Utils.adjustValueMax(pm.getPlayer().str, 5, 50);
pm.getPlayer().str = n;
damage += 200;
}
if ((stats & STATSBONUS_DEX) > 0) {
log("Dexterity + 5");
int n = Utils.adjustValueMax(pm.getPlayer().dex, 5, 50);
pm.getPlayer().dex = n;
damage += 200;
}
if ((stats & STATSBONUS_INT) > 0) {
log("Intelligence + 5");
int n = Utils.adjustValueMax(pm.getPlayer().intel, 5, 50);
pm.getPlayer().intel = n;
damage += 200;
}
Sounds.play(Sound.LIGHTNING);
pm.applyDamage(damage, false);
// remove orb model instance
DungeonTileModelInstance orb = null;
for (DungeonTileModelInstance dmi : modelInstances) {
if (dmi.getTile() == DungeonTile.ORB) {
if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
orb = dmi;
break;
}
}
}
modelInstances.remove(orb);
dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
} catch (PartyDeathException pde) {
partyDeath();
}
}
Aggregations