Created a builder for making maps
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package fmon.battle
|
||||
|
||||
import java.io._
|
||||
import java.util.concurrent.locks.{Condition, ReentrantLock}
|
||||
|
||||
import javafx.application.Platform
|
||||
@@ -23,6 +24,7 @@ import scalafx.scene.transform.Rotate
|
||||
import scalafx.util.Duration
|
||||
|
||||
import fmon.battle.msg._
|
||||
import fmon.draw._
|
||||
import fmon.stat._
|
||||
import fmon.stat.Statistic._
|
||||
|
||||
@@ -78,6 +80,7 @@ class BattleUI extends SignalConsumer {
|
||||
lock.lock()
|
||||
try {
|
||||
msg match {
|
||||
case AnimateMsg(ani, target) => playAnimation(ani, target)
|
||||
case Message(text) => messages.text = s"${messages.text()}${text}\n"
|
||||
case DamageMsg(dmg, target, element) => playDamage(dmg, target, element)
|
||||
}
|
||||
@@ -93,6 +96,29 @@ class BattleUI extends SignalConsumer {
|
||||
|
||||
}
|
||||
|
||||
private def playAnimation(aniname: String, target: Monster): Unit = {
|
||||
numPlaying += 1
|
||||
def helper = {
|
||||
val animation = AnimationToken(aniname).load(new File(raw"C:\Users\dalyj\Documents\Design\Images\TimmahLexusX reduced\Reduced Animations"))
|
||||
val imgView = new ImageView
|
||||
animationPane.children += imgView
|
||||
|
||||
val center = findCenter(target)
|
||||
imgView.translateX = center.x - 96 // TODO : Compute result
|
||||
imgView.translateY = center.y - 96
|
||||
|
||||
val duration = Duration(animation.frames.size * 50)
|
||||
val transition = new SpriteAnimation(imgView, animation, duration)
|
||||
transition.onFinished = handle{
|
||||
animationPane.children -= imgView
|
||||
finishPlay()
|
||||
}
|
||||
transition.play()
|
||||
}
|
||||
val task = Task(helper)
|
||||
Platform.runLater(task)
|
||||
}
|
||||
|
||||
private def playDamage(damage: Int, target: Monster, element: Element): Unit = {
|
||||
numPlaying += 1
|
||||
def helper = {
|
||||
|
||||
25
FakeMon/src/fmon/battle/msg/AnimateMsg.scala
Normal file
25
FakeMon/src/fmon/battle/msg/AnimateMsg.scala
Normal file
@@ -0,0 +1,25 @@
|
||||
package fmon.battle.msg
|
||||
|
||||
import fmon.stat.{Element, Monster}
|
||||
|
||||
case class AnimateMsg(val animation: String, target: Monster) extends Signal {
|
||||
|
||||
}
|
||||
|
||||
object AnimateMsg {
|
||||
def apply(element: Element, target: Monster): AnimateMsg = {
|
||||
val ani = element.name match {
|
||||
case "Poison" => "Poison Bubble"
|
||||
case "Electric" => "Lightning Lines"
|
||||
case "Fire" => "Rising Fire 1"
|
||||
case "Rock" => "Rock Blast"
|
||||
case "Ground" => "Stalagmites"
|
||||
case "Water" => "Rain"
|
||||
case "Flying" => "Gale"
|
||||
case "Ice" => "Glacier"
|
||||
case "Fairy" => "Light and Glass"
|
||||
case _ => "Buster"
|
||||
}
|
||||
AnimateMsg(ani, target)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user