Search in sources :

Example 11 with Creature

use of objects.Creature in project ultimate-java by pantinor.

the class SpellUtil method useMaskOfMinax.

public static void useMaskOfMinax(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.COMBAT) {
        final CombatScreen combatScreen = (CombatScreen) screen;
        final SequenceAction seq = Actions.action(SequenceAction.class);
        for (Creature cr : combatScreen.combatMap.getCreatures()) {
            if (Utils.rand.nextInt(3) == 0) {
                /* Deal maximum damage to creature */
                Utils.dealDamage(caster, cr, 0xFF);
            } else {
                if (cr.getHP() > 23) {
                    Utils.dealDamage(caster, cr, cr.getHP() * (3 / 4));
                } else {
                    Utils.dealDamage(caster, cr, 15);
                }
            }
            Actor d = new CloudDrawable();
            d.setX(cr.currentPos.x - 16);
            d.setY(cr.currentPos.y - 16);
            d.addAction(Actions.sequence(Actions.delay(2f), Actions.removeActor()));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.SPIRITS)));
            seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
            if (cr.getDamageStatus() == CreatureStatus.DEAD) {
                seq.addAction(Actions.run(combatScreen.new RemoveCreatureAction(cr)));
            }
        }
        seq.addAction(Actions.run(new Runnable() {

            @Override
            public void run() {
                combatScreen.finishPlayerTurn();
            }
        }));
        combatScreen.getStage().addAction(seq);
    } else {
        Sounds.play(Sound.ERROR);
    }
}
Also used : Creature(objects.Creature) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 12 with Creature

use of objects.Creature in project ultimate-java by pantinor.

the class SpellUtil method destoryAllCreatures.

/**
 * Used with skull of mondain on world map
 */
public static void destoryAllCreatures(BaseScreen screen, PartyMember caster) {
    if (screen.scType == ScreenType.MAIN) {
        final GameScreen gameScreen = (GameScreen) screen;
        SequenceAction seq = Actions.action(SequenceAction.class);
        for (final Creature cr : screen.context.getCurrentMap().getCreatures()) {
            /* Deal maximum damage to creature */
            Utils.dealDamage(caster, cr, 0xFF);
            Tile tile = Ultima4.baseTileSet.getTileByName("hit_flash");
            Drawable d = new Drawable(screen.context.getCurrentMap(), cr.currentX, cr.currentY, tile, Ultima4.standardAtlas);
            d.setX(cr.currentPos.x);
            d.setY(cr.currentPos.y);
            d.addAction(Actions.sequence(Actions.delay(.4f), Actions.fadeOut(.2f), Actions.removeActor()));
            seq.addAction(Actions.run(new AddActorAction(gameScreen.getStage(), d)));
            seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
            seq.addAction(Actions.run(new Runnable() {

                @Override
                public void run() {
                    screen.context.getCurrentMap().getCreatures().remove(cr);
                }
            }));
        }
        gameScreen.getStage().addAction(seq);
    }
}
Also used : Creature(objects.Creature) Drawable(objects.Drawable) Tile(objects.Tile) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 13 with Creature

use of objects.Creature in project ultimate-java by pantinor.

the class UltimaMapRenderer method renderTileLayer.

