Added basic features
This commit is contained in:
26
Assets/Scripts/Player.cs
Normal file
26
Assets/Scripts/Player.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user