bugfixed tambourine and player death

death still needs work!
This commit is contained in:
Sam
2023-04-30 14:16:29 -07:00
parent 9f36564e67
commit c51af3ce92
6 changed files with 27 additions and 22 deletions

View File

@@ -11,6 +11,9 @@ public class CameraMovement : MonoBehaviour {
[SerializeField] float yOffset;
[SerializeField] float smoothing;
[Header("Positioning")]
[SerializeField] float size;
[Header("Locking")]
[SerializeField] bool xLocked;
[SerializeField] bool yLocked;
@@ -18,6 +21,7 @@ public class CameraMovement : MonoBehaviour {
void Awake() {
FindPlayer();
this.gameObject.GetComponent<Camera>().orthographicSize = size;
}
// Update is called once per frame

View File

@@ -182,7 +182,7 @@ public class PlayerBehavior : MonoBehaviour
}
void OnCollisionEnter2D(Collision2D collision) {
if (collision.gameObject.tag == "Enemy") {
if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "ProjectileEnemy") {
if (collision.transform.position.y < transform.position.y) {
_rb.AddForce(Vector2.up * 8, ForceMode2D.Impulse);
collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
@@ -210,8 +210,5 @@ public class PlayerBehavior : MonoBehaviour
foreach (GameObject tambourine in currentTambourines) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
}
yield return new WaitForSeconds(2f);
Destroy(this.gameObject);
}
}

View File

@@ -102,6 +102,7 @@ public class StateController : MonoBehaviour {
}
public void RespawnPlayer() {
Destroy(GameObject.FindGameObjectWithTag("Player"));
SetDeathCanvasActive(false);
GameObject.Find("Main Camera").GetComponent<CameraMovement>().FindPlayer();
RespawnEnemies();

View File

@@ -54,12 +54,14 @@ public class TambourineBehavior : MonoBehaviour {
void OnTriggerEnter2D(Collider2D col) {
// print(col.tag);
if (col.tag == "Enemy") {
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
collidedObject = col.gameObject;
print("Pinning to enemy");
this.gameObject.GetComponent<CircleCollider2D>().enabled = false;
collidedObject.GetComponent<EnemyPatrol>().pinned = true;
collidedObject.GetComponent<EnemyPatrol>().TogglePin(true);
} else if (col.tag == "Projectile") {
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
collidedObject = col.gameObject;
print("pinned to projectile");
this.gameObject.GetComponent<CircleCollider2D>().enabled = false;