This file contains hidden or 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 Subject : MonoBehaviour | |
{ | |
//delegate that stores the list of methods | |
public delegate void Observer(); | |
public static Observer OnNotify; | |
private void Start() | |
{ |
This file contains hidden or 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 Human : MonoBehaviour | |
{ | |
public string Name; | |
private void Awake() | |
{ | |
Subject.OnNotify += SayHello; |
This file contains hidden or 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
namespace System | |
{ | |
public delegate void Action(); | |
} |
This file contains hidden or 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 Subject : MonoBehaviour | |
{ | |
//delegate that stores the list of methods | |
public static Action onNotify; | |
private void Start() | |
{ |
This file contains hidden or 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 Human : Observer | |
{ | |
public string Name; | |
public override void OnNotify() | |
{ | |
SayHello(); | |
} |
This file contains hidden or 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 GameManager : MonoBehaviour | |
{ | |
public const int INITIAL_LIFE = 100; | |
private const string SCORE_TXT = "SCORE: "; | |
private const string LIFE_TXT = "LIFE: "; | |
//UI |
This file contains hidden or 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 UIComponent : MonoBehaviour | |
{ | |
[SerializeField] private Text scoreText; | |
[SerializeField] private Text lifeText; | |
[SerializeField] private Image gameOverOverlay; | |
private void Start() |
This file contains hidden or 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 AudioComponent : MonoBehaviour | |
{ | |
//Audio Clips | |
[SerializeField] private AudioClip attackSfx; | |
[SerializeField] private AudioClip playerDeathSfx; | |
//Audio Sources | |
[SerializeField] private AudioSource audioSource; |
This file contains hidden or 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 CombatComponent : MonoBehaviour | |
{ | |
public void PlayerAttacksEnemy(Player player, Enemy enemy) | |
{ | |
if (player != null) | |
{ | |
enemy?.ReceiveDamage(player.Attack); | |
} |
This file contains hidden or 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 class GameConstants | |
{ | |
public const int INITIAL_LIFE = 100; | |
public const string SCORE_TXT = "SCORE: "; | |
public const string LIFE_TXT = "LIFE: "; | |
} |