Add NotificationManager and NotificationLabel for age advancement notifications; refactor scripts into Components directory
This commit is contained in:
31
Scripts/Components/NotificationManager.cs
Normal file
31
Scripts/Components/NotificationManager.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Godot;
|
||||
using ParasiticGod.Scripts;
|
||||
using ParasiticGod.Scripts.Singletons;
|
||||
|
||||
namespace ParasiticGod.Scripts.Components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class NotificationManager : CanvasLayer
|
||||
{
|
||||
[Export] private PackedScene _notificationLabelScene;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
GameBus.Instance.AgeAdvanced += OnAgeAdvanced;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
if (GameBus.Instance != null)
|
||||
{
|
||||
GameBus.Instance.AgeAdvanced -= OnAgeAdvanced;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAgeAdvanced(string ageName)
|
||||
{
|
||||
var notification = _notificationLabelScene.Instantiate<NotificationLabel>();
|
||||
AddChild(notification);
|
||||
notification.ShowNotification($"You have entered\n{ageName}!");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user