50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerStats : MonoBehaviour
|
|
{
|
|
public GameObject dieParticles;
|
|
public Vector2 checkpoint;
|
|
|
|
bool firstTime = true;
|
|
|
|
void OnEnable(){
|
|
if (!firstTime){
|
|
Respawn();
|
|
Invoke("EnableCameraCollider", 2f);
|
|
}else{
|
|
firstTime = false;
|
|
}
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void Die()
|
|
{
|
|
AudioManager.instance.Play("Hit");
|
|
Instantiate(dieParticles, transform.position, Quaternion.identity);
|
|
Camera.main.GetComponent<BoxCollider2D>().isTrigger = true;
|
|
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
|
GetComponent<PlayerMovement>().canMove = false;
|
|
FindObjectOfType<PlayerKill>().Die();
|
|
}
|
|
|
|
void Respawn(){
|
|
transform.position = checkpoint;
|
|
GetComponent<PlayerMovement>().canMove = true;
|
|
}
|
|
|
|
void EnableCameraCollider(){
|
|
Camera.main.GetComponent<BoxCollider2D>().isTrigger = false;
|
|
}
|
|
}
|