mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Inventory close and open by button
This commit is contained in:
parent
0687b6de99
commit
80a13d047d
11 changed files with 165 additions and 53 deletions
|
|
@ -41,6 +41,9 @@ public partial class GameManager : Node2D
|
|||
|
||||
//public AlarmManager AlarmManager => _alarmManager;
|
||||
|
||||
[Export]
|
||||
public string PauseActionName { get; private set; } = "pause";
|
||||
|
||||
private Node2D _bulletsContainer;
|
||||
public Node2D BulletsContainer => _bulletsContainer;
|
||||
|
||||
|
|
@ -49,6 +52,8 @@ public partial class GameManager : Node2D
|
|||
|
||||
[Signal]
|
||||
public delegate void PlayerRespawnedEventHandler();
|
||||
|
||||
public Vector2 LastCheckpointPosition { get; set; }
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
|
|
@ -104,20 +109,17 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (GameState is GameState.Playing && Input.IsActionJustPressed("pause"))
|
||||
if (GameState is GameState.Paused && Input.IsActionJustPressed(PauseActionName))
|
||||
{
|
||||
TogglePause();
|
||||
Unpause();
|
||||
}
|
||||
}
|
||||
|
||||
private void DelayPlayerSpawn()
|
||||
{
|
||||
//await Task.Delay(500);
|
||||
|
||||
if (SpawnMarkers.Any())
|
||||
{
|
||||
SpawnPlayer();
|
||||
|
|
@ -244,17 +246,17 @@ public partial class GameManager : Node2D
|
|||
AddChild(_bulletsContainer);
|
||||
}
|
||||
|
||||
public void TogglePause()
|
||||
{
|
||||
if (GameState == GameState.Paused)
|
||||
{
|
||||
Unpause();
|
||||
}
|
||||
else if (GameState == GameState.Playing)
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
// public void TogglePause()
|
||||
// {
|
||||
// if (GameState == GameState.Paused)
|
||||
// {
|
||||
// Unpause();
|
||||
// }
|
||||
// else if (GameState == GameState.Playing)
|
||||
// {
|
||||
// Pause();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
|
|
@ -268,7 +270,8 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
if (GameState == GameState.Paused)
|
||||
{
|
||||
ChangeState(GameState.Playing);
|
||||
CallDeferred(MethodName.ChangeState, (int)GameState.Playing);
|
||||
//ChangeState(GameState.Playing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,22 +293,19 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
if (state == GameState) return;
|
||||
GameState = state;
|
||||
EmitSignal(nameof(GameStateChange), (int)GameState);
|
||||
EmitSignal(SignalName.GameStateChange, (int)state);
|
||||
GD.Print($"Game state changed to {state}");
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GameState.Menu:
|
||||
GetTree().SetPause(false);
|
||||
break;
|
||||
case GameState.Paused:
|
||||
case GameState.Dialogue:
|
||||
case GameState.Inventory:
|
||||
GetTree().SetPause(true);
|
||||
break;
|
||||
case GameState.Playing:
|
||||
GetTree().SetPause(false);
|
||||
break;
|
||||
case GameState.Controlling:
|
||||
case GameState.Menu:
|
||||
GetTree().SetPause(false);
|
||||
break;
|
||||
}
|
||||
|
|
@ -327,5 +327,6 @@ public enum GameState
|
|||
Paused,
|
||||
Playing,
|
||||
Dialogue,
|
||||
Controlling
|
||||
Controlling,
|
||||
Inventory
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue