mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 03:25:55 +00:00
Main Menu and Game Over
This commit is contained in:
parent
360b4dfe6a
commit
9b7a426deb
5 changed files with 187 additions and 14 deletions
|
|
@ -13,10 +13,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
|
||||
|
||||
[Export]
|
||||
public PackedScene SelectorScene { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene GameOverScene { get; set; }
|
||||
|
||||
private Node2D _selector;
|
||||
|
||||
private Interactable _lastInteractable;
|
||||
|
|
@ -27,7 +30,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private AnimatedSprite2D _animatedSprite;
|
||||
|
||||
private Vector2 _movementDirection { get; set; }
|
||||
|
||||
|
||||
private Vector2 _facingDirection { get; set; }
|
||||
|
||||
private Sprite2D _crosshair;
|
||||
|
|
@ -78,7 +81,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
{
|
||||
HandleShoot();
|
||||
SetAnimation();
|
||||
|
||||
|
||||
FindInteractable();
|
||||
}
|
||||
|
||||
|
|
@ -88,9 +91,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
{
|
||||
_lastInteractable.Activate();
|
||||
}
|
||||
|
||||
|
||||
//var spaceState = GetWorld2D().DirectSpaceState;
|
||||
|
||||
|
||||
//var query = PhysicsRayQueryParameters2D.Create(Vector2.Zero, )
|
||||
}
|
||||
|
||||
|
|
@ -156,9 +159,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
{
|
||||
_movementDirection = GetInput();
|
||||
if (_movementDirection != Vector2.Zero) {
|
||||
if (_movementDirection != Vector2.Zero)
|
||||
{
|
||||
_facingDirection = _movementDirection;
|
||||
}
|
||||
Velocity = _movementDirection * (float)(Speed * delta);
|
||||
|
|
@ -168,9 +172,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
_crosshair.Position = CalculateCrosshairPosition();
|
||||
|
||||
//FindInteractable();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void _on_interaction_controller_area_entered(Area2D area)
|
||||
{
|
||||
// Replace with function body.
|
||||
|
|
@ -192,14 +196,21 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
Debug.WriteLine("Ded");
|
||||
//CreateParticles();
|
||||
//CreateDebris();
|
||||
QueueFree();
|
||||
if (GameOverScene != null)
|
||||
{
|
||||
GetTree().ChangeSceneToPacked(GameOverScene);
|
||||
}
|
||||
else
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit(float damage)
|
||||
{
|
||||
GD.Print($"Player damaged for {damage}");
|
||||
if (_isDestroyed) return;
|
||||
|
||||
|
||||
_currentHealth -= damage;
|
||||
if (!(_currentHealth <= 0)) return;
|
||||
_isDestroyed = true;
|
||||
|
|
@ -211,8 +222,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
return _isDestroyed;
|
||||
}
|
||||
|
||||
private void _on_damage_hit_box_area_entered(Area2D area) {
|
||||
if (area is Bullet bullet) {
|
||||
private void _on_damage_hit_box_area_entered(Area2D area)
|
||||
{
|
||||
if (area is Bullet bullet)
|
||||
{
|
||||
GD.Print("Received damage manually");
|
||||
this.Hit(bullet.Damage);
|
||||
bullet.QueueFree();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue