mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 19:35:55 +00:00
Game Pausing
This commit is contained in:
parent
401d944ab4
commit
e86e9a2bf7
8 changed files with 160 additions and 22 deletions
|
|
@ -53,6 +53,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private bool _isStrafing { get; set; }
|
||||
|
||||
private bool _canMove = true;
|
||||
|
||||
[Signal]
|
||||
public delegate void HealthChangedEventHandler(float newHealth, float MaxHealth);
|
||||
|
||||
|
|
@ -89,9 +91,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
_facingDirection = Vector2.Zero;
|
||||
_rightStickInput = Vector2.Zero;
|
||||
_isStrafing = false;
|
||||
|
||||
_gameManager = GetNode<GameManager>("/root/GameScene");
|
||||
|
||||
_gameManager = this.GetGameManager(); //GetNode<GameManager>("/root/GameScene");
|
||||
|
||||
_gameManager.GameStateChange += GameManagerOnGameStateChange;
|
||||
|
||||
if (SelectorScene != null)
|
||||
{
|
||||
_selector = this.CreateSibling<Selector>(SelectorScene, this.GlobalPosition);
|
||||
|
|
@ -99,6 +103,25 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
}
|
||||
|
||||
private void GameManagerOnGameStateChange(GameState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case GameState.Menu:
|
||||
break;
|
||||
case GameState.Paused:
|
||||
_canMove = false;
|
||||
break;
|
||||
case GameState.Playing:
|
||||
_canMove = true;
|
||||
break;
|
||||
case GameState.Dialogue:
|
||||
_canMove = false;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*public override _Process(float _delta)
|
||||
{
|
||||
if (Input.IsActionPressed("ui_right"))
|
||||
|
|
@ -113,9 +136,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
HandleShoot();
|
||||
SetAnimation();
|
||||
|
||||
if (!_canMove) return;
|
||||
HandleShoot();
|
||||
FindInteractable();
|
||||
}
|
||||
|
||||
|
|
@ -226,6 +249,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
|
||||
_movementDirection = GetInput();
|
||||
|
||||
_isStrafing = Input.IsActionPressed("strafe");
|
||||
|
|
@ -263,9 +288,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
//FindInteractable();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void _on_interaction_controller_area_entered(Area2D area)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
// Replace with function body.
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable && interactable.CanActivate())
|
||||
{
|
||||
|
|
@ -284,6 +310,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private void _on_interaction_controller_area_exited(Area2D area)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable)
|
||||
{
|
||||
Debug.WriteLine($"Interactable {area.Name} Exited");
|
||||
|
|
@ -312,6 +339,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
public void Hit(float damage)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
GD.Print($"Player damaged for {damage}");
|
||||
if (_isDestroyed) return;
|
||||
|
||||
|
|
@ -328,6 +356,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private void _on_damage_hit_box_area_entered(Area2D area)
|
||||
{
|
||||
if (!_canMove) return;
|
||||
if (area is Bullet bullet)
|
||||
{
|
||||
GD.Print("Received damage manually");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue