Java Code Examples for com.megacrit.cardcrawl.core.CardCrawlGame

The following examples show how to use com.megacrit.cardcrawl.core.CardCrawlGame. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jorbs-spire-mod   Source File: EffectUtils.java    License: MIT License 6 votes vote down vote up
public static void addWrathCardUpgradeEffect(AbstractCard cardToShowForVfx) {
    AbstractCard card = cardToShowForVfx.makeStatEquivalentCopy();
    ShowCardBrieflyEffect showCardBrieflyEffect = new ShowCardBrieflyEffect(card);
    float duration = Settings.FAST_MODE ? Settings.ACTION_DUR_XLONG : showCardBrieflyEffect.startingDuration;
    showCardBrieflyEffect.duration = showCardBrieflyEffect.startingDuration = duration;
    AbstractDungeon.topLevelEffects.add(showCardBrieflyEffect);
    AbstractDungeon.topLevelEffects.add(new GradeChangeShineEffect(
            (float) Settings.WIDTH / 2.0F,
            (float) Settings.HEIGHT / 2.0F,
            Settings.ACTION_DUR_MED,
            () -> CardCrawlGame.sound.playAV("CARD_BURN", -0.5F, 2.0F),
            () -> getWrathEffect(card),
            null,
            false));
    AbstractDungeon.actionManager.addToTop(new WaitAction(duration));
}
 
Example 2
Source Project: jorbs-spire-mod   Source File: EffectUtils.java    License: MIT License 6 votes vote down vote up
public static void showDowngradeEffect(AbstractCard card) {
    AbstractDungeon.topLevelEffects.add(new ShowCardBrieflyEffect(card.makeStatEquivalentCopy()));
    float x = (float) Settings.WIDTH / 2.0F;
    float y = (float) Settings.HEIGHT / 2.0F;
    AbstractDungeon.topLevelEffects.add(new GradeChangeShineEffect(
            x,
            y,
            Settings.ACTION_DUR_LONG,
            () -> CardCrawlGame.sound.playAV("SCENE_TORCH_EXTINGUISH", -0.5F, 10.0F),
            // TODO: this effect needs to change to something more negative, but figuring out this many particles is a bit out of my brain capacity ATM.
            // TODO: somehow include the hammer effect too.
            () -> new UpgradeShineParticleEffect(x + MathUtils.random(-10.0F, 10.0F) * Settings.scale, y + MathUtils.random(-10.0F, 10.0F) * Settings.scale),
            Color.FIREBRICK.cpy(),
            true));
    AbstractDungeon.actionManager.addToTop(new WaitAction(Settings.ACTION_DUR_LONG));
}
 
Example 3
Source Project: jorbs-spire-mod   Source File: StaticMemoryInfo.java    License: MIT License 6 votes vote down vote up
private <T extends AbstractMemory> StaticMemoryInfo(Class<T> memoryClass) {
    CLASS = memoryClass;
    ID = JorbsMod.makeID(memoryClass.getSimpleName());
    PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings(ID);
    NAME = powerStrings.NAME;
    DESCRIPTIONS = powerStrings.DESCRIPTIONS;

    String imageFilenamePrefix = memoryClass.getSimpleName().replace("Memory","");
    CLARITY_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("c" + imageFilenamePrefix + "_84.png"));
    CLARITY_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("c" + imageFilenamePrefix + "_48.png"));
    EMPTY_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("e" + imageFilenamePrefix + "_84.png"));
    EMPTY_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("e" + imageFilenamePrefix + "_48.png"));
    REMEMBER_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("r" + imageFilenamePrefix + "_84.png"));
    REMEMBER_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("r" + imageFilenamePrefix + "_48.png"));

    CLARITY_IMG_84 = new TextureAtlas.AtlasRegion(CLARITY_TEXTURE_84, 0, 0, 84, 84);
    CLARITY_IMG_48 = new TextureAtlas.AtlasRegion(CLARITY_TEXTURE_48, 0, 0, 48, 48);
    EMPTY_IMG_84 = new TextureAtlas.AtlasRegion(EMPTY_TEXTURE_84, 0, 0, 84, 84);
    EMPTY_IMG_48 = new TextureAtlas.AtlasRegion(EMPTY_TEXTURE_48, 0, 0, 48, 48);
    REMEMBER_IMG_84 = new TextureAtlas.AtlasRegion(REMEMBER_TEXTURE_84, 0, 0, 84, 84);
    REMEMBER_IMG_48 = new TextureAtlas.AtlasRegion(REMEMBER_TEXTURE_48, 0, 0, 48, 48);
}
 
Example 4
Source Project: jorbs-spire-mod   Source File: CustomPotionDrinkPatch.java    License: MIT License 5 votes vote down vote up
public static boolean playCustomPotionSound(AbstractPotion potion) {
    String customDrinkSound = CustomPotionDrinkFields.customDrinkSound.get(potion);
    if (customDrinkSound == null) {
        return false;
    }
    CardCrawlGame.sound.play(customDrinkSound);
    return true;
}
 
Example 5
Source Project: jorbs-spire-mod   Source File: JorbsModSettings.java    License: MIT License 5 votes vote down vote up
private static void unlockA20(AbstractPlayer.PlayerClass clz) {
    Prefs prefs = CardCrawlGame.characterManager.getCharacter(clz).getPrefs();
    if (prefs.getInteger(CharStat.WIN_COUNT, 0) == 0) {
        prefs.putInteger(CharStat.WIN_COUNT, 1);
    }
    prefs.putInteger(CharStat.LAST_ASCENSION_LEVEL, Settings.MAX_ASCENSION_LEVEL);
    prefs.putInteger(CharStat.ASCENSION_LEVEL, Settings.MAX_ASCENSION_LEVEL);
    prefs.flush();
}
 
Example 6
Source Project: jorbs-spire-mod   Source File: PlaySoundCommand.java    License: MIT License 5 votes vote down vote up
@Override
public void execute(String[] tokens, int depth) {
    String requiredSoundId = tokens.length > depth ? tokens[depth] : null;

    if (tokens.length > depth + 1) {
        try {
            float pitchAdjustment = Float.parseFloat(tokens[depth + 1]);
            CardCrawlGame.sound.playA(requiredSoundId, pitchAdjustment);
        } catch(Exception e) {
            return;
        }
    } else {
        CardCrawlGame.sound.play(requiredSoundId);
    }
}
 
Example 7
Source Project: jorbs-spire-mod   Source File: StaticPowerInfo.java    License: MIT License 5 votes vote down vote up
private <T extends AbstractPower> StaticPowerInfo(Class<T> powerClass) {
    CLASS = powerClass;
    ID = JorbsMod.makeID(powerClass.getSimpleName());
    PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings(ID);
    NAME = powerStrings.NAME;
    DESCRIPTIONS = powerStrings.DESCRIPTIONS;

    String imageFilenamePrefix = powerClass.getSimpleName().replace("Power", "");
    TEXTURE_84 = TextureLoader.getTexture(makePowerPath(imageFilenamePrefix + "_84.png"));
    TEXTURE_32 = TextureLoader.getTexture(makePowerPath(imageFilenamePrefix + "_32.png"));

    IMG_84 = new AtlasRegion(TEXTURE_84, 0, 0, 84, 84);
    IMG_32 = new AtlasRegion(TEXTURE_32, 0, 0, 32, 32);
}
 
Example 8
Source Project: jorbs-spire-mod   Source File: GradeChangeShineEffect.java    License: MIT License 5 votes vote down vote up
public void update() {
    if (duration / baseDuration < 0.6F && !clang1) {
        playSound.get();
        clang1 = true;
        clank(x - 80.0F * Settings.scale, y + 0.0F * Settings.scale);
        CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.HIGH, ScreenShake.ShakeDur.SHORT, false);
    }

    if (duration / baseDuration < 0.2F && !clang2) {
        if(playSoundEachClang) {
            playSound.get();
        }
        clang2 = true;
        clank(x + 90.0F * Settings.scale, y - 110.0F * Settings.scale);
        CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.HIGH, ScreenShake.ShakeDur.SHORT, false);
    }

    duration -= Gdx.graphics.getDeltaTime();
    if (duration < 0.0F) {
        if(playSoundEachClang) {
            playSound.get();
        }
        clank(this.x + 30.0F * Settings.scale, y + 120.0F * Settings.scale);
        isDone = true;
        CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.HIGH, ScreenShake.ShakeDur.SHORT, false);
    }

}
 
Example 9
Source Project: jorbs-spire-mod   Source File: RayOfFrostEffect.java    License: MIT License 5 votes vote down vote up
@Override
public void update() {
    CardCrawlGame.sound.play("ATTACK_MAGIC_SLOW_1", 0.7F);
    AbstractDungeon.effectsQueue.add(new BorderFlashEffect(Color.SKY.cpy()));
    AbstractDungeon.effectsQueue.add(new ScalingLaserEffect(
            source.hb.cX,
            source.hb.cY,
            target.hb.cX,
            target.hb.cY,
            Color.SKY.cpy(),
            Color.CYAN.cpy(),
            amount));
    isDone = true;
}
 
Example 10
Source Project: jorbs-spire-mod   Source File: EffectUtils.java    License: MIT License 5 votes vote down vote up
public static void showDestroyEffect(AbstractCard card) {
    CardCrawlGame.sound.play("CARD_EXHAUST");
    PurgeCardEffect purgeCardEffect = new PurgeCardEffect(card, (float) (Settings.WIDTH / 2), (float) (Settings.HEIGHT / 2));
    float duration = Settings.FAST_MODE ? 0.75F : purgeCardEffect.startingDuration;
    purgeCardEffect.duration = purgeCardEffect.startingDuration = duration;
    AbstractDungeon.topLevelEffects.add(purgeCardEffect);
    AbstractDungeon.actionManager.addToTop(new WaitAction(duration));
}
 
Example 11
Source Project: ModTheSpire   Source File: ModsScreen.java    License: MIT License 5 votes vote down vote up
public void open()
{
    button.show(PatchNotesScreen.TEXT[0]);
    scrollY = targetY = Settings.HEIGHT - 150.0F * Settings.scale;
    CardCrawlGame.mainMenuScreen.darken();
    CardCrawlGame.mainMenuScreen.screen = Enum.MODS_LIST;

    selectedMod = -1;

    scrollUpperBound = targetY + Math.max(0, Loader.MODINFOS.length - 15) * 45.0f * Settings.scale;
    scrollLowerBound = targetY;
}
 
