shovel fully done
This commit is contained in:
parent
797fbfb4fe
commit
2639322dbf
12 changed files with 107 additions and 14 deletions
|
|
@ -7,11 +7,14 @@ namespace Newlon.Components.GUI;
|
|||
|
||||
public partial class ShovelButton : TextureButton
|
||||
{
|
||||
const float CONE_HEALTH = 295.0f;
|
||||
[Export] private PackedScene particles;
|
||||
private Entity hoveredEntity;
|
||||
private bool Selected => hoveredEntity != null;
|
||||
[Export]
|
||||
private RayCast2D raycast;
|
||||
[Export]
|
||||
private Timer timer;
|
||||
private void OnFocusExited()
|
||||
{
|
||||
ButtonPressed = false;
|
||||
|
|
@ -20,6 +23,7 @@ public partial class ShovelButton : TextureButton
|
|||
{
|
||||
raycast.Reparent(PoolContainer.Instance);
|
||||
FocusExited += OnFocusExited;
|
||||
timer.Timeout += OnTimerTimeout;
|
||||
}
|
||||
|
||||
public override void _Toggled(bool toggledOn)
|
||||
|
|
@ -42,7 +46,9 @@ public partial class ShovelButton : TextureButton
|
|||
}
|
||||
else
|
||||
{
|
||||
hoveredEntity.TakeDamage(205, null);
|
||||
hoveredEntity.TakeDamage(CONE_HEALTH, null);
|
||||
timer.Start();
|
||||
Disabled = true;
|
||||
}
|
||||
}
|
||||
hoveredEntity?.GetNode<FlashShaderController>("FlashController").Deselect();
|
||||
|
|
@ -58,6 +64,7 @@ public partial class ShovelButton : TextureButton
|
|||
}
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
UpdateTimer();
|
||||
|
||||
if (ButtonPressed)
|
||||
{
|
||||
|
|
@ -145,6 +152,20 @@ public partial class ShovelButton : TextureButton
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hoveredEntity?.GetNode<FlashShaderController>("FlashController").Deselect();
|
||||
hoveredEntity = null;
|
||||
return false;
|
||||
}
|
||||
return hoveredEntity != null && hoveredEntity is RuntimeZombieData;
|
||||
}
|
||||
private void UpdateTimer()
|
||||
{
|
||||
((ShaderMaterial)Material).SetShaderParameter("progress", 1.0-timer.TimeLeft/timer.WaitTime);
|
||||
}
|
||||
private void OnTimerTimeout()
|
||||
{
|
||||
Disabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue