MIF_E31221325/Assets/Sprites/Space Shooter Template FREE/Scripts/Player.cs

51 lines
817 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// This script defines which sprite the 'Player" uses and its health.
/// </summary>
public class Player : MonoBehaviour
{
public GameObject destructionFX;
public static Player instance;
private void Awake()
{
if (instance == null)
instance = this;
}
//method for damage proceccing by 'Player'
public void GetDamage(int damage)
{
Destruction();
}
//'Player's' destruction procedure
void Destruction()
{
Instantiate(destructionFX, transform.position, Quaternion.identity); //generating destruction visual effect and destroying the 'Player' object
Destroy(gameObject);
}
}