You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.8 KiB
102 lines
2.8 KiB
package scenes
|
|
|
|
import korlibs.event.*
|
|
import korlibs.korge.input.*
|
|
import korlibs.korge.scene.*
|
|
import korlibs.korge.view.*
|
|
import korlibs.time.*
|
|
import model.*
|
|
import views.*
|
|
import kotlin.math.*
|
|
|
|
class BattleScene : Scene() {
|
|
private val battle = Battle(HistoryEntry.Load(
|
|
timestamp = TimeSpan.ZERO,
|
|
battlers = listOf(
|
|
Battler.Saved(
|
|
id = Battler.Id(0),
|
|
name = "Us",
|
|
composure = 150.0,
|
|
health = 150.0,
|
|
maxHealth = 200.0,
|
|
energy = 0.0,
|
|
stamina = 150.0,
|
|
maxStamina = 300.0,
|
|
|
|
shaken = false,
|
|
shakenTimes = 0,
|
|
composurePausedUntil = TimeSpan.ZERO,
|
|
energyPausedUntil = TimeSpan.ZERO,
|
|
),
|
|
Battler.Saved(
|
|
id = Battler.Id(1),
|
|
name = "Them",
|
|
composure = 150.0,
|
|
health = 150.0,
|
|
maxHealth = 200.0,
|
|
energy = 0.0,
|
|
stamina = 150.0,
|
|
maxStamina = 300.0,
|
|
|
|
shaken = false,
|
|
shakenTimes = 0,
|
|
composurePausedUntil = TimeSpan.ZERO,
|
|
energyPausedUntil = TimeSpan.ZERO,
|
|
)
|
|
),
|
|
pendingEffects = listOf()
|
|
))
|
|
|
|
override suspend fun SContainer.sceneInit() {
|
|
|
|
val usView = BattlerView(battle.battlers[0])
|
|
usView.xy(sceneWidth - (usView.width + 5), sceneHeight - (usView.height + 5))
|
|
addChild(usView)
|
|
|
|
val themView = BattlerView(battle.battlers[1])
|
|
themView.xy(5, 5)
|
|
addChild(themView)
|
|
|
|
var time = TimeSpan.ZERO
|
|
var fractional = 0.0
|
|
addUpdater {
|
|
val step = it.milliseconds + fractional
|
|
val whole = floor(step)
|
|
fractional = step - whole
|
|
time += TimeSpan(whole)
|
|
battle.setTimeTo(time)
|
|
}
|
|
|
|
keys {
|
|
justDown(Key.R) {
|
|
time = TimeSpan.ZERO
|
|
fractional = 0.0
|
|
battle.setTimeTo(time)
|
|
}
|
|
|
|
justDown(Key.F) {
|
|
time += TimeSpan(10_000.0)
|
|
battle.setTimeTo(time)
|
|
}
|
|
|
|
justDown(Key.V) {
|
|
battle.injectAction(MultiHitAction(
|
|
timestamp = time,
|
|
target = Battler.Id(1),
|
|
hits = 5,
|
|
firstHitDelay = TimeSpan(500.0),
|
|
subsequentHitDelay = TimeSpan(100.0),
|
|
damage = 5.0,
|
|
))
|
|
}
|
|
}
|
|
}
|
|
|
|
override suspend fun SContainer.sceneMain() {
|
|
// @TODO: Main scene code here (after sceneInit)
|
|
}
|
|
|
|
override suspend fun sceneAfterInit() {
|
|
super.sceneAfterInit()
|
|
}
|
|
}
|
|
|