Skip to content

Commit

Permalink
Minor tweaks to dropcatch
Browse files Browse the repository at this point in the history
  • Loading branch information
srikavin committed Feb 9, 2020
1 parent 5be7c62 commit 2a848fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class DropcatchMinigame : Minigame() {
private lateinit var table: Table
private lateinit var infoPanel: Table
private lateinit var container: Table
private lateinit var contactListener: ContactListener

private var firstRender = true
private var haveShownScoreboard = false
Expand All @@ -69,10 +70,12 @@ class DropcatchMinigame : Minigame() {
override fun resetMinigame(properties: MapProperties) {
goodItems.clear()
badItems.clear()
timeLeftVal = 60f
timeLeftVal = 45f
goodCollected = 0
goodItemsLeft = 0
badCollected = 0
firstRender = true
haveShownScoreboard = false
}

override fun initializeMinigame(skin: Skin, stage: Stage) {
Expand Down Expand Up @@ -101,11 +104,10 @@ class DropcatchMinigame : Minigame() {
gameState = world.getRegistered(GameState::class.java)

val mapper = world.getMapper(DropcatchItemComponent::class.java)
val contactListenerManager = world.getRegistered(ContactListenerManager::class.java)
val physicsWorld = world.getRegistered(World::class.java)

val contactListenerManager = world.getRegistered(ContactListenerManager::class.java)

contactListenerManager.addListener(object : ContactListener {
contactListener = object : ContactListener {
override fun endContact(contact: Contact?) {

}
Expand Down Expand Up @@ -146,7 +148,8 @@ class DropcatchMinigame : Minigame() {

override fun postSolve(contact: Contact?, impulse: ContactImpulse?) {
}
})
}
contactListenerManager.addListener(contactListener)

val cache: ObjectMap<String, TextureRegion> = ObjectMap(2)

Expand Down Expand Up @@ -201,7 +204,7 @@ class DropcatchMinigame : Minigame() {
table.isTransform = true
container.isTransform = true
table.sequence(
Actions.moveTo(1920 / 2f - 150f, 1080 / 3f),
Actions.moveTo(1920 / 2f - 150f, 1080 / 4f),
Actions.scaleTo(3f, 3f),
Actions.parallel(
Actions.moveTo(1920 / 2f, table.y, 2.5f, Interpolation.pow2In),
Expand Down Expand Up @@ -280,10 +283,14 @@ class DropcatchMinigame : Minigame() {
}

infoPanel.sequence(
Actions.fadeIn(7f),
Actions.fadeOut(3f),
Actions.show(),
Actions.fadeIn(3f),
Actions.fadeIn(5f),
Actions.fadeOut(2f),
Actions.hide(),
Actions.run {
val contactListenerManager = world.getRegistered(ContactListenerManager::class.java)
contactListenerManager.removeListener(contactListener)
Gdx.app.postRunnable {
this.endMinigame()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class ContactListenerManager : ContactListener {
listeners.add(listener)
}

/**
* Unregisters a given contact listener
*
* @param listener The listener to remove
*/
fun removeListener(listener: ContactListener) {
listeners.remove(listener)
}

override fun endContact(contact: Contact) {
listeners.forEach {
it.endContact(contact)
Expand Down

0 comments on commit 2a848fa

Please sign in to comment.