Large diffs are not rendered by default.

@@ -60,16 +60,19 @@ public class MapTile : MonoBehaviour {
// }
}

public void DestroyTile() {
public void DestroyTile(bool refreshCollider) {
//remove itself from the maptile array
this.level.mapTiles [x, y] = null;
if (refreshCollider) {
this.level.refreshCollidersOnOuterTiles ();
}
Destroy (this.gameObject);
}

public virtual void TakeDamage(int damage) {
HP = HP - damage;
if (HP <= 0) {
DestroyTile ();
DestroyTile (true);
} else {
float healthPercentage = ((float)HP / (float)maxHP) * 100;
if (healthPercentage > 66) {
@@ -44,7 +44,7 @@ public class Rocket : MonoBehaviour, IProjectile {

public void DestroyMapTileArea(int x, int y, Level level, int radius) {
if (level.mapTiles[x,y] != null) {
level.mapTiles[x,y].DestroyTile ();
level.mapTiles[x,y].DestroyTile (false);
}
if (radius > 0) {
if (y > 0) {
@@ -69,7 +69,7 @@ public void DestroyMapTileRadiusAlgorithm(Level level, int centerX, int centerY,

if (radius == 0) {
if (level.mapTiles [centerX, centerY] != null) {
level.mapTiles [centerX, centerY].DestroyTile ();
level.mapTiles [centerX, centerY].DestroyTile (false);
}
return;
}
@@ -85,42 +85,42 @@ public void DestroyMapTileRadiusAlgorithm(Level level, int centerX, int centerY,

if ((centerX + x < level.mapTiles.GetLength (0) - 1) && (centerY + y < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX + x,centerY + y] != null) {
level.mapTiles[centerX + x,centerY + y].DestroyTile ();
level.mapTiles[centerX + x,centerY + y].DestroyTile (false);
}
}
if ((centerX + x < level.mapTiles.GetLength (0) - 1) && (centerY - y > 0)) {
if (level.mapTiles[centerX + x,centerY - y] != null) {
level.mapTiles[centerX + x,centerY - y].DestroyTile ();
level.mapTiles[centerX + x,centerY - y].DestroyTile (false);
}
}
if ((centerX - x > 0) && (centerY + y < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX - x,centerY + y] != null) {
level.mapTiles[centerX - x,centerY + y].DestroyTile ();
level.mapTiles[centerX - x,centerY + y].DestroyTile (false);
}
}
if ((centerX - x > 0) && (centerY - y > 0)) {
if (level.mapTiles[centerX - x,centerY - y] != null) {
level.mapTiles[centerX - x,centerY - y].DestroyTile ();
level.mapTiles[centerX - x,centerY - y].DestroyTile (false);
}
}
if ((centerX + y < level.mapTiles.GetLength (0) - 1) && (centerY + x < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX + y,centerY + x] != null) {
level.mapTiles[centerX + y,centerY + x].DestroyTile ();
level.mapTiles[centerX + y,centerY + x].DestroyTile (false);
}
}
if ((centerX + y < level.mapTiles.GetLength (0) - 1) && (centerY - x > 0)) {
if (level.mapTiles[centerX + y,centerY - x] != null) {
level.mapTiles[centerX + y,centerY - x].DestroyTile ();
level.mapTiles[centerX + y,centerY - x].DestroyTile (false);
}
}
if ((centerX - y > 0) && (centerY + x < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX - y,centerY + x] != null) {
level.mapTiles[centerX - y,centerY + x].DestroyTile ();
level.mapTiles[centerX - y,centerY + x].DestroyTile (false);
}
}
if ((centerX - y > 0) && (centerY - x > 0)) {
if (level.mapTiles[centerX - y,centerY - x] != null) {
level.mapTiles[centerX - y,centerY - x].DestroyTile ();
level.mapTiles[centerX - y,centerY - x].DestroyTile (false);
}
}

@@ -41,7 +41,7 @@ void OnCollisionEnter2D (Collision2D col)
level.mapTiles [mapTile.x, mapTile.y].TakeDamage (damageToTile);

//refresh colliders this is probably to slow to put in every hit
level.refreshCollidersOnOuterTiles();
//level.refreshCollidersOnOuterTiles();

//Destory the projectile
Destroy (this.gameObject);
@@ -54,7 +54,7 @@ void OnCollisionEnter2D (Collision2D col)

public void DestroyMapTileArea(int x, int y, Level level, int radius) {
if (level.mapTiles[x,y] != null) {
level.mapTiles[x,y].DestroyTile ();
level.mapTiles[x,y].DestroyTile (false);
}
if (radius > 0) {
if (y > 0) {
@@ -79,7 +79,7 @@ public void DestroyMapTileRadiusAlgorithm(Level level, int centerX, int centerY,

if (radius == 0) {
if (level.mapTiles [centerX, centerY] != null) {
level.mapTiles [centerX, centerY].DestroyTile ();
level.mapTiles [centerX, centerY].DestroyTile (false);
}
return;
}
@@ -95,42 +95,42 @@ public void DestroyMapTileRadiusAlgorithm(Level level, int centerX, int centerY,

if ((centerX + x < level.mapTiles.GetLength (0) - 1) && (centerY + y < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX + x,centerY + y] != null) {
level.mapTiles[centerX + x,centerY + y].DestroyTile ();
level.mapTiles[centerX + x,centerY + y].DestroyTile (false);
}
}
if ((centerX + x < level.mapTiles.GetLength (0) - 1) && (centerY - y > 0)) {
if (level.mapTiles[centerX + x,centerY - y] != null) {
level.mapTiles[centerX + x,centerY - y].DestroyTile ();
level.mapTiles[centerX + x,centerY - y].DestroyTile (false);
}
}
if ((centerX - x > 0) && (centerY + y < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX - x,centerY + y] != null) {
level.mapTiles[centerX - x,centerY + y].DestroyTile ();
level.mapTiles[centerX - x,centerY + y].DestroyTile (false);
}
}
if ((centerX - x > 0) && (centerY - y > 0)) {
if (level.mapTiles[centerX - x,centerY - y] != null) {
level.mapTiles[centerX - x,centerY - y].DestroyTile ();
level.mapTiles[centerX - x,centerY - y].DestroyTile (false);
}
}
if ((centerX + y < level.mapTiles.GetLength (0) - 1) && (centerY + x < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX + y,centerY + x] != null) {
level.mapTiles[centerX + y,centerY + x].DestroyTile ();
level.mapTiles[centerX + y,centerY + x].DestroyTile (false);
}
}
if ((centerX + y < level.mapTiles.GetLength (0) - 1) && (centerY - x > 0)) {
if (level.mapTiles[centerX + y,centerY - x] != null) {
level.mapTiles[centerX + y,centerY - x].DestroyTile ();
level.mapTiles[centerX + y,centerY - x].DestroyTile (false);
}
}
if ((centerX - y > 0) && (centerY + x < level.mapTiles.GetLength (1) - 1)) {
if (level.mapTiles[centerX - y,centerY + x] != null) {
level.mapTiles[centerX - y,centerY + x].DestroyTile ();
level.mapTiles[centerX - y,centerY + x].DestroyTile (false);
}
}
if ((centerX - y > 0) && (centerY - x > 0)) {
if (level.mapTiles[centerX - y,centerY - x] != null) {
level.mapTiles[centerX - y,centerY - x].DestroyTile ();
level.mapTiles[centerX - y,centerY - x].DestroyTile (false);
}
}