player can now jump on enemies to defeat them

This commit is contained in:
slevy14
2023-04-26 16:52:49 -07:00
committed by Nicholas Novak
parent 7ae4fdd547
commit ad3b8f9166
4 changed files with 90 additions and 6 deletions

View File

@@ -150,8 +150,7 @@ public class PlayerBehavior : MonoBehaviour
}
else if (col.tag == "instaDeath")
{
this.stateController.SetDeathCanvasActive(true);
Destroy(this.gameObject);
DestroyPlayer();
}
else if (col.tag == "spawnPoint") {
stateController.spawnPoint.GetComponent<SpawnPointBehavior>().DeactivateSpawnPoint();
@@ -169,8 +168,20 @@ public class PlayerBehavior : MonoBehaviour
void OnCollisionEnter2D(Collision2D collision) {
if (collision.gameObject.tag == "Enemy") {
this.stateController.SetDeathCanvasActive(true);
Destroy(this.gameObject);
if (collision.transform.position.y < transform.position.y) {
Destroy(collision.gameObject);
} else {
DestroyPlayer();
}
}
else if (collision.gameObject.tag == "Projectile") {
Destroy(collision.gameObject);
DestroyPlayer();
}
}
public void DestroyPlayer() {
this.stateController.SetDeathCanvasActive(true);
Destroy(this.gameObject);
}
}