egrading armor and universal veil
This commit is contained in:
parent
1692477176
commit
29254dbda0
22 changed files with 142 additions and 30 deletions
|
|
@ -11,13 +11,13 @@ public partial class Armor : Node
|
|||
public delegate void ArmorLostEventHandler();
|
||||
|
||||
[Export]
|
||||
private int _maxHP;
|
||||
public int MaxHP { get; private set; }
|
||||
private int _hp;
|
||||
private bool _lost = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_hp = _maxHP;
|
||||
_hp = MaxHP;
|
||||
}
|
||||
|
||||
public int RecieveDamage(int damage)
|
||||
|
|
@ -43,10 +43,10 @@ public partial class Armor : Node
|
|||
return amount;
|
||||
int returnAmount = 0;
|
||||
_hp += amount;
|
||||
if (_hp >= _maxHP)
|
||||
if (_hp >= MaxHP)
|
||||
{
|
||||
returnAmount = _hp-_maxHP;
|
||||
_hp = _maxHP;
|
||||
returnAmount = _hp-MaxHP;
|
||||
_hp = MaxHP;
|
||||
}
|
||||
EmitSignal(SignalName.ArmorDamaged,_hp);
|
||||
return returnAmount;
|
||||
|
|
|
|||
33
scripts/components/DegradingSprite.cs
Normal file
33
scripts/components/DegradingSprite.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Newlon.Components.Zombies;
|
||||
|
||||
public partial class DegradingSprite : Sprite2D
|
||||
{
|
||||
[Export] private Armor armor;
|
||||
[Export] private Array<Texture2D> degradationStages;
|
||||
[Export] private Array<float> thresholdPercentage;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
armor.ArmorDamaged += OnZombieHPChanged;
|
||||
}
|
||||
|
||||
private void OnZombieHPChanged(int hp)
|
||||
{
|
||||
float percent = (float)hp / (float)armor.MaxHP;
|
||||
for (int i = 0; i < degradationStages.Count; i++)
|
||||
{
|
||||
if (percent <= thresholdPercentage[i])
|
||||
{
|
||||
Texture = degradationStages[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/components/DegradingSprite.cs.uid
Normal file
1
scripts/components/DegradingSprite.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bbw848msxb4re
|
||||
|
|
@ -1,13 +1,23 @@
|
|||
using Godot;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class VeilResizer : TextureProgressBar
|
||||
{
|
||||
[Export] private Timer _referenceTimer;
|
||||
private Seedpacket seedpacket;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
seedpacket = GetParent<Seedpacket>();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Value = (_referenceTimer.TimeLeft/_referenceTimer.WaitTime);
|
||||
if (seedpacket.Disabled && _referenceTimer.IsStopped())
|
||||
Value = 1.0;
|
||||
else
|
||||
Value = _referenceTimer.TimeLeft / _referenceTimer.WaitTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue