Some shortcuts, cancellable shovel and pause fix
This commit is contained in:
parent
6e84edafea
commit
50887a3e19
8 changed files with 99 additions and 53 deletions
|
|
@ -5,6 +5,8 @@ public partial class PauseMenu : Control
|
|||
{
|
||||
private static PauseMenu Instance;
|
||||
private bool previousPaused;
|
||||
private bool currently_paused = false;
|
||||
private AudioStream pauseSound = ResourceLoader.Load<AudioStream>("uid://ckja8ym50y0d4");
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
|
@ -14,20 +16,29 @@ public partial class PauseMenu : Control
|
|||
{
|
||||
GetParent<Control>().Visible = false;
|
||||
GetTree().Paused = previousPaused;
|
||||
currently_paused = false;
|
||||
}
|
||||
public void Restart()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
GetTree().ReloadCurrentScene();
|
||||
currently_paused = false;
|
||||
}
|
||||
public void Exit()
|
||||
{
|
||||
GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
|
||||
currently_paused = false;
|
||||
}
|
||||
public static void Pause()
|
||||
{
|
||||
if (Instance.currently_paused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Instance.GetParent<Control>().Visible = true;
|
||||
Instance.previousPaused = Instance.GetTree().Paused;
|
||||
Instance.GetTree().Paused = true;
|
||||
Instance.currently_paused = true;
|
||||
AudioSequencer.Play("pause",Instance.pauseSound);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,22 @@ public partial class ShovelButton : TextureButton
|
|||
{
|
||||
var checkedPosition = (PoolContainer.Instance.Plants.GetGlobalMousePosition() / Utility.Tile).Ceil() * Utility.Tile - new Vector2(20, 14);
|
||||
|
||||
for (int i = Utility.LayersCount-1; i >= 0; i--)
|
||||
for (int i = Utility.LayersCount - 1; i >= 0; i--)
|
||||
{
|
||||
if (PoolContainer.Instance.EntityField[i].TryGetValue(checkedPosition, out var entity) && entity is RuntimePlantData plantData)
|
||||
{
|
||||
plantData.Kill();
|
||||
|
||||
PoolContainer.Instance.SpawnParticles(particles, plantData.GlobalPosition + Vector2.Down * Utility.TileHeight/2.0f);
|
||||
PoolContainer.Instance.SpawnParticles(particles, plantData.GlobalPosition + Vector2.Down * Utility.TileHeight / 2.0f);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
ButtonPressed = false;
|
||||
}
|
||||
if (@event.IsActionPressed("cancel_plant") && ButtonPressed)
|
||||
{
|
||||
ButtonPressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue