重构旧的采集系统和掉落系统 #3

Task和Ability系统初步接入,Task系统实现移动
This commit is contained in:
2025-11-02 15:51:28 +08:00
parent 39b100acff
commit 893a0743dd
25 changed files with 306 additions and 5 deletions

View File

@ -10,7 +10,10 @@ namespace UI.Level.StateBar;
public class UBusyWidgetStateBar : UPW_MinimalWidget
{
protected UBusyWidgetHealthBar? WBP_HealthBar { get { return GetWidget("WBP_HealthBar") as UBusyWidgetHealthBar; } }
protected UBusyWidgetSatietyBar? WBP_SatietyBar { get { return GetWidget("WBP_SatietyBar") as UBusyWidgetSatietyBar; } }
// protected UBusyWidgetSatietyBar? WBP_SatietyBar { get { return GetWidget("WBP_SatietyBar") as UBusyWidgetSatietyBar; } }
protected List<UBusyWidgetSatietyBar> SatietyBars = new();
protected List<UBusyWidgetHealthBar> HealthBars = new();
protected UBusyRoleStateController? UIController;
@ -18,13 +21,26 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
public override void Construct()
{
base.Construct();
WBP_SatietyBar.SetSatietyConfig(100, 200);
for (int i = 0; i < 5; ++i)
{
if (GetWidget($"WBP_SatietyBar_{i}") is UBusyWidgetSatietyBar Bar)
{
SatietyBars.Add(Bar);
}
if (GetWidget("WBP_HealthBar") is UBusyWidgetHealthBar HpBar)
{
HealthBars.Add(HpBar);
}
}
UIController = UUIFunctionLibrary.GetUIController(this, "RoleState") as UBusyRoleStateController;
InitRoleAttribute();
UIController.OnAttributeChangeDelegate += OnAttributeChanged;
}
public void InitRoleAttribute()
@ -34,7 +50,12 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
float CurSatiety = UIController.GetControlledAttribute("Hunger");
float MaxSatiety = UIController.GetControlledAttribute("MaxHunger");
WBP_HealthBar.SetHpConfig(CurHealth, MaxHealth);
WBP_SatietyBar.SetSatietyConfig(CurSatiety, MaxSatiety);
foreach (UBusyWidgetSatietyBar Bar in SatietyBars)
{
Bar.SetSatietyConfig(CurSatiety, MaxSatiety);
}
}
public override void Destruct()
@ -43,13 +64,22 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
UIController.OnAttributeChangeDelegate -= OnAttributeChanged;
}
public void SetSatiety(float Satiety)
{
foreach(UBusyWidgetSatietyBar Bar in SatietyBars)
{
Bar.OnSatietyChanged(Satiety);
}
}
[UFunction()]
protected void OnAttributeChanged(FName AttributeName, float NewValue, float OldValue)
{
if (AttributeName == "Hunger")
{
WBP_SatietyBar.OnSatietyChanged(NewValue);
SetSatiety(NewValue);
}
}
}