jimmy tremblay-Bernier 86fbe09b20 initial commit
2022-03-12 20:32:56 -05:00

60 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BraseroInteractable : MonoBehaviour
{
public GameObject brasero;
public Transform rotationAxis;
public ParticleSystem oil;
public GameObject fxExplosion;
private bool canExplode = true;
// Update is called once per frame
void Update()
{
float yAngle = transform.localRotation.y;
float braseroAngle = brasero.transform.localRotation.x;
// Up y = 0
if (yAngle >= -0.0003f && yAngle <= 0.0003f)
{
if (braseroAngle > 0f)
{
brasero.transform.RotateAround(rotationAxis.position, Vector3.forward, (30 * Time.deltaTime));
if (!canExplode)
{
canExplode = true;
oil.Stop();
}
}
}
// Down y = -0.5
if (yAngle <= -0.4999f && yAngle >= -0.5001f)
{
if (braseroAngle < 0.5f)
{
brasero.transform.RotateAround(rotationAxis.position, Vector3.back, (30 * Time.deltaTime));
}
else if (braseroAngle < 0.51f && braseroAngle > 0.49f)
{
if (canExplode)
{
canExplode = false;
PourOil();
}
}
}
}
private void PourOil()
{
oil.Play();
AudioSource cranking = GameObject.Find("SFX/OilSpill").GetComponent<AudioSource>();
if (!cranking.isPlaying)
cranking.Play();
}
}