26 lines
535 B
C#
26 lines
535 B
C#
using Assets;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(CharacterController2D))]
|
|
public class Player : MonoBehaviour
|
|
{
|
|
public CharacterController2D controller;
|
|
public PlayerInteraction playerInteraction;
|
|
public Health health;
|
|
|
|
public Action OnPlayerDead;
|
|
|
|
public void Start()
|
|
{
|
|
health.OnDamageTaken += OnDamageTaken;
|
|
}
|
|
|
|
private void OnDamageTaken(DamageData damageData)
|
|
{
|
|
if (damageData.newHealth <= 0)
|
|
{
|
|
OnPlayerDead?.Invoke();
|
|
}
|
|
}
|
|
} |