This commit is contained in:
Gerard Gascón 2025-04-24 16:56:52 +02:00
commit 862afc9b7a
478 changed files with 197737 additions and 0 deletions

View file

@ -0,0 +1,50 @@
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;
}
}