init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
50
Assets/Scripts/PlayerStats.cs
Normal file
50
Assets/Scripts/PlayerStats.cs
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue