change: Switched the state controller and scene controller to a singleton class

This doesnt' change any of the logic, but simplifies a lot of the main
game loop code.

Many things still rely on the singleton class, but shouldn't so this
will be fixed in a later commit
This commit is contained in:
Nicholas Novak
2023-05-04 02:19:51 -07:00
parent afbcb920ac
commit 5a7ce8fb2b
8 changed files with 301 additions and 211 deletions

View File

@@ -8,7 +8,8 @@ public class VictoryObjectBehavior : MonoBehaviour
public float speed = 1f;
Vector2 initPosition;
void Awake() {
void Awake()
{
initPosition = this.transform.position;
}
@@ -18,13 +19,16 @@ public class VictoryObjectBehavior : MonoBehaviour
transform.position = new Vector2(initPosition.x, initPosition.y + Mathf.Sin(Time.time * speed) * height);
}
void OnDrawGizmos() {
void OnDrawGizmos()
{
Gizmos.DrawLine(new Vector3(transform.position.x, transform.position.y - height, transform.position.z), new Vector3(transform.position.x, transform.position.y + height, transform.position.z));
}
void OnTriggerEnter2D(Collider2D col) {
if (col.tag == "Player") {
GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>().ShowVictoryCanvas();
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "Player")
{
StateController.Instance.ShowVictoryCanvas();
}
}
}