Search in sources :

Example 1 with PlayAudioMessage

use of com.minecolonies.coremod.network.messages.client.PlayAudioMessage in project minecolonies by ldtteam.

the class HordeRaidEvent method sendHordeMessage.

/**
 * Sends the right horde message.
 */
protected void sendHordeMessage() {
    int total = 0;
    for (IColonyEvent event : colony.getEventManager().getEvents().values()) {
        if (event instanceof HordeRaidEvent) {
            total += ((HordeRaidEvent) event).horde.hordeSize;
        }
    }
    raidBar.setPercent((float) horde.hordeSize / horde.initialSize);
    if (total == 0) {
        LanguageHandler.sendPlayersMessage(colony.getImportantMessageEntityPlayers(), LanguageHandler.translateKey(ALL_BARBARIANS_KILLED_MESSAGE), colony.getName());
        PlayAudioMessage audio = new PlayAudioMessage(horde.initialSize <= SMALL_HORDE_SIZE ? RaidSounds.VICTORY_EARLY : RaidSounds.VICTORY, SoundCategory.RECORDS);
        PlayAudioMessage.sendToAll(getColony(), false, true, audio);
        if (colony.getRaiderManager().getLostCitizen() == 0) {
            colony.getCitizenManager().updateModifier("raidwithoutdeath");
        }
    } else if (total > 0 && total <= SMALL_HORDE_SIZE) {
        LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), ONLY_X_BARBARIANS_LEFT_MESSAGE, total);
    }
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) PlayAudioMessage(com.minecolonies.coremod.network.messages.client.PlayAudioMessage)

Example 2 with PlayAudioMessage

use of com.minecolonies.coremod.network.messages.client.PlayAudioMessage in project minecolonies by ldtteam.

the class EgyptianRaidEvent method onStart.

@Override
public void onStart() {
    super.onStart();
    PlayAudioMessage.sendToAll(getColony(), true, false, new PlayAudioMessage(RaidSounds.DESERT_RAID_WARNING));
}
Also used : PlayAudioMessage(com.minecolonies.coremod.network.messages.client.PlayAudioMessage)

Example 3 with PlayAudioMessage

use of com.minecolonies.coremod.network.messages.client.PlayAudioMessage in project minecolonies by Minecolonies.

the class HordeRaidEvent method sendHordeMessage.

/**
 * Sends the right horde message.
 */
protected void sendHordeMessage() {
    int total = 0;
    for (IColonyEvent event : colony.getEventManager().getEvents().values()) {
        if (event instanceof HordeRaidEvent) {
            total += ((HordeRaidEvent) event).horde.hordeSize;
        }
    }
    raidBar.setPercent((float) horde.hordeSize / horde.initialSize);
    if (total == 0) {
        MessageUtils.format(ALL_BARBARIANS_KILLED_MESSAGE, colony.getName()).sendTo(colony).forManagers();
        PlayAudioMessage audio = new PlayAudioMessage(horde.initialSize <= SMALL_HORDE_SIZE ? RaidSounds.VICTORY_EARLY : RaidSounds.VICTORY, SoundCategory.RECORDS);
        PlayAudioMessage.sendToAll(getColony(), false, true, audio);
        if (colony.getRaiderManager().getLostCitizen() == 0) {
            colony.getCitizenManager().updateModifier("raidwithoutdeath");
        }
    } else if (total > 0 && total <= SMALL_HORDE_SIZE) {
        MessageUtils.format(ONLY_X_BARBARIANS_LEFT_MESSAGE, total).sendTo(colony).forManagers();
    }
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) PlayAudioMessage(com.minecolonies.coremod.network.messages.client.PlayAudioMessage)

Example 4 with PlayAudioMessage

use of com.minecolonies.coremod.network.messages.client.PlayAudioMessage in project minecolonies by Minecolonies.

the class AmazonRaidEvent method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (--musicCooldown <= 0) {
        PlayAudioMessage.sendToAll(getColony(), true, true, new PlayAudioMessage(RaidSounds.AMAZON_RAID));
        musicCooldown = 20;
    }
}
Also used : PlayAudioMessage(com.minecolonies.coremod.network.messages.client.PlayAudioMessage)

Example 5 with PlayAudioMessage

use of com.minecolonies.coremod.network.messages.client.PlayAudioMessage in project minecolonies by Minecolonies.

the class HordeRaidEvent method onStart.

@Override
public void onStart() {
    if (spawnPathResult != null && spawnPathResult.isDone()) {
        final Path path = spawnPathResult.getPath();
        if (path != null && path.canReach()) {
            spawnPoint = path.getEndNode().asBlockPos();
        }
        this.wayPoints = ShipBasedRaiderUtils.createWaypoints(colony.getWorld(), path, WAYPOINT_SPACING);
    }
    final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(spawnPoint, colony, MAX_SPAWN_DEVIATION, spawnPoint, MIN_CENTER_DISTANCE, 10);
    if (spawnPos == null) {
        status = EventStatus.CANCELED;
        return;
    }
    status = EventStatus.PREPARING;
    spawnCampFires(spawnPos);
    final double dist = colony.getCenter().distSqr(spawnPos);
    if (dist < MIN_CENTER_DISTANCE * MIN_CENTER_DISTANCE) {
        campFireTime = 6;
    } else {
        campFireTime = 3;
    }
    spawnHorde(spawnPos, colony, id, horde.numberOfBosses, horde.numberOfArchers, horde.numberOfRaiders);
    updateRaidBar();
    MessageUtils.format(RAID_EVENT_MESSAGE + horde.getMessageID(), BlockPosUtil.calcDirection(colony.getCenter(), spawnPoint), colony.getName()).sendTo(colony).forManagers();
    PlayAudioMessage audio = new PlayAudioMessage(horde.initialSize <= SMALL_HORDE_SIZE ? RaidSounds.WARNING_EARLY : RaidSounds.WARNING, SoundCategory.RECORDS);
    PlayAudioMessage.sendToAll(getColony(), false, false, audio);
}
Also used : Path(net.minecraft.pathfinding.Path) PlayAudioMessage(com.minecolonies.coremod.network.messages.client.PlayAudioMessage) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

PlayAudioMessage (com.minecolonies.coremod.network.messages.client.PlayAudioMessage)10 IColonyEvent (com.minecolonies.api.colony.colonyEvents.IColonyEvent)2 Path (net.minecraft.pathfinding.Path)2 BlockPos (net.minecraft.util.math.BlockPos)2