@Override
public void renderTileLayer(TiledMapTileLayer layer) {
    stateTime += Gdx.graphics.getDeltaTime();
    Color batchColor = batch.getColor();
    // Color.toFloatBits(batchColor.r, batchColor.g, batchColor.b, batchColor.a * layer.getOpacity());
    float color = 0;
    int layerWidth = layer.getWidth();
    int layerHeight = layer.getHeight();
    int layerTileWidth = (int) (layer.getTileWidth() * unitScale);
    int layerTileHeight = (int) (layer.getTileHeight() * unitScale);
    float[] vertices = this.vertices;
    int col1 = Math.max(0, (int) (viewBounds.x / layerTileWidth));
    int col2 = Math.min(layerWidth, (int) ((viewBounds.x + viewBounds.width + layerTileWidth) / layerTileWidth));
    int row1 = Math.max(0, (int) (viewBounds.y / layerTileHeight));
    int row2 = Math.min(layerHeight, (int) ((viewBounds.y + viewBounds.height + layerTileHeight) / layerTileHeight));
    if (bm.getBorderbehavior() == MapBorderBehavior.wrap) {
        col1 = (int) (viewBounds.x / layerTileWidth);
        col2 = (int) ((viewBounds.x + viewBounds.width + layerTileWidth) / layerTileWidth);
        row1 = (int) (viewBounds.y / layerTileHeight);
        row2 = (int) ((viewBounds.y + viewBounds.height + layerTileHeight) / layerTileHeight);
    }
    float y = row2 * layerTileHeight;
    float startX = col1 * layerTileWidth;
    for (int row = row2; row >= row1; row--) {
        float x = startX;
        for (int col = col1; col < col2; col++) {
            TiledMapTileLayer.Cell cell = null;
            if (bm.getBorderbehavior() == MapBorderBehavior.wrap) {
                int cx = col;
                boolean wrapped = false;
                if (col < 0) {
                    cx = layerWidth + col;
                    wrapped = true;
                } else if (col >= layerWidth) {
                    cx = col - layerWidth;
                    wrapped = true;
                }
                int cy = row;
                if (row < 0) {
                    cy = layerHeight + row;
                    wrapped = true;
                } else if (row >= layerHeight) {
                    cy = row - layerHeight;
                    wrapped = true;
                }
                cell = layer.getCell(cx, cy);
                color = wrapped ? getColor(batchColor, -1, -1) : getColor(batchColor, cx, layerHeight - cy - 1);
            } else {
                cell = layer.getCell(col, row);
                color = getColor(batchColor, col, layerHeight - row - 1);
            }
            if (cell == null) {
                x += layerTileWidth;
                continue;
            }
            TiledMapTile tile = cell.getTile();
            if (tile != null) {
                TextureRegion region = tile.getTextureRegion();
                DoorStatus ds = bm.getDoor(col, layerHeight - row - 1);
                if (ds != null) {
                    region = door;
                    if (ds.locked) {
                        region = locked_door;
                    }
                    if (bm.isDoorOpen(ds)) {
                        region = brick_floor;
                    }
                }
                float x1 = x + tile.getOffsetX() * unitScale;
                float y1 = y + tile.getOffsetY() * unitScale;
                float x2 = x1 + region.getRegionWidth() * unitScale;
                float y2 = y1 + region.getRegionHeight() * unitScale;
                float u1 = region.getU();
                float v1 = region.getV2();
                float u2 = region.getU2();
                float v2 = region.getV();
                vertices[X1] = x1;
                vertices[Y1] = y1;
                vertices[C1] = color;
                vertices[U1] = u1;
                vertices[V1] = v1;
                vertices[X2] = x1;
                vertices[Y2] = y2;
                vertices[C2] = color;
                vertices[U2] = u1;
                vertices[V2] = v2;
                vertices[X3] = x2;
                vertices[Y3] = y2;
                vertices[C3] = color;
                vertices[U3] = u2;
                vertices[V3] = v2;
                vertices[X4] = x2;
                vertices[Y4] = y1;
                vertices[C4] = color;
                vertices[U4] = u2;
                vertices[V4] = v1;
                batch.draw(region.getTexture(), vertices, 0, 20);
            }
            x += layerTileWidth;
        }
        y -= layerTileHeight;
    }
    if (bm.getCity() != null) {
        for (Person p : bm.getCity().getPeople()) {
            if (p == null || p.isRemovedFromMap()) {
                continue;
            }
            if (p.getAnim() != null) {
                draw(p.getAnim().getKeyFrame(stateTime, true), p.getCurrentPos().x, p.getCurrentPos().y, p.getX(), p.getY());
            } else {
                draw(p.getTextureRegion(), p.getCurrentPos().x, p.getCurrentPos().y, p.getX(), p.getY());
            }
        }
    }
    List<Creature> crs = bm.getCreatures();
    if (crs.size() > 0) {
        for (Creature cr : crs) {
            if (cr.currentPos == null || !cr.getVisible()) {
                continue;
            }
            if (cr.getTile() == CreatureType.pirate_ship) {
                TextureRegion tr = cr.getAnim().getKeyFrames()[cr.sailDir.getVal() - 1];
                draw(tr, cr.currentPos.x, cr.currentPos.y, cr.currentX, cr.currentY);
            } else {
                draw(cr.getAnim().getKeyFrame(stateTime, true), cr.currentPos.x, cr.currentPos.y, cr.currentX, cr.currentY);
            }
        }
    }
}
Also used : Creature(objects.Creature) Color(com.badlogic.gdx.graphics.Color) DoorStatus(objects.BaseMap.DoorStatus) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Person(objects.Person)

