This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
public class SceneLoadedListener : MonoBehaviour | |
{ | |
private void Start() | |
{ | |
SceneManager.sceneLoaded += HandleSceneLoaded; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class Health : MonoBehaviour | |
{ | |
[SerializeField] private int startingHealth = 100; | |
private int currentHealth; | |
public event Action<float> OnHPPctChanged = delegate { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class NPC : MonoBehaviour | |
{ | |
[SerializeField] private ParticleSystem deathParticlePrefab; | |
public event Action OnNPCDied = delegate { }; | |
internal void TakeDamage(int amount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class NPC : MonoBehaviour | |
{ | |
public event Action OnNPCDied = delegate { }; | |
internal void TakeDamage(int amount) | |
{ | |
GetComponent<Health>().TakeDamage(amount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class Health : MonoBehaviour | |
{ | |
[SerializeField] private int startingHealth = 100; | |
private int currentHealth; | |
public event Action<float> OnHPPctChanged = delegate { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class NPC : MonoBehaviour | |
{ | |
internal void TakeDamage(int amount) | |
{ | |
GetComponent<Health>().TakeDamage(amount); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class HPBar : MonoBehaviour | |
{ | |
private Slider slider; | |
private void Start() | |
{ | |
slider = GetComponentInChildren<Slider>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class NPCParticles : MonoBehaviour | |
{ | |
[SerializeField] private ParticleSystem deathParticlePrefab; | |
private void Start() | |
{ | |
GetComponent<Health>().OnDied += HandleNPCDied; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IHealth | |
{ | |
event System.Action<float> OnHPPctChanged; | |
event System.Action OnDied; | |
void TakeDamage(int amount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class StandardHealth : MonoBehaviour, IHealth | |
{ | |
[SerializeField] private int startingHealth = 100; | |
private int currentHealth; | |
public event Action<float> OnHPPctChanged = delegate { }; |
OlderNewer