From 3b474963a8188cc044fc81afd761428f6c3abb4b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 27 Apr 2020 11:19:00 +0200 Subject: [PATCH] Fix some towers --- .../scala/fr/ynerant/leveleditor/api/editor/RawCase.scala | 2 +- .../fr/ynerant/leveleditor/game/towers/BasicTower.scala | 1 - .../fr/ynerant/leveleditor/game/towers/FreezerTower.scala | 5 ++++- .../fr/ynerant/leveleditor/game/towers/LaserTower.scala | 1 - .../fr/ynerant/leveleditor/game/towers/UpgradeTower.scala | 4 ++-- .../scala/fr/ynerant/leveleditor/game/towers/WallTower.scala | 1 - 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/fr/ynerant/leveleditor/api/editor/RawCase.scala b/src/main/scala/fr/ynerant/leveleditor/api/editor/RawCase.scala index 548fce6..88b038c 100644 --- a/src/main/scala/fr/ynerant/leveleditor/api/editor/RawCase.scala +++ b/src/main/scala/fr/ynerant/leveleditor/api/editor/RawCase.scala @@ -21,7 +21,7 @@ case class RawCase(var x: Int, var y: Int, var couche1: RawSprite, var couche2: def getCoucheThree: RawSprite = couche3 - def getCollision: String = collision + def getCollision: String = collision // FULL, PARTIAL or ANY def setCollision(collision: String): Unit = { this.collision = collision diff --git a/src/main/scala/fr/ynerant/leveleditor/game/towers/BasicTower.scala b/src/main/scala/fr/ynerant/leveleditor/game/towers/BasicTower.scala index fea43eb..0f07191 100644 --- a/src/main/scala/fr/ynerant/leveleditor/game/towers/BasicTower.scala +++ b/src/main/scala/fr/ynerant/leveleditor/game/towers/BasicTower.scala @@ -4,7 +4,6 @@ import fr.ynerant.leveleditor.game.GameFrame import scala.util.Random - class BasicTower(override val x: Int, override val y: Int) extends Tower(x, y) { override def getName = "basictower" diff --git a/src/main/scala/fr/ynerant/leveleditor/game/towers/FreezerTower.scala b/src/main/scala/fr/ynerant/leveleditor/game/towers/FreezerTower.scala index 370482b..ad59c62 100644 --- a/src/main/scala/fr/ynerant/leveleditor/game/towers/FreezerTower.scala +++ b/src/main/scala/fr/ynerant/leveleditor/game/towers/FreezerTower.scala @@ -12,6 +12,9 @@ class FreezerTower(override val x: Int, override val y: Int) extends Tower(x, y) override def getPrice = 40 override private[towers] def _shot(game: GameFrame): Unit = { - game.getMobs.filter(mob => Math.abs(mob.getX - getX) <= 3 && Math.abs(mob.getY - getY) <= 3).foreach(mob => mob.freeze(if (isUpgraded) 100 else 40)) + game.getMobs.filter(mob => Math.abs(mob.getX - getX) <= 3 && Math.abs(mob.getY - getY) <= 3).foreach(mob => { + mob.freeze(if (isUpgraded) 100 else 40) + mob.hit(getDamagePerShot) + }) } } diff --git a/src/main/scala/fr/ynerant/leveleditor/game/towers/LaserTower.scala b/src/main/scala/fr/ynerant/leveleditor/game/towers/LaserTower.scala index 8984ebd..50912d0 100644 --- a/src/main/scala/fr/ynerant/leveleditor/game/towers/LaserTower.scala +++ b/src/main/scala/fr/ynerant/leveleditor/game/towers/LaserTower.scala @@ -2,7 +2,6 @@ package fr.ynerant.leveleditor.game.towers import fr.ynerant.leveleditor.game.GameFrame - class LaserTower(override val x: Int, override val y: Int) extends Tower(x, y) { override def getName = "lasertower" diff --git a/src/main/scala/fr/ynerant/leveleditor/game/towers/UpgradeTower.scala b/src/main/scala/fr/ynerant/leveleditor/game/towers/UpgradeTower.scala index 94b3c31..a72c76a 100644 --- a/src/main/scala/fr/ynerant/leveleditor/game/towers/UpgradeTower.scala +++ b/src/main/scala/fr/ynerant/leveleditor/game/towers/UpgradeTower.scala @@ -2,8 +2,6 @@ package fr.ynerant.leveleditor.game.towers import fr.ynerant.leveleditor.game.GameFrame -import scala.util.Random - class UpgradeTower(override val x: Int, override val y: Int) extends Tower(x, y) { override def getName = "upgradetower" @@ -15,5 +13,7 @@ class UpgradeTower(override val x: Int, override val y: Int) extends Tower(x, y) override private[towers] def _shot(game: GameFrame): Unit = { game.getTowers.filter(tower => Math.pow(tower.getX - getX, 2) + Math.pow(tower.getY - getY, 2) <= 25 && tower != this).foreach(tower => tower.upgrade) + if (isUpgraded) + game.getMobs.filter(mob => Math.pow(mob.getX - getX, 2) + Math.pow(mob.getY - getY, 2) <= 9).foreach(mob => mob.hit(getDamagePerShot)) } } diff --git a/src/main/scala/fr/ynerant/leveleditor/game/towers/WallTower.scala b/src/main/scala/fr/ynerant/leveleditor/game/towers/WallTower.scala index 72d3334..2e62cef 100644 --- a/src/main/scala/fr/ynerant/leveleditor/game/towers/WallTower.scala +++ b/src/main/scala/fr/ynerant/leveleditor/game/towers/WallTower.scala @@ -2,7 +2,6 @@ package fr.ynerant.leveleditor.game.towers import fr.ynerant.leveleditor.game.GameFrame - class WallTower(override val x: Int, override val y: Int) extends Tower(x, y) { override def getName = "walltower"