Example 12
Source Project: ModTheSpire   Source File: ModsScreen.java    License: MIT License 5 votes vote down vote up
private void modBadge_onClick(Object badge)
{
    if (badge != null) {
        try {
            button.show("Close");
            ModBadge_onClick.invoke(badge);
            CardCrawlGame.mainMenuScreen.screen = Enum.MODS_LIST;
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
 
Example 13
Source Project: jorbs-spire-mod   Source File: VoiceoverMasterPatch.java    License: MIT License 4 votes vote down vote up
@SpirePrefixPatch
public static void Prefix(CardCrawlGame __this) {
    VoiceoverMaster.update();
}
 
Example 14
Source Project: jorbs-spire-mod   Source File: JorbsModSettings.java    License: MIT License 4 votes vote down vote up
public static ModPanel createSettingsPanel() {
    String[] MOD_SETTINGS_PANEL_TEXT = CardCrawlGame.languagePack.getUIString(makeID("ModSettingsPanel")).TEXT;
    ModPanel settingsPanel = new ModPanel();

    // Buttons will set the text on this when pressed
    ModLabel messageLabel = new ModLabel("",
            400.0F,
            300.0F,
            Color.GREEN,
            FontHelper.tipHeaderFont,
            settingsPanel,
            (label) -> {});
    settingsPanel.addUIElement(messageLabel);

    ModLabel voiceoverVolumeSliderLabel = new ModLabel(
            MOD_SETTINGS_PANEL_TEXT[0],
            400.0F,
            694.0F,
            Color.WHITE,
            FontHelper.tipHeaderFont,
            settingsPanel,
            (label) -> {});
    settingsPanel.addUIElement(voiceoverVolumeSliderLabel);
    ModSlider voiceoverVolumeSlider = new ModSlider(
            "",
            700.0F,
            700.0F,
            100,
            "%",
            settingsPanel,
            JorbsModSettings::onVoiceoverVolumeChange);
    voiceoverVolumeSlider.setValue(VoiceoverMaster.VOICEOVER_VOLUME);
    settingsPanel.addUIElement(voiceoverVolumeSlider);

    ModLabeledToggleButton voiceoverSubtitlesToggle = new ModLabeledToggleButton(
            MOD_SETTINGS_PANEL_TEXT[6],
    400.0F,
            640.0F,
            Color.WHITE,
            FontHelper.tipHeaderFont,
            isCullEnabled(),
            settingsPanel,
            (label) -> {},
            JorbsModSettings::onCullToggle);
    settingsPanel.addUIElement(voiceoverSubtitlesToggle);

    ModLabeledToggleButton cullToggle = new ModLabeledToggleButton(
            MOD_SETTINGS_PANEL_TEXT[1],
            400.0F,
            580.0F,
            Color.WHITE,
            FontHelper.tipHeaderFont,
            isCullEnabled(),
            settingsPanel,
            (label) -> {},
            JorbsModSettings::onCullToggle);
    settingsPanel.addUIElement(cullToggle);

    ModButton resetTipsButton = new ModButton(
            370.0F,
            460.0F,
            settingsPanel,
            (b) -> {
                JorbsModTipTracker.reset();
                messageLabel.text = MOD_SETTINGS_PANEL_TEXT[3];
            }
    );
    settingsPanel.addUIElement(resetTipsButton);
    ModLabel resetTipsLabel = new ModLabel(
            MOD_SETTINGS_PANEL_TEXT[2],
            500.0F,
            515.0F,
            Color.WHITE,
            FontHelper.tipHeaderFont,
            settingsPanel,
            (label) -> {});
    settingsPanel.addUIElement(resetTipsLabel);

    ModButton unlockA20Button = new ModButton(
            370.0F,
            370.0F,
            settingsPanel,
            (b) -> {
                unlockA20(Wanderer.Enums.WANDERER);
                unlockA20(Cull.Enums.CULL);
                messageLabel.text = MOD_SETTINGS_PANEL_TEXT[5];
            }
    );
    settingsPanel.addUIElement(unlockA20Button);
    ModLabel unlockA20Label = new ModLabel(
            MOD_SETTINGS_PANEL_TEXT[4],
            500.0F,
            425.0F,
            Color.WHITE,
            FontHelper.tipHeaderFont,
            settingsPanel,
            (label) -> {});
    settingsPanel.addUIElement(unlockA20Label);

    return settingsPanel;
}
 
Example 15
Source Project: jorbs-spire-mod   Source File: SnapAction.java    License: MIT License 4 votes vote down vote up
public void update() {
    if (MemoryManager.forPlayer(target) == null || target.hasPower(SnappedPower.POWER_ID)) {
        isDone = true;
        return;
    }
    if (CombatUtils.isCombatBasicallyVictory()) {
        isDone = true;
        return;
    }

    int numClarities = MemoryManager.forPlayer(target).countCurrentClarities();
    int enemyDamage = ENEMY_DAMAGE_PER_CLARITY * numClarities;
    int targetDamage = PLAYER_DAMAGE_PER_CLARITY * numClarities;

    // addToTop is important for Trauma effect ordering
    // Note that the group of addToTops actually executes in reverse order
    AbstractDungeon.actionManager.addToTop(
            new ApplyPowerAction(target, null, new SnappedPower(target)));
    AbstractDungeon.actionManager.addToTop(
            new LoseHPAction(target, target, targetDamage, AttackEffect.BLUNT_LIGHT));
    AbstractDungeon.actionManager.addToTop(
            new DamageAllEnemiesAction(target, DamageInfo.createDamageMatrix(enemyDamage, true), DamageInfo.DamageType.THORNS, AttackEffect.BLUNT_LIGHT));

    AbstractDungeon.actionManager.addToTop(new VFXAction(new BorderFlashEffect(Color.DARK_GRAY.cpy())));

    CardCrawlGame.sound.playA("MONSTER_SNECKO_GLARE", -0.3F);

    if (target instanceof Wanderer) {
        ((Wanderer) target).startSnapAnimation();
    }

    MemoryManager.forPlayer(target).snap();

    if (isEndOfTurn) {
        AbstractDungeon.actionManager.addToBottom(new ApplyPowerAction(target, target,
                new ExhumeAtStartOfTurnPower(target, SelfExhumeFields.selfExhumeOnSnap::get)));
    } else {
        AbstractDungeon.actionManager.addToBottom(new ExhumeCardsAction(SelfExhumeFields.selfExhumeOnSnap::get));
    }

    isDone = true;
}
 
Example 16
Source Project: jorbs-spire-mod   Source File: PlaySoundCommand.java    License: MIT License 4 votes vote down vote up
@Override
public ArrayList<String> extraOptions(String[] tokens, int depth) {
    HashMap<String, Sfx> map = ReflectionUtils.getPrivateField(CardCrawlGame.sound, SoundMaster.class, "map");
    return map.keySet().stream().sorted().collect(Collectors.toCollection(ArrayList::new));
}
 
Example 17
Source Project: jorbs-spire-mod   Source File: BurningPower.java    License: MIT License 4 votes vote down vote up
@Override
public void playApplyPowerSfx() {
    CardCrawlGame.sound.play("ATTACK_FIRE", 0.05F);
}
 
Example 18
Source Project: jorbs-spire-mod   Source File: Cull.java    License: MIT License 4 votes vote down vote up
private static void registerVoiceOver(String key, String baseName) {
    baseName = baseName.replace(' ', '_');
    String fileName = "cull/" + baseName + ".ogg";
    String subtitle = CardCrawlGame.languagePack.getUIString(makeID("cull:voiceover:"+baseName)).TEXT[0];
    VoiceoverMaster.register(Cull.Enums.CULL, key, fileName, subtitle);
}
 
Example 19
Source Project: jorbs-spire-mod   Source File: Cull.java    License: MIT License 4 votes vote down vote up
@Override
public void doCharSelectScreenSelectEffect() {
    CardCrawlGame.sound.playA("BLOOD_SPLAT", 0.8f);
    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.LOW, ScreenShake.ShakeDur.SHORT, false);
}
 
Example 20
Source Project: jorbs-spire-mod   Source File: Wanderer.java    License: MIT License 4 votes vote down vote up
private static void registerVoiceOver(String key, String baseName) {
    baseName = baseName.replace(' ', '_');
    String fileName = "wanderer/" + baseName + ".ogg";
    String subtitle = CardCrawlGame.languagePack.getUIString(makeID("wanderer:voiceover:"+baseName)).TEXT[0];
    VoiceoverMaster.register(Wanderer.Enums.WANDERER, key, fileName, subtitle);
}
 
Example 21
Source Project: jorbs-spire-mod   Source File: Wanderer.java    License: MIT License 4 votes vote down vote up
@Override
public void doCharSelectScreenSelectEffect() {
    CardCrawlGame.sound.playA("ATTACK_FIRE", 0.8f);
    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.LOW, ScreenShake.ShakeDur.SHORT, false);
}
 
Example 22
Source Project: jorbs-spire-mod   Source File: DeckOfManyThingsEvent.java    License: MIT License 4 votes vote down vote up
@Override
protected void buttonEffect(int i) { // This is the event:
    switch (screenNum) {
        case 0: // While you are on screen number 0 (The starting screen)
            switch (i) {
                case 0: // If you press button the first button (Button at index 0), in this case: Inspiration.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[1]); // Update the text of the event
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]); // 1. Change the first button to the [Leave] button
                    this.imageEventText.clearRemainingOptions(); // 2. and remove all others
                    screenNum = 1; // Screen set the screen number to 1. Once we exit the switch (i) statement,
                    // we'll still continue the switch (screenNum) statement. It'll find screen 1 and do it's actions
                    // (in our case, that's the final screen, but you can chain as many as you want like that)

                    AbstractRelic relicToAdd = RelicLibrary.starterList.get(AbstractDungeon.relicRng.random(RelicLibrary.starterList.size() - 1)).makeCopy();
                    // Get a random starting relic

                    AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2), relicToAdd);


                    break; // Onto screen 1 we go.
                case 1: // If you press button the second button (Button at index 1), in this case: Deinal

                    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.MED, ScreenShake.ShakeDur.MED, false);
                    // Shake the screen
                    CardCrawlGame.sound.play("BLUNT_FAST");  // Play a hit sound
                    AbstractDungeon.player.decreaseMaxHealth(healthdamage); // Lose max HP
                    if (CardGroup.getGroupWithoutBottledCards(AbstractDungeon.player.masterDeck.getPurgeableCards()).size() > 0) {
                        // If you have cards you can remove - remove a card
                        AbstractDungeon.gridSelectScreen.open(
                                CardGroup.getGroupWithoutBottledCards(
                                        AbstractDungeon.player.masterDeck.getPurgeableCards()),
                                1, OPTIONS[6], false, false, false, true);
                    }

                    this.imageEventText.updateBodyText(DESCRIPTIONS[2]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;

                    // Same as before. A note here is that you can also do
                    // imageEventText.clearAllDialogs();
                    // imageEventText.setDialogOption(OPTIONS[1]);
                    // imageEventText.setDialogOption(OPTIONS[4]);
                    // (etc.)
                    // And that would also just set them into slot 0, 1, 2... in order, just like what we do in the very beginning

                    break; // Onto screen 1 we go.
                case 2: // If you press button the third button (Button at index 2), in this case: Acceptance

                    AbstractCard c = new Apotheosis().makeCopy();
                    AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c, (float) (Settings.WIDTH / 2), (float) (Settings.HEIGHT / 2)));

                    this.imageEventText.updateBodyText(DESCRIPTIONS[3]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
                case 3: // If you press button the fourth button (Button at index 3), in this case: TOUCH
                    imageEventText.loadImage("stsjorbsmodResources/images/events/IdentityCrisisEvent2.png"); // Change the shown image
                    // Other than that, this option doesn't do anything special.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[4]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
            }
            break;
        case 1: // Welcome to screenNum = 1;
            switch (i) {
                case 0: // If you press the first (and this should be the only) button,
                    openMap(); // You'll open the map and end the event.
                    break;
            }
            break;
    }
}
 
Example 23
Source Project: jorbs-spire-mod   Source File: Voiceover.java    License: MIT License 4 votes vote down vote up
public void update() {
    this.duration -= Gdx.graphics.getDeltaTime();

    switch (state) {
        case INITIAL_DELAY:
            if (this.duration <= 0.0F) {
                this.state = State.DAMPENING_MASTER_VOLUME;
                this.duration = Math.max(dampeningDuration, 0.01F);
            }
            break;

        case DAMPENING_MASTER_VOLUME:
            float dampenProgress = dampeningDuration <= 0.0F ? 1.0F : MathUtils.clamp(1 - duration / dampeningDuration, 0F, 1F);
            VoiceoverMaster.MASTER_DAMPENING_FACTOR = MathUtils.lerp(1.0F, DAMPENING_FACTOR, dampenProgress);
            CardCrawlGame.music.updateVolume();

            if (this.duration <= 0.0F) {
                if (VoiceoverMaster.VOICEOVER_SUBTITLES_ENABLED) {
                    AbstractDungeon.effectList.add(new SpeechBubble(source.dialogX, source.dialogY, PLAY_DURATION, subtitle, source.isPlayer));
                }
                sfx.play(Settings.MASTER_VOLUME * VoiceoverMaster.VOICEOVER_VOLUME * VoiceoverMaster.VOICEOVER_VOLUME_MODIFIER);

                this.state = State.PLAYING_SFX;
                this.duration = PLAY_DURATION;
            }
            break;

        case PLAYING_SFX:
            if (this.duration <= 0.0F) {
                this.state = State.RESTORING_MASTER_VOLUME;
                this.duration = DAMPENING_RESTORE_DURATION;
            }
            break;

        case RESTORING_MASTER_VOLUME:
            float restoreProgress = MathUtils.clamp(1 - duration / DAMPENING_RESTORE_DURATION, 0F, 1F);
            VoiceoverMaster.MASTER_DAMPENING_FACTOR = MathUtils.lerp(DAMPENING_FACTOR, 1.0F, restoreProgress);
            CardCrawlGame.music.updateVolume();

            if (this.duration <= 0.0F) {
                VoiceoverMaster.MASTER_DAMPENING_FACTOR = 1.0F;
                this.state = State.DONE;
            }
            break;
    }
}
 
Example 24
Source Project: StSLib   Source File: PlayerDamage.java    License: MIT License 4 votes vote down vote up
@SpireInsertPatch(
        locator=Locator.class,
        localvars={"damageAmount", "hadBlock"}
)
public static void Insert(AbstractCreature __instance, DamageInfo info, @ByRef int[] damageAmount, @ByRef boolean[] hadBlock)
{
    hadTempHP = false;
    if (damageAmount[0] <= 0) {
        return;
    }

    int temporaryHealth = TempHPField.tempHp.get(__instance);
    if (temporaryHealth > 0) {
        for (AbstractPower power : __instance.powers) {
            if (power instanceof OnLoseTempHpPower) {
                damageAmount[0] = ((OnLoseTempHpPower) power).onLoseTempHp(info, damageAmount[0]);
            }
        }
        if (__instance instanceof AbstractPlayer) {
            for (AbstractRelic relic : ((AbstractPlayer) __instance).relics) {
                if (relic instanceof OnLoseTempHpRelic) {
                    damageAmount[0] = ((OnLoseTempHpRelic) relic).onLoseTempHp(info, damageAmount[0]);
                }
            }
        }

        hadTempHP = true;
        for (int i = 0; i < 18; ++i) {
            AbstractDungeon.effectsQueue.add(new DamageImpactLineEffect(__instance.hb.cX, __instance.hb.cY));
        }
        CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.MED, ScreenShake.ShakeDur.SHORT, false);
        if (temporaryHealth >= damageAmount[0]) {
            temporaryHealth -= damageAmount[0];
            AbstractDungeon.effectsQueue.add(new TempDamageNumberEffect(__instance, __instance.hb.cX, __instance.hb.cY, damageAmount[0]));
            //AbstractDungeon.effectList.add(new BlockedWordEffect(__instance, __instance.hb.cX, __instance.hb.cY, "Absorbed"));
            damageAmount[0] = 0;
        } else {
            damageAmount[0] -= temporaryHealth;
            AbstractDungeon.effectsQueue.add(new TempDamageNumberEffect(__instance, __instance.hb.cX, __instance.hb.cY, temporaryHealth));
            temporaryHealth = 0;
        }

        TempHPField.tempHp.set(__instance, temporaryHealth);
    }
}
 
