Commit 884829ef authored by Daniel Drießen's avatar Daniel Drießen

Documented Classes

parent 2f6a8d46
......@@ -5,6 +5,11 @@ import android.graphics.Paint
import android.graphics.PointF
import io.ender.pathchaser.paths.PathManager
/**
* Adds Points to the Highscore
* @param pm the PathManager
* @param p central Point of the Path
*/
class Coin(pm: PathManager, p: PointF) : Collectible(pm, p) {
override fun getPaint(): Paint = Paint().apply { color = Color.YELLOW }
......
......@@ -8,6 +8,11 @@ import io.ender.pathchaser.Sprite
import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Constants
/**
* Fundamental sprite for Collectibles
* @param pm the PathManager
* @param p central Point of the Path
*/
abstract class Collectible(pm: PathManager, p: PointF) : Sprite(pm) {
override fun getPaint(): Paint = Paint().apply { color = Color.BLACK }
......@@ -20,6 +25,9 @@ abstract class Collectible(pm: PathManager, p: PointF) : Sprite(pm) {
canvas.drawPath(this, getPaint())
}
/**
* gets executed if the Collectible is collected
*/
abstract fun trigger()
......
......@@ -5,6 +5,11 @@ import android.graphics.Paint
import android.graphics.PointF
import io.ender.pathchaser.paths.PathManager
/**
* Activates Rotation (experimental)
* @param pm the PathManager
* @param p central Point of the Path
*/
class Rotation(pm: PathManager, p: PointF) : Collectible(pm, p) {
override fun getPaint(): Paint = Paint().apply { color = Color.GRAY }
......
......@@ -7,6 +7,11 @@ import android.graphics.PointF
import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Constants
/**
* Adds 4 shields to the player and removes any remaining shields which player has.
* @param pm the PathManager
* @param p central Point of the Path
*/
class Shields(pm: PathManager, p: PointF) : Collectible(pm, p) {
override fun getPaint() = Paint().apply { color = Color.GREEN }
......
......@@ -7,6 +7,11 @@ import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Preferences
import kotlin.math.max
/**
* Reduces Speed
* @param pm the PathManager
* @param p central Point of the Path
*/
class SpeedDown(pm: PathManager, p: PointF) : Collectible(pm, p) {
override fun getPaint(): Paint = Paint().apply { color = Color.BLUE }
......
......@@ -6,6 +6,11 @@ import android.graphics.PointF
import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Preferences
/**
* Adds Speed
* @param pm the PathManager
* @param p central Point of the Path
*/
class SpeedUp(pm: PathManager, p: PointF) : Collectible(pm, p) {
override fun getPaint(): Paint = Paint().apply { color = Color.RED }
......
......@@ -9,6 +9,12 @@ import io.ender.pathchaser.paths.BossPath
import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Constants
/**
* Boss which has multiple lives and spawns obstacles in a spiral
* @param pm the PathManager
* @param bp BossPath which owns the Boss
* @param p central Point of the Path
*/
class Boss(p: PointF, pm: PathManager, private val bp: BossPath) : Enemy(p, pm) {
var life = 10
set(value) {
......@@ -28,7 +34,9 @@ class Boss(p: PointF, pm: PathManager, private val bp: BossPath) : Enemy(p, pm)
addCircle(p.x, p.y, Constants.playerRadius, Direction.CW)
}
/**
* spawns a random Collectible or an Enemy if sprite is not null
*/
fun spawn() {
for (i in 0..1) {
val sp = sprite()
......@@ -44,6 +52,9 @@ class Boss(p: PointF, pm: PathManager, private val bp: BossPath) : Enemy(p, pm)
}
}
/**
* @return A random Sprite (Enemy/Collectible) or null
*/
private fun sprite(): Sprite? {
val p = PointF(p.x, p.y + Constants.playerRadius * 1.5f)
return when ((0..100).random()) {
......
......@@ -8,6 +8,11 @@ import io.ender.pathchaser.Sprite
import io.ender.pathchaser.paths.PathManager
import io.ender.pathchaser.util.Constants
/**
* Path which costs the player a live if the player touches it
* @param p central Point of the Path
* @param pm the PathManager
*/
open class Enemy(var p: PointF, pm:PathManager) : Sprite(pm) {
override fun getPaint() = Paint().apply { color = Color.MAGENTA }
......
......@@ -11,6 +11,10 @@ import io.ender.pathchaser.util.Constants
import io.ender.pathchaser.util.Preferences
import java.io.Serializable
/**
* Administers all paths
* @param game the GameActivity
*/
class PathManager(val game: GameActivity) : Serializable {
private val paths: MutableList<Pathway> = mutableListOf()
fun getPaths(): List<Pathway> = paths
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment