-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vfx to collecting quirk and meteoric shower (#210)
* initial commit * code cleanup * code cleanup * fix javavdoc comment
- Loading branch information
Showing
7 changed files
with
417 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package marisa.fx | ||
|
||
import com.badlogic.gdx.Gdx | ||
import com.badlogic.gdx.graphics.Color | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch | ||
import com.megacrit.cardcrawl.actions.animations.VFXAction | ||
import com.megacrit.cardcrawl.core.CardCrawlGame.screenShake | ||
import com.megacrit.cardcrawl.core.CardCrawlGame.sound | ||
import com.megacrit.cardcrawl.core.Settings | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon.player | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon.effectsQueue | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon.getMonsters | ||
import com.megacrit.cardcrawl.helpers.ScreenShake | ||
import com.megacrit.cardcrawl.monsters.AbstractMonster | ||
import com.megacrit.cardcrawl.relics.AbstractRelic | ||
import com.megacrit.cardcrawl.vfx.BorderLongFlashEffect | ||
import marisa.fx.lib.FireProjectileEffect.Companion.CollectingQuirkProjectile | ||
import marisa.fx.lib.SOUND_EFFECT_KEY | ||
import marisa.fx.lib.VfxGameEffect | ||
|
||
private const val MAX_VFX_PROJECTILES = 50 | ||
|
||
class CollectingQuirkEffect(private val flipped: Boolean, private val monsterX: Float) : VfxGameEffect() { | ||
private val relics: List<AbstractRelic> = player.relics | ||
private var relicCounter = 0 | ||
|
||
init { | ||
duration = if (Settings.FAST_MODE) 2.0f else 0.5f | ||
} | ||
|
||
override fun update() { | ||
if (isFirstUpdate()) { start() } | ||
|
||
duration -= Gdx.graphics.deltaTime | ||
timer -= Gdx.graphics.deltaTime | ||
if (relicCounter < relics.size.coerceAtMost(MAX_VFX_PROJECTILES) && timer < 0.0f) { | ||
timer += 0.03f | ||
effectsQueue.add(CollectingQuirkProjectile(relics[relicCounter].img, relics.size, flipped, monsterX)) | ||
relicCounter += 1 | ||
} | ||
if (duration < 0.0f) { | ||
isDone = true | ||
} | ||
} | ||
|
||
override fun start() { | ||
sound.playA(SOUND_EFFECT_KEY, -0.25f - relics.size.toFloat() / 200.0f) | ||
screenShake.shake(ScreenShake.ShakeIntensity.HIGH, ScreenShake.ShakeDur.MED, true) | ||
effectsQueue.add(BorderLongFlashEffect(Color.SKY)) | ||
hasStarted = true | ||
} | ||
|
||
override fun render(spriteBatch: SpriteBatch) {} | ||
override fun dispose() {} | ||
|
||
companion object { | ||
fun toVfx(): VFXAction { | ||
val duration = if (Settings.FAST_MODE) 0.5f else 1.0f | ||
val monsters = getMonsters() | ||
val avgX = monsters.monsters.stream() | ||
.mapToDouble { m: AbstractMonster -> m.drawX.toDouble() }.average() | ||
.orElse(Settings.WIDTH.toDouble()) | ||
.toFloat() | ||
return VFXAction(CollectingQuirkEffect(monsters.shouldFlipVfx(), avgX), duration) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package marisa.fx | ||
|
||
import com.badlogic.gdx.Gdx | ||
import com.badlogic.gdx.graphics.Color | ||
import com.badlogic.gdx.graphics.Texture | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch | ||
import com.megacrit.cardcrawl.actions.animations.VFXAction | ||
import com.megacrit.cardcrawl.core.CardCrawlGame.screenShake | ||
import com.megacrit.cardcrawl.core.CardCrawlGame.sound | ||
import com.megacrit.cardcrawl.core.Settings | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon.effectsQueue | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon.getMonsters | ||
import com.megacrit.cardcrawl.helpers.ImageMaster | ||
import com.megacrit.cardcrawl.helpers.ScreenShake | ||
import com.megacrit.cardcrawl.monsters.AbstractMonster | ||
import com.megacrit.cardcrawl.vfx.BorderLongFlashEffect | ||
import marisa.fx.lib.FireProjectileEffect.Companion.MeteoricShowerProjectile | ||
import marisa.fx.lib.SOUND_EFFECT_KEY | ||
import marisa.fx.lib.VfxGameEffect | ||
|
||
private const val MAX_VFX_PROJECTILES = 50 | ||
|
||
class MeteoricShowerEffect( | ||
private val numHits: Int, | ||
private val flipped: Boolean, | ||
private val monsterX: Float | ||
) : VfxGameEffect() { | ||
private var starCounter = 0 | ||
|
||
init { | ||
duration = if (Settings.FAST_MODE) 2.0f else 0.5f | ||
} | ||
|
||
override fun update() { | ||
if (isFirstUpdate()) { start() } | ||
|
||
duration -= Gdx.graphics.deltaTime | ||
timer -= Gdx.graphics.deltaTime | ||
if (starCounter < numHits.coerceAtMost(MAX_VFX_PROJECTILES) && timer < 0.0f) { | ||
timer += 0.03f | ||
effectsQueue.add(MeteoricShowerProjectile(numHits, flipped, monsterX)) | ||
starCounter += 1 | ||
} | ||
if (duration < 0.0f) { | ||
isDone = true | ||
} | ||
} | ||
|
||
override fun start() { | ||
sound.playA(SOUND_EFFECT_KEY, -0.25f - numHits.toFloat() / 200.0f) | ||
screenShake.shake(ScreenShake.ShakeIntensity.HIGH, ScreenShake.ShakeDur.MED, true) | ||
effectsQueue.add(BorderLongFlashEffect(Color.SKY)) | ||
hasStarted = true | ||
} | ||
|
||
override fun render(spriteBatch: SpriteBatch) {} | ||
override fun dispose() {} | ||
|
||
companion object { | ||
private const val METEORIC_SHOWER_PROJECTILE_TEXPATH = "img/vfx/star_128.png" | ||
@JvmField | ||
val METEORIC_SHOWER_PROJECTILE: Texture = ImageMaster.loadImage(METEORIC_SHOWER_PROJECTILE_TEXPATH) | ||
|
||
fun toVfx(numHits: Int): VFXAction { | ||
val duration = if (Settings.FAST_MODE) 0.5f else 1.0f | ||
val monsters = getMonsters() | ||
val avgX = monsters.monsters.stream() | ||
.mapToDouble { m: AbstractMonster -> m.drawX.toDouble() }.average() | ||
.orElse(Settings.WIDTH.toDouble()) | ||
.toFloat() | ||
return VFXAction(MeteoricShowerEffect(numHits, monsters.shouldFlipVfx(), avgX), duration) | ||
} | ||
} | ||
} |
Oops, something went wrong.