Example 25
Source Project: StSLib   Source File: BranchingUpgradesPatch.java    License: MIT License 4 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, SpriteBatch sb, AbstractCard ___card) {
    if (___card instanceof BranchingUpgradesCard) {
        if (uiStrings == null) {
            uiStrings = CardCrawlGame.languagePack.getUIString("stslib:SingleCardViewPopup");
        }

        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);

        sb.setColor(Color.WHITE);
        sb.draw(
                ImageMaster.CHECKBOX,
                branchUpgradeHb.cX - 80f * Settings.scale - 32f,
                branchUpgradeHb.cY - 32f,
                32f, 32f,
                64f, 64f,
                Settings.scale, Settings.scale,
                0f,
                0, 0,
                64, 64,
                false, false
        );
        Color fontColor = Settings.GOLD_COLOR;
        if (branchUpgradeHb.hovered) {
            fontColor = Settings.BLUE_TEXT_COLOR;
        }
        FontHelper.renderFont(
                sb,
                FontHelper.cardTitleFont,
                uiStrings.TEXT[0],
                branchUpgradeHb.cX - 45f * Settings.scale,
                branchUpgradeHb.cY + 10f * Settings.scale,
                fontColor
        );
        if (BranchUpgradeButton.isViewingBranchUpgrade.get(__instance)) {
            sb.setColor(Color.WHITE);
            sb.draw(
                    ImageMaster.TICK,
                    branchUpgradeHb.cX - 80f * Settings.scale - 32f,
                    branchUpgradeHb.cY - 32f,
                    32f, 32f,
                    64f, 64f,
                    Settings.scale, Settings.scale,
                    0f,
                    0, 0,
                    64, 64,
                    false, false
            );
        }
        BranchUpgradeButton.branchUpgradeHb.get(__instance).render(sb);
    }
}
 
Example 26
Source Project: FruityMod-StS   Source File: TheTranquil.java    License: MIT License 4 votes vote down vote up
@Override
public void doCharSelectScreenSelectEffect() {
    CardCrawlGame.sound.playA("UNLOCK_PING", MathUtils.random(-0.2F, 0.2F));
    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.LOW, ScreenShake.ShakeDur.SHORT,
            false);
}
 
Example 27
Source Project: FruityMod-StS   Source File: TheSeeker.java    License: MIT License 4 votes vote down vote up
@Override
public void doCharSelectScreenSelectEffect() {
    CardCrawlGame.sound.playA("UNLOCK_PING", MathUtils.random(-0.2F, 0.2F));
    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.LOW, ScreenShake.ShakeDur.SHORT,
            false);
}
 
