Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public enum NotificationType
  6. {
  7. // MAIN STATES
  8. ENEMY_DETECTED,
  9. TARGET_IN_RANGE,
  10. TARGET_OUT_OF_RANGE,
  11. TARGET_DIED,
  12. NO_TARGET,
  13. END_OF_WAYPOINTS,
  14.  
  15. // SUBSTATES
  16. STUNNED,
  17. DIED,
  18.  
  19. // OTHERS
  20. HIT_TAKEN,
  21. SUBSCRIBE_DEATH_OBSERVER,
  22. UNSUBSCRIBE_DEATH_OBSERVER
  23. }
  24. public enum NotificationPriority { LOW, NORMAL, HIGH }
  25.  
  26. public class Notification {
  27.  
  28. private GameObject sender;
  29. private GameObject receiver;
  30.  
  31. private NotificationType type;
  32. private NotificationPriority priority;
  33. private object data;
  34.  
  35. public Notification(GameObject sender, GameObject receiver, NotificationType type, NotificationPriority priority, object data)
  36. {
  37. this.sender = sender;
  38. this.receiver = receiver;
  39. this.type = type;
  40. this.priority = priority;
  41. this.data = data;
  42. }
  43.  
  44. public NotificationPriority GetPriority()
  45. {
  46. return priority;
  47. }
  48.  
  49. public NotificationType GetNotificationType()
  50. {
  51. return type;
  52. }
  53.  
  54. public object GetData()
  55. {
  56. return data;
  57. }
  58.  
  59. public GameObject GetSender()
  60. {
  61. return sender;
  62. }
  63.  
  64. public GameObject GetReceiver()
  65. {
  66. return receiver;
  67. }
  68.  
  69. public void Send()
  70. {
  71. if (GetReceiver() != null)
  72. {
  73. if (type == NotificationType.HIT_TAKEN && sender.GetComponent<EntityController>().debug)
  74. Debug.Log(type);
  75.  
  76. receiver.GetComponent<EntityController>().GetNotificationCenter().Notify(this);
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement