fixed: tambourine ui resets properly on player death
This commit is contained in:
parent
cc694586a4
commit
347b1a0b2c
@ -3012,6 +3012,18 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: GrappleBox (1)
|
value: GrappleBox (1)
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3}
|
||||||
|
propertyPath: m_Radius
|
||||||
|
value: 1.85
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3}
|
||||||
|
propertyPath: m_Offset.x
|
||||||
|
value: 0.33
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1025473297745678352, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3}
|
||||||
|
propertyPath: m_Offset.y
|
||||||
|
value: -9.03
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8452658923215583967, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3}
|
- target: {fileID: 8452658923215583967, guid: 94c7d43583a3b46c58e7d4e253eae896, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: -1
|
value: -1
|
||||||
|
@ -55,4 +55,16 @@ public class GameUIController : MonoBehaviour
|
|||||||
clarinetUI.GetComponent<Image>().enabled = toggleState;
|
clarinetUI.GetComponent<Image>().enabled = toggleState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetInstrumentUI() {
|
||||||
|
if (stateController.unlockedTrumpet) {
|
||||||
|
ToggleTrumpet(true);
|
||||||
|
}
|
||||||
|
if (stateController.unlockedTambourine) {
|
||||||
|
ToggleTambourine(true);
|
||||||
|
}
|
||||||
|
if (stateController.unlockedClarinet) {
|
||||||
|
ToggleClarinet(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,9 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
{ // initialize
|
{ // initialize
|
||||||
_rb = GetComponent<Rigidbody2D>();
|
_rb = GetComponent<Rigidbody2D>();
|
||||||
stateController = GameObject.Find("StateController").GetComponent<StateController>();
|
stateController = GameObject.Find("StateController").GetComponent<StateController>();
|
||||||
|
|
||||||
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
|
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
|
||||||
|
gameUI.ResetInstrumentUI();
|
||||||
|
|
||||||
audioSource = this.gameObject.GetComponent<AudioSource>();
|
audioSource = this.gameObject.GetComponent<AudioSource>();
|
||||||
audioSource.clip = footstepSound;
|
audioSource.clip = footstepSound;
|
||||||
@ -235,8 +237,8 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
// destroy all tambourines
|
// destroy all tambourines
|
||||||
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
|
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
|
||||||
foreach (GameObject tambourine in currentTambourines) {
|
foreach (GameObject tambourine in currentTambourines) {
|
||||||
// tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
|
||||||
Destroy(tambourine);
|
// Destroy(tambourine);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stateController.RespawnPlayer();
|
this.stateController.RespawnPlayer();
|
||||||
|
@ -38,28 +38,32 @@ public class TambourineBehavior : MonoBehaviour {
|
|||||||
// if (Input.GetKeyUp(KeyCode.K)) {
|
// if (Input.GetKeyUp(KeyCode.K)) {
|
||||||
// Destroy(this.gameObject);
|
// Destroy(this.gameObject);
|
||||||
// }
|
// }
|
||||||
if (collidedObject != null && collidedObject.tag != "grappleSurface" && !returnToPlayer) {
|
if (player == null) {
|
||||||
rb.constraints = RigidbodyConstraints2D.FreezeAll;
|
DestroySelf();
|
||||||
// this.gameObject.transform.position = col.transform.position;
|
} else {
|
||||||
timeLerped += Time.deltaTime;
|
if (collidedObject != null && collidedObject.tag != "grappleSurface" && !returnToPlayer) {
|
||||||
this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, collidedObject.transform.position, timeLerped/timeToLerp);
|
rb.constraints = RigidbodyConstraints2D.FreezeAll;
|
||||||
if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !pinned) {
|
// this.gameObject.transform.position = col.transform.position;
|
||||||
animator.SetBool("pinned", true);
|
timeLerped += Time.deltaTime;
|
||||||
pinned = true;
|
this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, collidedObject.transform.position, timeLerped/timeToLerp);
|
||||||
tambourineHitSound.Play();
|
if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !pinned) {
|
||||||
} else {
|
animator.SetBool("pinned", true);
|
||||||
// print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position);
|
pinned = true;
|
||||||
}
|
tambourineHitSound.Play();
|
||||||
} else if (returnToPlayer) {
|
} else {
|
||||||
Destroy(rb);
|
// print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position);
|
||||||
animator.SetBool("pinned", false);
|
}
|
||||||
pinned = false;
|
} else if (returnToPlayer) {
|
||||||
|
Destroy(rb);
|
||||||
|
animator.SetBool("pinned", false);
|
||||||
|
pinned = false;
|
||||||
|
|
||||||
timeLerped += Time.deltaTime;
|
timeLerped += Time.deltaTime;
|
||||||
this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, player.transform.position, timeLerped/0.1f);
|
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) {
|
if (this.gameObject.transform.position.x == player.transform.position.x && this.gameObject.transform.position.y == player.transform.position.y) {
|
||||||
player.GetComponent<PlayerBehavior>().SetHasTambourine(true);
|
player.GetComponent<PlayerBehavior>().SetHasTambourine(true);
|
||||||
Destroy(this.gameObject);
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,14 +101,22 @@ public class TambourineBehavior : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void DestroySelf() {
|
public void DestroySelf() {
|
||||||
timeLerped = 0.0f;
|
if (player != null) {
|
||||||
returnToPlayer = true;
|
timeLerped = 0.0f;
|
||||||
|
returnToPlayer = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (collidedObject != null && collidedObject.tag == "Enemy") {
|
if (collidedObject != null && collidedObject.tag == "Enemy") {
|
||||||
collidedObject.GetComponent<EnemyPatrol>().pinned = false;
|
collidedObject.GetComponent<EnemyPatrol>().pinned = false;
|
||||||
collidedObject.GetComponent<EnemyPatrol>().TogglePin(false);
|
collidedObject.GetComponent<EnemyPatrol>().TogglePin(false);
|
||||||
} else if (collidedObject != null && collidedObject.tag == "Projectile") {
|
} else if (collidedObject != null && collidedObject.tag == "Projectile") {
|
||||||
collidedObject.GetComponent<ProjectileBehavior>().Explode();
|
collidedObject.GetComponent<ProjectileBehavior>().Explode();
|
||||||
}
|
}
|
||||||
player.GetComponent<PlayerBehavior>().grapplingGun.ReleaseGrapple();
|
|
||||||
|
if (player == null) {
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
} else {
|
||||||
|
player.GetComponent<PlayerBehavior>().grapplingGun.ReleaseGrapple();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user