75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.GodotNodeInterfaces;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
public interface IPlayerInfoUI : IControl
|
|
{
|
|
public void Activate();
|
|
}
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class PlayerInfoUI : Control, IPlayerInfoUI
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
#region Nodes
|
|
[Node] public VBoxContainer PlayerInfo { get; set; } = default!;
|
|
|
|
[Node] public Label LevelNumber { get; set; } = default!;
|
|
|
|
[Node] public Label HPNumber { get; set; } = default!;
|
|
|
|
[Node] public Label VTNumber { get; set; } = default!;
|
|
|
|
[Node] public Label EXPNumber { get; set; } = default!;
|
|
|
|
[Node] public ProgressBar HPProgressBar { get; set; } = default!;
|
|
|
|
[Node] public ProgressBar VTProgressBar { get; set; } = default!;
|
|
|
|
#endregion
|
|
|
|
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
|
|
|
public void Activate()
|
|
{
|
|
Player.HealthComponent.CurrentHP.Sync += HPSync;
|
|
Player.HealthComponent.MaximumHP.Sync += HPSync;
|
|
|
|
Player.VTComponent.CurrentVT.Sync += VTSync;
|
|
Player.VTComponent.MaximumVT.Sync += VTSync;
|
|
|
|
Player.ExperiencePointsComponent.Level.Sync += CurrentLevel_Sync;
|
|
Player.ExperiencePointsComponent.CurrentExp.Sync += ExpSync;
|
|
Player.ExperiencePointsComponent.ExpToNextLevel.Sync += ExpSync;
|
|
}
|
|
|
|
private void CurrentLevel_Sync(int obj)
|
|
{
|
|
LevelNumber.Text = $"{obj}";
|
|
}
|
|
|
|
private void VTSync(int obj)
|
|
{
|
|
VTNumber.Text = $"{Player.VTComponent.CurrentVT.Value}/{Player.VTComponent.MaximumVT.Value}";
|
|
VTProgressBar.Value = Player.VTComponent.CurrentVT.Value;
|
|
VTProgressBar.MaxValue = Player.VTComponent.MaximumVT.Value;
|
|
}
|
|
|
|
private void HPSync(int obj)
|
|
{
|
|
HPNumber.Text = $"{Player.HealthComponent.CurrentHP.Value}/{Player.HealthComponent.MaximumHP.Value}";
|
|
HPProgressBar.Value = Player.HealthComponent.CurrentHP.Value;
|
|
HPProgressBar.MaxValue = Player.HealthComponent.MaximumHP.Value;
|
|
}
|
|
|
|
private void ExpSync(int obj)
|
|
{
|
|
EXPNumber.Text = $"{Player.ExperiencePointsComponent.CurrentExp.Value}/{Player.ExperiencePointsComponent.ExpToNextLevel.Value}";
|
|
}
|
|
}
|