fixes, bits and pieces, changes in ID referencing, terrain and wall takes damage, working test pickaxe, and a new issue

This commit is contained in:
Song Minjae
2017-04-17 02:18:52 +09:00
parent 6087072d3d
commit f2ae2d9449
40 changed files with 502 additions and 249 deletions

View File

@@ -1,6 +1,9 @@
package net.torvald.terrarum.ui
import net.torvald.point.Point2d
import net.torvald.terrarum.Millisec
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.roundInt
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Input
@@ -57,21 +60,86 @@ interface UICanvas {
fun doOpeningFade(handler: UIHandler?, openCloseTime: Int) {
handler!!.opacity = handler.openCloseCounter.toFloat() / openCloseTime
}
fun doClosingFade(handler: UIHandler?, openCloseTime: Int) {
handler!!.opacity = (openCloseTime - handler.openCloseCounter.toFloat()) / openCloseTime
}
fun endOpeningFade(handler: UIHandler?) {
handler!!.opacity = 1f
}
fun endClosingFade(handler: UIHandler?) {
handler!!.opacity = 0f
}
// TODO add drawer slide in/out (quadratic)
fun doOpeningPopOut(handler: UIHandler?, openCloseTime: Int, position: Position) {
when (position) {
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
-handler.UI.width.toFloat(),
0f
).roundInt()
Position.TOP -> handler!!.posY = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
-handler.UI.height.toFloat(),
0f
).roundInt()
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
Terrarum.WIDTH.toFloat(),
Terrarum.WIDTH - handler.UI.width.toFloat()
).roundInt()
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
Terrarum.HEIGHT.toFloat(),
Terrarum.HEIGHT - handler.UI.height.toFloat()
).roundInt()
}
}
fun doClosingPopOut(handler: UIHandler?, openCloseTime: Int, position: Position) {
when (position) {
Position.LEFT -> handler!!.posX = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
0f,
-handler.UI.width.toFloat()
).roundInt()
Position.TOP -> handler!!.posY = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
0f,
-handler.UI.height.toFloat()
).roundInt()
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
Terrarum.WIDTH - handler.UI.width.toFloat(),
Terrarum.WIDTH.toFloat()
).roundInt()
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
handler.openCloseCounter.toFloat() / openCloseTime,
Terrarum.HEIGHT - handler.UI.height.toFloat(),
Terrarum.HEIGHT.toFloat()
).roundInt()
}
}
fun endOpeningPopOut(handler: UIHandler?, position: Position) {
when (position) {
Position.LEFT -> handler!!.posX = 0
Position.TOP -> handler!!.posY = 0
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH - handler.UI.width
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT - handler.UI.height
}
}
fun endClosingPopOut(handler: UIHandler?, position: Position) {
when (position) {
Position.LEFT -> handler!!.posX = -handler.UI.width
Position.TOP -> handler!!.posY = -handler.UI.height
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT
}
}
// TODO add blackboard take in/out (sinusoidal)
enum class Position {
LEFT, RIGHT, TOP, BOTTOM
}
}
}

View File

@@ -158,7 +158,7 @@ class UIInventory(
// filter items
inventory?.forEach {
if (it.item.category == filter || filter == "__all__")
if (it.item.inventoryCategory == filter || filter == "__all__")
inventorySortList.add(it)
}
@@ -295,27 +295,20 @@ class UIInventory(
}
override fun doOpening(gc: GameContainer, delta: Int) {
handler!!.posX = Movement.fastPullOut(
handler!!.openCloseCounter.toFloat() / openCloseTime,
-width.toFloat(),
0f
).roundInt()
UICanvas.doOpeningPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
}
override fun doClosing(gc: GameContainer, delta: Int) {
handler!!.posX = Movement.fastPullOut(
handler!!.openCloseCounter.toFloat() / openCloseTime,
0f,
-width.toFloat()
).roundInt()
UICanvas.doClosingPopOut(handler, openCloseTime, UICanvas.Companion.Position.LEFT)
}
override fun endOpening(gc: GameContainer, delta: Int) {
handler!!.posX = 0
UICanvas.endOpeningPopOut(handler, UICanvas.Companion.Position.LEFT)
}
override fun endClosing(gc: GameContainer, delta: Int) {
handler!!.posX = -width
UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT)
}
override fun keyPressed(key: Int, c: Char) {