Example 28
Source Project: StS-DefaultModBase   Source File: DefaultOrb.java    License: MIT License 4 votes vote down vote up
@Override
public void playChannelSFX() { // When you channel this orb, the ATTACK_FIRE effect plays ("Fwoom").
    CardCrawlGame.sound.play("ATTACK_FIRE", 0.1f);
}
 
Example 29
Source Project: StS-DefaultModBase   Source File: TheDefault.java    License: MIT License 4 votes vote down vote up
@Override
public void doCharSelectScreenSelectEffect() {
    CardCrawlGame.sound.playA("ATTACK_DAGGER_1", 1.25f); // Sound Effect
    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.LOW, ScreenShake.ShakeDur.SHORT,
            false); // Screen Effect
}
 
Example 30
Source Project: StS-DefaultModBase   Source File: IdentityCrisisEvent.java    License: MIT License 4 votes vote down vote up
@Override
protected void buttonEffect(int i) { // This is the event:
    switch (screenNum) {
        case 0: // While you are on screen number 0 (The starting screen)
            switch (i) {
                case 0: // If you press button the first button (Button at index 0), in this case: Inspiration.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[1]); // Update the text of the event
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]); // 1. Change the first button to the [Leave] button
                    this.imageEventText.clearRemainingOptions(); // 2. and remove all others
                    screenNum = 1; // Screen set the screen number to 1. Once we exit the switch (i) statement,
                    // we'll still continue the switch (screenNum) statement. It'll find screen 1 and do it's actions
                    // (in our case, that's the final screen, but you can chain as many as you want like that)

                    AbstractRelic relicToAdd = RelicLibrary.starterList.get(AbstractDungeon.relicRng.random(RelicLibrary.starterList.size() - 1)).makeCopy();
                    // Get a random starting relic

                    AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2), relicToAdd);


                    break; // Onto screen 1 we go.
                case 1: // If you press button the second button (Button at index 1), in this case: Deinal

                    CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.MED, ScreenShake.ShakeDur.MED, false);
                    // Shake the screen
                    CardCrawlGame.sound.play("BLUNT_FAST");  // Play a hit sound
                    AbstractDungeon.player.decreaseMaxHealth(healthdamage); // Lose max HP
                    if (CardGroup.getGroupWithoutBottledCards(AbstractDungeon.player.masterDeck.getPurgeableCards()).size() > 0) {
                        // If you have cards you can remove - remove a card
                        AbstractDungeon.gridSelectScreen.open(
                                CardGroup.getGroupWithoutBottledCards(
                                        AbstractDungeon.player.masterDeck.getPurgeableCards()),
                                1, OPTIONS[6], false, false, false, true);
                    }

                    this.imageEventText.updateBodyText(DESCRIPTIONS[2]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;

                    // Same as before. A note here is that you can also do
                    // imageEventText.clearAllDialogs();
                    // imageEventText.setDialogOption(OPTIONS[1]);
                    // imageEventText.setDialogOption(OPTIONS[4]);
                    // (etc.)
                    // And that would also just set them into slot 0, 1, 2... in order, just like what we do in the very beginning

                    break; // Onto screen 1 we go.
                case 2: // If you press button the third button (Button at index 2), in this case: Acceptance

                    AbstractCard c = new Apotheosis().makeCopy();
                    AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c, (float) (Settings.WIDTH / 2), (float) (Settings.HEIGHT / 2)));

                    this.imageEventText.updateBodyText(DESCRIPTIONS[3]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
                case 3: // If you press button the fourth button (Button at index 3), in this case: TOUCH
                    imageEventText.loadImage("theDefaultResources/images/events/IdentityCrisisEvent2.png"); // Change the shown image
                    // Other than that, this option doesn't do anything special.
                    this.imageEventText.updateBodyText(DESCRIPTIONS[4]);
                    this.imageEventText.updateDialogOption(0, OPTIONS[5]);
                    this.imageEventText.clearRemainingOptions();
                    screenNum = 1;
                    break;
            }
            break;
        case 1: // Welcome to screenNum = 1;
            switch (i) {
                case 0: // If you press the first (and this should be the only) button,
                    openMap(); // You'll open the map and end the event.
                    break;
            }
            break;
    }
}