Search in sources :

Example 11 with DungeonTileModelInstance

use of util.DungeonTileModelInstance in project ultimate-java by pantinor.

the class StaticGeneratedDungeonScreen 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);
    Gdx.gl.glViewport(32, 64, Ultima4.MAP_WIDTH, Ultima4.MAP_HEIGHT);
    camera.update();
    modelBatch.begin(camera);
    for (DungeonTileModelInstance i : modelInstances) {
        if (i.getLevel() == currentLevel) {
            modelBatch.render(i.getInstance(), environment[currentLevel]);
        }
    }
    modelBatch.end();
    for (Creature cr : dngMap.getMap().getCreatures()) {
        if (cr.currentLevel != this.currentLevel) {
            continue;
        }
        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);
    Ultima4.hud.render(batch, context.getParty());
    Ultima4.font.draw(batch, "Level " + (currentLevel + 1) + " facing " + currentDir, 305, Ultima4.SCREEN_HEIGHT - 7);
    if (showZstats > 0) {
        context.getParty().getSaveGame().renderZstats(showZstats, Ultima4.font, batch, Ultima4.SCREEN_HEIGHT);
    }
    batch.end();
    stage.act();
    stage.draw();
}
Also used : Creature(objects.Creature) DungeonTileModelInstance(util.DungeonTileModelInstance) Vector3(com.badlogic.gdx.math.Vector3)

Example 12 with DungeonTileModelInstance

use of util.DungeonTileModelInstance in project ultimate-java by pantinor.

the class SpellUtil method spellDispel.

public static void spellDispel(BaseScreen screen, Context context, PartyMember caster, Direction dir) {
    if (screen.scType == ScreenType.MAIN) {
        GameScreen gameScreen = (GameScreen) screen;
        Vector3 v = gameScreen.getCurrentMapCoords();
        int x = (int) v.x;
        int y = (int) v.y;
        if (dir == Direction.NORTH) {
            y--;
        }
        if (dir == Direction.SOUTH) {
            y++;
        }
        if (dir == Direction.EAST) {
            x++;
        }
        if (dir == Direction.WEST) {
            x--;
        }
        Tile dispellable = context.getCurrentMap().getTile(x, y);
        if (dispellable.getRule() == null || !dispellable.getRule().has(TileAttrib.dispelable)) {
            return;
        }
        gameScreen.replaceTile("grass", x, y);
    } else if (screen.scType == ScreenType.COMBAT) {
        CombatScreen combatScreen = (CombatScreen) screen;
        int x = caster.combatCr.currentX;
        int y = caster.combatCr.currentY;
        if (dir == Direction.NORTH) {
            y--;
        }
        if (dir == Direction.SOUTH) {
            y++;
        }
        if (dir == Direction.EAST) {
            x++;
        }
        if (dir == Direction.WEST) {
            x--;
        }
        Tile dispellable = combatScreen.combatMap.getTile(x, y);
        if (dispellable.getRule() == null || !dispellable.getRule().has(TileAttrib.dispelable)) {
            return;
        }
        combatScreen.replaceTile("dungeon_floor", x, y);
    } else if (screen.scType == ScreenType.DUNGEON) {
        DungeonScreen dngScreen = (DungeonScreen) screen;
        int x = (Math.round(dngScreen.currentPos.x) - 1);
        int y = (Math.round(dngScreen.currentPos.z) - 1);
        if (dngScreen.currentDir == Direction.NORTH) {
            y = y - 1 < 0 ? DungeonScreen.DUNGEON_MAP - 1 : y - 1;
        }
        if (dngScreen.currentDir == Direction.SOUTH) {
            y = y + 1 >= DungeonScreen.DUNGEON_MAP ? 0 : y + 1;
        }
        if (dngScreen.currentDir == Direction.EAST) {
            x = x + 1 >= DungeonScreen.DUNGEON_MAP ? 0 : x + 1;
        }
        if (dngScreen.currentDir == Direction.WEST) {
            x = x - 1 < 0 ? DungeonScreen.DUNGEON_MAP - 1 : x - 1;
        }
        DungeonTileModelInstance dispellable = null;
        for (DungeonTileModelInstance dmi : dngScreen.modelInstances) {
            if (dmi.getTile().getValue() >= DungeonTile.FIELD_POISON.getValue() && dmi.getTile().getValue() <= DungeonTile.FIELD_SLEEP.getValue()) {
                if (dmi.x == x && dmi.y == y && dmi.getLevel() == dngScreen.currentLevel) {
                    dispellable = dmi;
                    break;
                }
            }
        }
        if (dispellable != null) {
            dngScreen.modelInstances.remove(dispellable);
            dngScreen.dungeonTiles[dngScreen.currentLevel][x][y] = DungeonTile.NOTHING;
            dngScreen.createMiniMap();
        }
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) Tile(objects.Tile) Vector3(com.badlogic.gdx.math.Vector3)

Aggregations

DungeonTileModelInstance (util.DungeonTileModelInstance)12 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)6 PartyDeathException (util.PartyDeathException)6 Vector3 (com.badlogic.gdx.math.Vector3)5 PartyMember (objects.Party.PartyMember)4 Material (com.badlogic.gdx.graphics.g3d.Material)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)3 Creature (objects.Creature)3 Color (com.badlogic.gdx.graphics.Color)2 Texture (com.badlogic.gdx.graphics.Texture)2 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandle (com.badlogic.gdx.files.FileHandle)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureAtlasData (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData)1 Region (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region)1 Environment (com.badlogic.gdx.graphics.g3d.Environment)1 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)1