added trumpet visual

This commit is contained in:
Sam
2023-05-03 13:16:44 -07:00
parent 8d230a5a71
commit 3108c31489
3 changed files with 86 additions and 5 deletions

View File

@@ -37,5 +37,6 @@ public class DebugSceneSwitcher : MonoBehaviour
public void ChangeScene(int index) {
// print(index);
GameObject.FindGameObjectWithTag("SceneManager").GetComponent<SceneController>().LoadChosenScene(index);
this.gameObject.SetActive(false);
}
}

View File

@@ -30,9 +30,14 @@ public class PlayerMovement : MonoBehaviour
public float LastOnWallRightTime { get; private set; }
public float LastOnWallLeftTime { get; private set; }
// trumpet
public int trumpet = 0;
public bool in_range = false;
public GameObject enemy;
bool unlockedTrumpet;
[SerializeField] SpriteRenderer trumpetSprite;
bool trumpetActive = false;
//Jump
private bool _isJumpCut;
@@ -48,7 +53,6 @@ public class PlayerMovement : MonoBehaviour
Tutorial_GrapplingRope grapplingRope;
bool wasGrappling = false;
bool unlockedTrumpet;
//Set all of these up in the inspector
[Header("Checks")]
@@ -78,6 +82,7 @@ public class PlayerMovement : MonoBehaviour
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
audioSource = GetComponent<AudioSource>();
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
trumpetSprite.enabled = false;
}
private void Start()
@@ -204,8 +209,10 @@ public class PlayerMovement : MonoBehaviour
_isJumpFalling = false;
Jump();
// determine if trumpet jump
if (!IsGrounded() && in_range && trumpet > 0)
{
StartCoroutine(ActivateTrumpetSprite());
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
enemy.GetComponent<EnemyPatrol>().DefeatEnemy();
enemy = null;
@@ -217,6 +224,7 @@ public class PlayerMovement : MonoBehaviour
}
// check if double jump, play sound
if (trumpet == 0) {
StartCoroutine(ActivateTrumpetSprite());
gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
}
}
@@ -537,4 +545,17 @@ public class PlayerMovement : MonoBehaviour
Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);
}
#endregion
#region ADDITIONAL TRUMPET METHODS
IEnumerator ActivateTrumpetSprite() {
if (!trumpetActive) {
trumpetActive = true;
trumpetSprite.enabled = true;
yield return new WaitForSeconds(.5f);
trumpetSprite.enabled = false;
trumpetActive = false;
}
}
#endregion
}