Add NotificationManager and NotificationLabel for age advancement notifications; refactor scripts into Components directory
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
using ParasiticGod.Scripts.Core;
|
||||
using ParasiticGod.Scripts;
|
||||
using ParasiticGod.Scripts.Core.Effects;
|
||||
using ParasiticGod.Scripts.Singletons;
|
||||
|
||||
namespace ParasiticGod.Scripts;
|
||||
namespace ParasiticGod.Scripts.Components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ActiveBuffsManager : Node
|
@@ -5,7 +5,7 @@ using Godot;
|
||||
using ParasiticGod.Scripts.Core;
|
||||
using ParasiticGod.Scripts.Singletons;
|
||||
|
||||
namespace ParasiticGod.Scripts;
|
||||
namespace ParasiticGod.Scripts.Components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ForestVisualizer : Node
|
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}!");
|
||||
}
|
||||
}
|
1
Scripts/Components/NotificationManager.cs.uid
Normal file
1
Scripts/Components/NotificationManager.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c6uh5h3sdlg7n
|
@@ -4,7 +4,7 @@ using Godot.Collections;
|
||||
using ParasiticGod.Scripts.Core;
|
||||
using ParasiticGod.Scripts.Singletons;
|
||||
|
||||
namespace ParasiticGod.Scripts;
|
||||
namespace ParasiticGod.Scripts.Components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PopulationVisualizer : Node
|
1
Scripts/Components/ProgressiveVisualizer.cs.uid
Normal file
1
Scripts/Components/ProgressiveVisualizer.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://m3qqshwpk16h
|
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using ParasiticGod.Scripts.Core;
|
||||
using ParasiticGod.Scripts.Singletons;
|
||||
|
||||
namespace ParasiticGod.Scripts;
|
||||
namespace ParasiticGod.Scripts.Components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RoadManager : Node2D
|
@@ -14,6 +14,7 @@ public partial class MiracleDefinition : Resource
|
||||
[Export] public double FaithCost { get; set; }
|
||||
[Export] public long FollowersRequired { get; set; }
|
||||
[Export] public double ProductionRequired { get; set; }
|
||||
public string AdvancesToAge { get; set; }
|
||||
|
||||
[Export] public Array<Effect> Effects { get; set; }
|
||||
}
|
@@ -6,6 +6,7 @@ namespace ParasiticGod.Scripts.Core;
|
||||
public class EffectDto
|
||||
{
|
||||
public string Type { get; set; }
|
||||
|
||||
// --- For "AddResource" Effect ---
|
||||
public Stat TargetResource { get; set; }
|
||||
public double Value { get; set; }
|
||||
@@ -19,11 +20,11 @@ public class EffectDto
|
||||
public double FromAmount { get; set; }
|
||||
public Stat ToResource { get; set; }
|
||||
public double ToAmount { get; set; }
|
||||
|
||||
|
||||
// --- For "ModifyStat" Effect ---
|
||||
public Stat TargetStat { get; set; }
|
||||
public ModifyStatEffect.Operation Op { get; set; }
|
||||
|
||||
|
||||
public List<string> MiraclesToUnlock { get; set; }
|
||||
}
|
||||
|
||||
@@ -34,5 +35,6 @@ public class MiracleDto
|
||||
public long FollowersRequired { get; set; }
|
||||
public double ProductionRequired { get; set; }
|
||||
public bool UnlockedByDefault { get; set; }
|
||||
public string AdvancesToAge { get; set; }
|
||||
public List<EffectDto> Effects { get; set; }
|
||||
}
|
@@ -70,6 +70,7 @@ public static class MiracleLoader
|
||||
FaithCost = miracleDto.FaithCost,
|
||||
FollowersRequired = miracleDto.FollowersRequired,
|
||||
ProductionRequired = miracleDto.ProductionRequired,
|
||||
AdvancesToAge = miracleDto.AdvancesToAge,
|
||||
Effects = []
|
||||
};
|
||||
|
||||
|
20
Scripts/NotificationLabel.cs
Normal file
20
Scripts/NotificationLabel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
|
||||
namespace ParasiticGod.Scripts;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class NotificationLabel : Label
|
||||
{
|
||||
public void ShowNotification(string text)
|
||||
{
|
||||
Text = text;
|
||||
PivotOffset = Size / 2;
|
||||
GlobalPosition = GetViewportRect().Size / 2;
|
||||
|
||||
var tween = CreateTween();
|
||||
tween.TweenProperty(this, "modulate:a", 1.0f, 0.5f).From(0.0f);
|
||||
tween.TweenInterval(2.5f);
|
||||
tween.TweenProperty(this, "modulate:a", 0.0f, 1.0f);
|
||||
tween.Finished += QueueFree;
|
||||
}
|
||||
}
|
1
Scripts/NotificationLabel.cs.uid
Normal file
1
Scripts/NotificationLabel.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drx8lqcjq5khj
|
@@ -21,6 +21,7 @@ public partial class GameBus : Node
|
||||
public event Action<Buff> BuffAdded;
|
||||
public event Action<Buff> BuffRemoved;
|
||||
public event Action PopulationVisualsUpdated;
|
||||
public event Action<string> AgeAdvanced;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
@@ -74,6 +75,11 @@ public partial class GameBus : Node
|
||||
{
|
||||
MiraclesUnlocked?.Invoke(miraclesToUnlock);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(miracle.AdvancesToAge))
|
||||
{
|
||||
AgeAdvanced?.Invoke(miracle.AdvancesToAge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user