Added whoosh sound when telling units to move

This commit is contained in:
Yair Morgenstern 2018-12-17 14:46:01 +02:00
parent 319cfd1fe9
commit 3edc95dd3e
4 changed files with 10 additions and 8 deletions

View file

@ -394,10 +394,11 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
Sounds are from FreeSound.org and are either Creative Commons or Public Domain
* [Click 01_Minimal UI Sounds](https://freesound.org/people/cabled_mess/sounds/370962/) By cabled_mess for most clicks
* [Pencil1](https://freesound.org/people/stijn/sounds/43673/) By stijn for opening and closing the tech picker
* [Click 01_Minimal UI Sounds](https://freesound.org/people/cabled_mess/sounds/370962/) By cabled_mess as 'click' for most clicks
* [Pencil1](https://freesound.org/people/stijn/sounds/43673/) By stijn as 'paper' for opening and closing the tech picker
* [SawInOut01](https://freesound.org/people/kingof_thelab/sounds/340243/) By kingof_thelab for construction picking?
* [Chain Snare #1](https://freesound.org/people/lovesbody/sounds/322079/) By lovesbody for Fortify
* [Level up](https://freesound.org/people/Marregheriti/sounds/266100/) By Marregheriti for Promote action
* [levelup](https://freesound.org/people/Seidhepriest/sounds/382915/) By Seidhepriest for special actions (free tech, build city, hhurry wonder etc.
* [Coin](https://freesound.org/people/TheDJoe93/sounds/97373/) By TheDJoe93 for purchasing tiles and constructions
* [Chain Snare #1](https://freesound.org/people/lovesbody/sounds/322079/) By lovesbody as 'fortify'
* [Level up](https://freesound.org/people/Marregheriti/sounds/266100/) By Marregheriti as 'promote' for Promote action and upgrading units
* [levelup](https://freesound.org/people/Seidhepriest/sounds/382915/) By Seidhepriest as 'chimes' for special actions (free tech, build city, hurry wonder etc.)
* [Coin](https://freesound.org/people/TheDJoe93/sounds/97373/) By TheDJoe93 as 'coin' for purchasing tiles and constructions
* [fast simple chop 1](https://freesound.org/people/dave.des/sounds/127196/) By dave.dev as 'whoosh' for moving units around

Binary file not shown.

View file

@ -129,7 +129,7 @@ fun Label.setFontSize(size:Int): Label {
fun Actor.onClick(sound:String,function: () -> Unit){
this.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
Sounds.play(sound)
if(sound!="") Sounds.play(sound)
function()
}
} )

View file

@ -140,7 +140,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
moveHereButton.addActor(unitIcon)
if (dto.unit.currentMovement > 0)
moveHereButton.onClick {
moveHereButton.onClick("") {
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
kotlin.concurrent.thread {
if (dto.unit.movementAlgs().canReach(dto.tileInfo)) {
@ -151,6 +151,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
// I can't think of any way to avoid this,
// but it's so rare and edge-case-y that ignoring its failure is actually acceptable, hence the empty catch
dto.unit.movementAlgs().headTowards(dto.tileInfo)
Sounds.play("whoosh")
if (dto.unit.currentTile != dto.tileInfo)
dto.unit.action = "moveTo " + dto.tileInfo.position.x.toInt() + "," + dto.tileInfo.position.y.toInt()
}