38 lines
876 B
C#
38 lines
876 B
C#
using System;
|
|
using UnityEngine;
|
|
using OHM.UnityToolkit;
|
|
using OHM.UnityToolkit.Vibration;
|
|
using UnityEngine.Serialization;
|
|
|
|
public class CheckpointsHandler : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
[FormerlySerializedAs("passCheckpoint")]
|
|
private SFX _passCheckpoint;
|
|
|
|
public Checkpoints lastCheckpoint { get; private set; }
|
|
|
|
public event Action<Checkpoints> onCheckpoints;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
Checkpoints checkpoint = other.GetComponentInParent<Checkpoints>();
|
|
if (!(checkpoint == null) && !checkpoint.isPass)
|
|
{
|
|
lastCheckpoint = checkpoint;
|
|
checkpoint.PassCheckpoint();
|
|
_passCheckpoint.Play(base.transform);
|
|
VibrationManager.Vibrate(VibrationManager.VibrationType.MEDIUM);
|
|
if (this.onCheckpoints != null)
|
|
{
|
|
this.onCheckpoints(checkpoint);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UnPause(bool success)
|
|
{
|
|
Time.timeScale = 1f;
|
|
}
|
|
}
|