change: Finished MushroomVillage

This includes changes such as putting enemies in levels, adding
projectiles, and finalizing the bounces for the moving platforms

The cymbal has been implemented, and provides a short immunity to
projectiles

Every section is playable, and includes a final ending object, although there
is no transistion to the level from the previous level yet
This commit is contained in:
Nicholas Novak
2023-05-05 10:44:42 -07:00
parent ba01db1051
commit d3dfe2acac
10 changed files with 2458 additions and 221 deletions

View File

@@ -10,21 +10,26 @@ public class GameUIController : MonoBehaviour
public GameObject trumpetBackground;
public GameObject tambourineBackground;
public GameObject clarinetBackground;
public GameObject cymbalBackground;
[HideInInspector] public GameObject trumpetUI;
[HideInInspector] public GameObject tambourineUI;
[HideInInspector] public GameObject clarinetUI;
[HideInInspector] public GameObject cymbalUI;
void Awake()
{
this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
this.cymbalUI = this.cymbalBackground.transform.GetChild(0).gameObject;
}
void Start() {
void Start()
{
this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet());
this.tambourineBackground.SetActive(StateController.Instance.HasTambourine());
this.clarinetBackground.SetActive(StateController.Instance.HasClarinet());
this.cymbalBackground.SetActive(StateController.Instance.HasCymbal());
}
public void ToggleTrumpet(bool toggleState)
@@ -54,10 +59,20 @@ public class GameUIController : MonoBehaviour
}
}
public void ToggleCymbal(bool desiredState)
{
bool curEnabled = clarinetUI.GetComponent<Image>().enabled;
if (curEnabled != desiredState)
{
cymbalUI.GetComponent<Image>().enabled = desiredState;
}
}
public void UpdateInstrumentUI()
{
this.ToggleTrumpet(StateController.Instance.HasTrumpet());
this.ToggleTambourine(StateController.Instance.HasTambourine());
this.ToggleClarinet(StateController.Instance.HasClarinet());
this.ToggleCymbal(StateController.Instance.HasCymbal());
}
}

View File

@@ -49,6 +49,7 @@ public class PlayerBehavior : MonoBehaviour
[Header("Sound")]
[SerializeField] public AudioClip footstepSound;
[SerializeField] public AudioClip deathSound;
[SerializeField] public AudioClip cymbalSound;
AudioSource audioSource;
@@ -75,6 +76,10 @@ public class PlayerBehavior : MonoBehaviour
void Update()
{
if (this.cymbalActiveTime < 0)
{
this.gameUI.ToggleCymbal(true);
}
this.cymbalActiveTime -= Time.deltaTime;
unlockedTambourine = StateController.Instance.HasTambourine();
@@ -145,6 +150,13 @@ public class PlayerBehavior : MonoBehaviour
{
if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame())
{
// Play the sound
this.gameUI.ToggleCymbal(false);
this.audioSource.clip = cymbalSound;
this.audioSource.loop = false;
this.audioSource.Play();
// Set the cymbal active for the equivalent of one second
this.cymbalActiveTime = 1;
}
}
@@ -370,7 +382,12 @@ public class PlayerBehavior : MonoBehaviour
Destroy(collision.gameObject);
if (this.cymbalActiveTime > 0)
{
Debug.Log("Reflected!");
Vector2 projVel = collision.gameObject.GetComponent<Rigidbody2D>().velocity;
collision.gameObject.GetComponent<Rigidbody2D>().velocity =
new Vector2(
-projVel.x,
-projVel.y
);
}
else
{