ofb/Assets/Scripts/VictoryObjectBehavior.cs
Nicholas Novak 5a7ce8fb2b 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
2023-05-04 11:25:58 -07:00

35 lines
886 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VictoryObjectBehavior : MonoBehaviour
{
public float height = 1f;
public float speed = 1f;
Vector2 initPosition;
void Awake()
{
initPosition = this.transform.position;
}
// Update is called once per frame
void Update()
{
transform.position = new Vector2(initPosition.x, initPosition.y + Mathf.Sin(Time.time * speed) * height);
}
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")
{
StateController.Instance.ShowVictoryCanvas();
}
}
}