improved tambourine behavior
also worked a bit on level balancing, adding background details
This commit is contained in:
@@ -18,6 +18,8 @@ public class TambourineBehavior : MonoBehaviour {
|
||||
public bool pinned = false;
|
||||
public AudioSource tambourineHitSound;
|
||||
|
||||
private bool returnToPlayer = false;
|
||||
|
||||
|
||||
void Awake() {
|
||||
this.gameObject.GetComponent<CircleCollider2D>().enabled = true;
|
||||
@@ -36,7 +38,7 @@ public class TambourineBehavior : MonoBehaviour {
|
||||
// if (Input.GetKeyUp(KeyCode.K)) {
|
||||
// Destroy(this.gameObject);
|
||||
// }
|
||||
if (collidedObject != null && collidedObject.tag != "grappleSurface") {
|
||||
if (collidedObject != null && collidedObject.tag != "grappleSurface" && !returnToPlayer) {
|
||||
rb.constraints = RigidbodyConstraints2D.FreezeAll;
|
||||
// this.gameObject.transform.position = col.transform.position;
|
||||
timeLerped += Time.deltaTime;
|
||||
@@ -48,6 +50,17 @@ public class TambourineBehavior : MonoBehaviour {
|
||||
} else {
|
||||
// print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position);
|
||||
}
|
||||
} else if (returnToPlayer) {
|
||||
Destroy(rb);
|
||||
animator.SetBool("pinned", false);
|
||||
pinned = false;
|
||||
|
||||
timeLerped += Time.deltaTime;
|
||||
this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, player.transform.position, timeLerped/0.1f);
|
||||
if (this.gameObject.transform.position.x == player.transform.position.x && this.gameObject.transform.position.y == player.transform.position.y) {
|
||||
player.GetComponent<PlayerBehavior>().hasTambourine = true;
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +97,14 @@ public class TambourineBehavior : MonoBehaviour {
|
||||
}
|
||||
|
||||
public void DestroySelf() {
|
||||
timeLerped = 0.0f;
|
||||
returnToPlayer = true;
|
||||
if (collidedObject != null && collidedObject.tag == "Enemy") {
|
||||
collidedObject.GetComponent<EnemyPatrol>().pinned = false;
|
||||
collidedObject.GetComponent<EnemyPatrol>().TogglePin(false);
|
||||
} else if (collidedObject != null && collidedObject.tag == "Projectile") {
|
||||
collidedObject.GetComponent<ProjectileBehavior>().Explode();
|
||||
}
|
||||
player.GetComponent<PlayerBehavior>().hasTambourine = true;
|
||||
player.GetComponent<PlayerBehavior>().grapplingGun.ReleaseGrapple();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user