Example 14 with Creature

use of objects.Creature in project ultimate-java by pantinor.

the class Utils method castAt.

private static AttackResult castAt(BaseMap combatMap, AttackVector target, PartyMember attacker, int minDamage, int maxDamage, Spell spell) {
    AttackResult res = AttackResult.NONE;
    Creature creature = null;
    for (Creature c : combatMap.getCreatures()) {
        if (c.currentX == target.x && c.currentY == target.y) {
            creature = c;
            break;
        }
    }
    if (creature == null) {
        return res;
    }
    if (spell == Spell.SLEEP) {
        if (!"sleep".equals(creature.getResists())) {
            Sounds.play(Sound.NPC_STRUCK);
            Ultima4.hud.add("Slept!\n");
            creature.setStatus(StatusType.SLEEPING);
            return AttackResult.HIT;
        } else {
            Sounds.play(Sound.EVADE);
            Ultima4.hud.add("Resisted!\n");
            return AttackResult.MISS;
        }
    }
    if (spell == Spell.FIREBALL) {
        if ("fire".equals(creature.getResists())) {
            Sounds.play(Sound.EVADE);
            Ultima4.hud.add("Resisted!\n");
            return AttackResult.MISS;
        }
    }
    Sounds.play(Sound.NPC_STRUCK);
    int attackDamage = ((minDamage >= 0) && (minDamage < maxDamage)) ? rand.nextInt((maxDamage + 1) - minDamage) + minDamage : maxDamage;
    dealDamage(attacker, creature, attackDamage);
    return AttackResult.HIT;
}
Also used : Creature(objects.Creature)

Example 15 with Creature

use of objects.Creature in project ultimate-java by pantinor.

the class Utils method attackAt.

private static AttackResult attackAt(BaseMap combatMap, AttackVector target, PartyMember attacker, Direction dir, int range, int distance) {
    AttackResult res = AttackResult.NONE;
    Creature creature = null;
    for (Creature c : combatMap.getCreatures()) {
        if (c.currentX == target.x && c.currentY == target.y) {
            creature = c;
            break;
        }
    }
    WeaponType wt = attacker.getPlayer().weapon;
    boolean wrongRange = (wt.getWeapon().getAbsolute_range() > 0 && (distance != range));
    if (creature == null || wrongRange) {
        if (!wt.getWeapon().getDontshowtravel()) {
        }
        return res;
    }
    if ((combatMap.getId() == Maps.ABYSS.getId() && !wt.getWeapon().getMagic()) || !attackHit(attacker, creature)) {
        Ultima4.hud.add("Missed!\n");
        res = AttackResult.MISS;
    } else {
        Sounds.play(Sound.NPC_STRUCK);
        dealDamage(attacker, creature, attacker.getDamage());
        res = AttackResult.HIT;
    }
    return res;
}
Also used : Creature(objects.Creature)

Aggregations

Creature (objects.Creature)32 Tile (objects.Tile)12 Drawable (objects.Drawable)8 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)6 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)6 Vector3 (com.badlogic.gdx.math.Vector3)6 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 PartyMember (objects.Party.PartyMember)5 PartyDeathException (util.PartyDeathException)5 MapLayer (com.badlogic.gdx.maps.MapLayer)3 DungeonTileModelInstance (util.DungeonTileModelInstance)3 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)2 Texture (com.badlogic.gdx.graphics.Texture)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 MapObject (com.badlogic.gdx.maps.MapObject)2 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)2 Portal (objects.Portal)2 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandle (com.badlogic.gdx.files.FileHandle)1