-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/src/main/java/net/imshit/aircraftwar/element/prop/BloodProp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.imshit.aircraftwar.element.prop | ||
|
||
import net.imshit.aircraftwar.logic.Games | ||
|
||
class BloodProp( | ||
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float | ||
) : Props( | ||
game = game, initialX = initialX, initialY = initialY, speedX = speedX, speedY = speedY | ||
) { | ||
override val image = game.images.propBlood | ||
override fun activate() { | ||
game.heroAircraft.increaseHp(100) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/net/imshit/aircraftwar/element/prop/BombProp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.imshit.aircraftwar.element.prop | ||
|
||
import net.imshit.aircraftwar.logic.GameEvents | ||
import net.imshit.aircraftwar.logic.Games | ||
|
||
class BombProp( | ||
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float | ||
) : Props( | ||
game = game, initialX = initialX, initialY = initialY, speedX = speedX, speedY = speedY | ||
) { | ||
override val image = game.images.propBomb | ||
override fun activate() { | ||
game.notify(GameEvents.BOMB_ACTIVATE) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/net/imshit/aircraftwar/element/prop/BulletProp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.imshit.aircraftwar.element.prop | ||
|
||
import net.imshit.aircraftwar.logic.Games | ||
import java.util.Timer | ||
import java.util.TimerTask | ||
import java.util.concurrent.atomic.AtomicInteger | ||
|
||
class BulletProp( | ||
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float | ||
) : Props( | ||
game = game, initialX = initialX, initialY = initialY, speedX = speedX, speedY = speedY | ||
) { | ||
companion object { | ||
private val usedCount = AtomicInteger(0) | ||
} | ||
|
||
override val image = game.images.propBullet | ||
|
||
override fun activate() { | ||
usedCount.getAndIncrement() | ||
val heroAircraft = game.heroAircraft | ||
heroAircraft.setShootNum(3) | ||
Timer().schedule(object : TimerTask() { | ||
override fun run() { | ||
if (usedCount.decrementAndGet() <= 0) { | ||
heroAircraft.setShootNum(1) | ||
} | ||
} | ||
}, 10000) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/net/imshit/aircraftwar/element/prop/Props.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.imshit.aircraftwar.element.prop | ||
|
||
import net.imshit.aircraftwar.element.AbstractFlyingObject | ||
import net.imshit.aircraftwar.logic.Games | ||
|
||
sealed class Props( | ||
game: Games, initialX: Float, initialY: Float, speedX: Float, speedY: Float | ||
) : AbstractFlyingObject( | ||
game = game, initialX = initialX, initialY = initialY, speedX = speedX, speedY = speedY | ||
) { | ||
abstract fun activate() | ||
} |