PJ/Assets/scripts/Blocks/DieBlock.cs

21 lines
753 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DieBlock : MonoBehaviour
{
public GameObject EndScreen;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player" && !GameObject.Find("player").GetComponent<Move>().Finished)
{
int DieCount = PlayerPrefs.GetInt("CountDie");
//Instantiate(EndScreen);
GameObject FD = collision.gameObject.transform.parent.gameObject;
collision.gameObject.GetComponent<Move>().Lives = 0;
Destroy(FD.transform.GetChild(1).gameObject);
PlayerPrefs.SetInt("CountDie", DieCount +1);
}
}
}