mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 06:45:33 +00:00
Death and Rebirth
This commit is contained in:
parent
ba21b30a4d
commit
be52d0e081
11 changed files with 309 additions and 83 deletions
BIN
SFX/pldead00.wav
(Stored with Git LFS)
Normal file
BIN
SFX/pldead00.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
SFX/pldead00.wav.import
Normal file
24
SFX/pldead00.wav.import
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://euu22u5vf3gc"
|
||||
path="res://.godot/imported/pldead00.wav-9136eaf19bc9fb81de81db941a0dcb15.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://SFX/pldead00.wav"
|
||||
dest_files=["res://.godot/imported/pldead00.wav-9136eaf19bc9fb81de81db941a0dcb15.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://dkwi1hu1bixoe"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dkwi1hu1bixoe"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Hud.cs" id="1_m0hb0"]
|
||||
[ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="2_0xmx2"]
|
||||
|
|
@ -7,6 +7,20 @@
|
|||
[ext_resource type="PackedScene" uid="uid://bybd38ivpb2ly" path="res://Scenes/HUD/pause_menu.tscn" id="3_hxmxt"]
|
||||
[ext_resource type="PackedScene" uid="uid://bemu3l6b1e84y" path="res://Scenes/HUD/debug_menu.tscn" id="4_gd1k6"]
|
||||
[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="5_vmict"]
|
||||
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="6_sk1eq"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_a7f6n"]
|
||||
font = ExtResource("2_0xmx2")
|
||||
font_size = 24
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_5na8k"]
|
||||
font = ExtResource("6_sk1eq")
|
||||
font_color = Color(0, 0.676374, 0, 1)
|
||||
outline_size = 2
|
||||
outline_color = Color(0, 0.145098, 0, 1)
|
||||
shadow_color = Color(0, 0.239216, 0, 0)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h626b"]
|
||||
atlas = ExtResource("3_hee3i")
|
||||
|
|
@ -48,7 +62,7 @@ anti_aliasing = false
|
|||
bg_color = Color(0.338981, 0.507716, 0.996646, 1)
|
||||
anti_aliasing = false
|
||||
|
||||
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_healthLabel", "_healthBar", "_shieldLabel", "_shieldBar", "_itemsContainer", "PauseMenuContainer", "DebugMenuHolder")]
|
||||
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_healthLabel", "_healthBar", "_shieldLabel", "_shieldBar", "_itemsContainer", "_gameOverPanel", "PauseMenuContainer", "DebugMenuHolder")]
|
||||
script = ExtResource("1_m0hb0")
|
||||
_healthLabel = NodePath("VBoxContainer/HealthBarContainer/HealthLabel")
|
||||
_healthBar = NodePath("VBoxContainer/HealthBarContainer/HealthBar")
|
||||
|
|
@ -56,27 +70,35 @@ _shieldLabel = NodePath("VBoxContainer/ShieldBarContainer/ShieldLabel")
|
|||
_shieldBar = NodePath("VBoxContainer/ShieldBarContainer/ShieldBar")
|
||||
_itemsContainer = NodePath("VBoxContainer/ItemsContainer")
|
||||
_labelSettings = ExtResource("2_x7kl7")
|
||||
_gameOverPanel = NodePath("GameOver")
|
||||
PauseMenuContainer = NodePath("PauseMenuContainer")
|
||||
PauseMenuScene = ExtResource("3_hxmxt")
|
||||
DebugMenuTemplate = ExtResource("4_gd1k6")
|
||||
DebugMenuHolder = NodePath("DebugContainer")
|
||||
|
||||
[node name="GameOver" type="Label" parent="."]
|
||||
[node name="GameOver" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -217.0
|
||||
offset_top = -39.0
|
||||
offset_right = 217.0
|
||||
offset_bottom = 39.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_fonts/font = ExtResource("2_0xmx2")
|
||||
theme_override_font_sizes/font_size = 64
|
||||
text = "GAME OVER"
|
||||
offset_left = -3.0
|
||||
offset_top = 34.0
|
||||
offset_right = 323.0
|
||||
offset_bottom = 88.0
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="GameOver"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = -4
|
||||
|
||||
[node name="GameOver" type="Label" parent="GameOver/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "FAIRY: TERMINATED"
|
||||
label_settings = SubResource("LabelSettings_a7f6n")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="GameOver/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Press Shoot button to reform"
|
||||
label_settings = SubResource("LabelSettings_5na8k")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="MessageTimer" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
|
|
|
|||
28
Scenes/Particles/DeathParticles.tscn
Normal file
28
Scenes/Particles/DeathParticles.tscn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://biugfbp0yae2s"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="1_7tn7y"]
|
||||
[ext_resource type="Script" path="res://Scripts/Components/AutodeleteParticle.cs" id="2_2y1ka"]
|
||||
[ext_resource type="AudioStream" uid="uid://euu22u5vf3gc" path="res://SFX/pldead00.wav" id="3_q7v7h"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_nmvck"]
|
||||
particle_flag_disable_z = true
|
||||
radial_velocity_min = -2.23517e-05
|
||||
radial_velocity_max = 360.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
scale_min = 4.0
|
||||
scale_max = 4.0
|
||||
|
||||
[node name="DeathParticles" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 16
|
||||
process_material = SubResource("ParticleProcessMaterial_nmvck")
|
||||
texture = ExtResource("1_7tn7y")
|
||||
one_shot = true
|
||||
script = ExtResource("2_2y1ka")
|
||||
LifeTime = 3.0
|
||||
AutoStart = true
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("3_q7v7h")
|
||||
volume_db = -15.078
|
||||
autoplay = true
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=34 format=3 uid="uid://bghghp5ep4w2j"]
|
||||
[gd_scene load_steps=36 format=3 uid="uid://bghghp5ep4w2j"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
||||
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="2_ov36d"]
|
||||
[ext_resource type="PackedScene" uid="uid://chkpk7erlqajg" path="res://Scenes/Selector.tscn" id="3_8wt6s"]
|
||||
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="3_ul15q"]
|
||||
[ext_resource type="PackedScene" uid="uid://biugfbp0yae2s" path="res://Scenes/Particles/DeathParticles.tscn" id="4_1bl4h"]
|
||||
[ext_resource type="Script" path="res://addons/smoothing/smoothing_2d.gd" id="4_j4xhu"]
|
||||
[ext_resource type="Texture2D" uid="uid://ddwhrlrgj6i00" path="res://Sprites/Actors/Cirno.png" id="5_hq878"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfb3nsay84xdb" path="res://Scenes/Weapons/crosshair.tscn" id="6_l43rf"]
|
||||
|
|
@ -13,6 +14,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bwjrdlnysft15" path="res://Sprites/Actors/Focus_Circle.png" id="8_1og8b"]
|
||||
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="9_84o8f"]
|
||||
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="9_wblq0"]
|
||||
[ext_resource type="Script" path="res://Scripts/Components/Actors/ActorResourceProvider.cs" id="14_mfxfv"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ai4rh"]
|
||||
size = Vector2(6, 6)
|
||||
|
|
@ -174,6 +176,7 @@ GameOverScene = "res://Scenes/GameOver.tscn"
|
|||
WingsSprite = ExtResource("3_ul15q")
|
||||
Muzzle = NodePath("Muzzle")
|
||||
HitboxSprite = NodePath("Smoothing2D/HitboxSprite")
|
||||
_deathParticles = ExtResource("4_1bl4h")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
|
@ -241,6 +244,16 @@ WeaponData = ExtResource("9_84o8f")
|
|||
BulletScene = ExtResource("2_ov36d")
|
||||
Muzzle = NodePath("../Muzzle")
|
||||
|
||||
[node name="HealthProvider" type="Node2D" parent="."]
|
||||
script = ExtResource("14_mfxfv")
|
||||
ResourceName = "Health"
|
||||
MaxResource = 25.0
|
||||
|
||||
[node name="ShieldProvider" type="Node2D" parent="."]
|
||||
script = ExtResource("14_mfxfv")
|
||||
ResourceName = "Shield"
|
||||
MaxResource = 25.0
|
||||
|
||||
[connection signal="area_entered" from="InteractionController" to="." method="_on_interaction_controller_area_entered"]
|
||||
[connection signal="area_exited" from="InteractionController" to="." method="_on_interaction_controller_area_exited"]
|
||||
[connection signal="area_entered" from="DamageHitBox" to="." method="_on_damage_hit_box_area_entered"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=71 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=74 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
||||
|
|
@ -57,11 +57,22 @@
|
|||
[ext_resource type="Script" path="res://Scripts/Resources/Events/DialogueStartEvent.cs" id="46_i0omr"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdti0hnbs3e63" path="res://Scenes/Actors/RoamingSusan.tscn" id="47_u1ve6"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0pb078xylxy" path="res://Scenes/Interactable/Valve.tscn" id="48_8usll"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/Events/UpdateCheckPointEvent.cs" id="49_0si7g"]
|
||||
[ext_resource type="PackedScene" uid="uid://cd36ch65jijg0" path="res://Scenes/Activable/BulletEmitter.tscn" id="49_64oga"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5fiv1nioghfb" path="res://Scenes/Actors/Marisa.tscn" id="50_mp5ma"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/Events/ControlEnemyEvent.cs" id="52_5m7td"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqjcwxene73l2" path="res://Scenes/Actors/ActorEnemyTest.tscn" id="55_chha6"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5er5x"]
|
||||
script = ExtResource("49_0si7g")
|
||||
Target = NodePath("../Factory Tilemaps/Teleporter")
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_b25hy"]
|
||||
script = ExtResource("46_i0omr")
|
||||
TimelineName = "testintro"
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_8wuck"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hdht4"]
|
||||
|
|
@ -479,8 +490,12 @@ position = Vector2(-1174, 133)
|
|||
[node name="AlarmBox2" parent="." instance=ExtResource("17_dppcs")]
|
||||
position = Vector2(-1506, -188)
|
||||
|
||||
[node name="LevelStartTrigger" parent="." instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-808, -167)
|
||||
Events = Array[Object]([SubResource("Resource_5er5x"), SubResource("Resource_b25hy")])
|
||||
|
||||
[node name="AreaTrigger2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("28_6au4t")]
|
||||
position = Vector2(-808, -168)
|
||||
position = Vector2(-435, -162)
|
||||
Target = NodePath("TestDialogueStarter")
|
||||
OneTime = true
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,20 @@ public partial class AutodeleteParticle : GpuParticles2D
|
|||
|
||||
[Export]
|
||||
public double LifeTime { get; private set; }
|
||||
|
||||
[Export]
|
||||
public bool AutoStart { get; private set; }
|
||||
|
||||
private double _timer = 0;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (AutoStart)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
this.Emitting = true;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,12 @@ public partial class GameManager : Node2D
|
|||
_player.ShieldChanged += (newShield, maxShield) => _hud.UpdateShield(newShield, maxShield);
|
||||
|
||||
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
|
||||
|
||||
_player.Death += () =>
|
||||
{
|
||||
// Show Game Over
|
||||
_hud.ShowGameOver();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public partial class Hud : CanvasLayer
|
|||
[Export] private Container _itemsContainer;
|
||||
|
||||
[Export] private LabelSettings _labelSettings;
|
||||
|
||||
[Export] private Container _gameOverPanel;
|
||||
|
||||
[ExportGroup("Pause Menu")] [Export]
|
||||
public Control PauseMenuContainer;
|
||||
|
|
@ -45,11 +47,14 @@ public partial class Hud : CanvasLayer
|
|||
private Dictionary<string, HudItem> _items = new();
|
||||
|
||||
private PauseMenu _pauseMenu;
|
||||
|
||||
private bool _playerDead = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
// Assuming the HUD has a Label node named "HealthLabel"
|
||||
//_healthLabel = GetNode<Label>("HealthLabel");
|
||||
_gameOverPanel.Hide();
|
||||
}
|
||||
|
||||
public void ShowMessage(string text)
|
||||
|
|
@ -61,23 +66,33 @@ public partial class Hud : CanvasLayer
|
|||
GetNode<Timer>("MessageTimer").Start();
|
||||
}
|
||||
|
||||
async public void ShowGameOver()
|
||||
public void ShowGameOver()
|
||||
{
|
||||
ShowMessage("Game Over");
|
||||
|
||||
var messageTimer = GetNode<Timer>("MessageTimer");
|
||||
await ToSignal(messageTimer, Timer.SignalName.Timeout);
|
||||
|
||||
var message = GetNode<Label>("Message");
|
||||
message.Text = "Dodge the Creeps!";
|
||||
message.Show();
|
||||
|
||||
await ToSignal(GetTree().CreateTimer(1.0), SceneTreeTimer.SignalName.Timeout);
|
||||
GetNode<Button>("StartButton").Show();
|
||||
_gameOverPanel.Show();
|
||||
_playerDead = true;
|
||||
|
||||
// ShowMessage("Game Over");
|
||||
//
|
||||
// var messageTimer = GetNode<Timer>("MessageTimer");
|
||||
// await ToSignal(messageTimer, Timer.SignalName.Timeout);
|
||||
//
|
||||
// var message = GetNode<Label>("Message");
|
||||
// message.Text = "Dodge the Creeps!";
|
||||
// message.Show();
|
||||
//
|
||||
// await ToSignal(GetTree().CreateTimer(1.0), SceneTreeTimer.SignalName.Timeout);
|
||||
// GetNode<Button>("StartButton").Show();
|
||||
}
|
||||
|
||||
public void UpdateHealth(float newHealth, float maxHealth)
|
||||
{
|
||||
// Hide game over if player is no longer dead
|
||||
if (_playerDead && newHealth > 0)
|
||||
{
|
||||
_playerDead = false;
|
||||
_gameOverPanel.Hide();
|
||||
}
|
||||
|
||||
_healthLabel.Text = $"{newHealth}/{maxHealth}";
|
||||
if (_healthBar != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
||||
|
|
@ -46,6 +48,17 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
[Export] public float MaxHealth = 32f;
|
||||
[Export] public float MaxShield = 32f;
|
||||
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _shootActionName = "shoot";
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _useActionName = "Use";
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _strafeActionName = "strafe";
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _nextWeaponActionName = "next_weapon";
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _previousWeaponActionName = "previous_weapon";
|
||||
|
||||
public Weapon EquippedWeapon { get; set; }
|
||||
|
||||
|
|
@ -53,17 +66,22 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
public int CurrentWeaponIndex { get; set; } = 0;
|
||||
|
||||
private float _currentHealth = 0f;
|
||||
private float _currentShield = 0f;
|
||||
//private float _currentHealth = 0f;
|
||||
//private float _currentShield = 0f;
|
||||
|
||||
private bool _isDestroyed = false;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
|
||||
private ActorResourceProvider _healthProvider;
|
||||
private ActorResourceProvider _shieldProvider;
|
||||
|
||||
[Export] public Sprite2D HitboxSprite { get; set; }
|
||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
||||
|
||||
[Export] private PackedScene _deathParticles;
|
||||
private bool _isStrafing { get; set; }
|
||||
|
||||
private bool _canMove = true;
|
||||
|
|
@ -79,53 +97,71 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
[Signal]
|
||||
public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
|
||||
|
||||
[Signal]
|
||||
public delegate void DeathEventHandler();
|
||||
|
||||
// public float CurrentHealth
|
||||
// {
|
||||
// get => _currentHealth;
|
||||
// set
|
||||
// {
|
||||
// if (_currentHealth != value)
|
||||
// {
|
||||
// _currentHealth = value;
|
||||
//
|
||||
// if (_currentHealth > MaxHealth) {
|
||||
// _currentHealth = MaxHealth;
|
||||
// }
|
||||
//
|
||||
// EmitSignal(nameof(HealthChanged), _currentHealth, MaxHealth);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public float CurrentHealth
|
||||
{
|
||||
get => _currentHealth;
|
||||
set
|
||||
{
|
||||
if (_currentHealth != value)
|
||||
{
|
||||
_currentHealth = value;
|
||||
|
||||
if (_currentHealth > MaxHealth) {
|
||||
_currentHealth = MaxHealth;
|
||||
}
|
||||
|
||||
EmitSignal(nameof(HealthChanged), _currentHealth, MaxHealth);
|
||||
}
|
||||
}
|
||||
get => _healthProvider.CurrentResource;
|
||||
set => _healthProvider.CurrentResource = value;
|
||||
}
|
||||
|
||||
|
||||
public float CurrentShield
|
||||
{
|
||||
get => _currentShield;
|
||||
set
|
||||
{
|
||||
if (_currentShield != value)
|
||||
{
|
||||
_currentShield = value;
|
||||
|
||||
if (_currentShield > MaxShield)
|
||||
{
|
||||
_currentShield = MaxShield;
|
||||
}
|
||||
|
||||
EmitSignal(nameof(ShieldChanged), _currentShield, MaxShield);
|
||||
}
|
||||
}
|
||||
get => _shieldProvider.CurrentResource;
|
||||
set => _shieldProvider.CurrentResource = value;
|
||||
}
|
||||
|
||||
//private InventoryManager _inventoryManager;
|
||||
private Vector2 _lastCheckPointPosition;
|
||||
|
||||
public Vector2 LastCheckPointPosition
|
||||
{
|
||||
get => _lastCheckPointPosition;
|
||||
set => _lastCheckPointPosition = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CurrentHealth = MaxHealth;
|
||||
CurrentShield = MaxShield;
|
||||
// CurrentHealth = MaxHealth;
|
||||
// CurrentShield = MaxShield;
|
||||
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||
|
||||
_healthProvider = GetNode<ActorResourceProvider>("HealthProvider");
|
||||
_shieldProvider = GetNode<ActorResourceProvider>("ShieldProvider");
|
||||
|
||||
_healthProvider.MaxResource = MaxHealth;
|
||||
_shieldProvider.MaxResource = MaxShield;
|
||||
_healthProvider.ResourceChanged += (value, maxValue) =>
|
||||
{
|
||||
EmitSignal(nameof(HealthChanged), value, maxValue);
|
||||
};
|
||||
_shieldProvider.ResourceChanged += (value, maxValue) =>
|
||||
{
|
||||
EmitSignal(nameof(ShieldChanged), value, maxValue);
|
||||
};
|
||||
_healthProvider.FillResource();
|
||||
_shieldProvider.FillResource();
|
||||
|
||||
_movementDirection = Vector2.Zero;
|
||||
_facingDirection = Vector2.Zero;
|
||||
|
|
@ -142,6 +178,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
_selector = this.CreateSibling<Selector>(SelectorScene, this.GlobalPosition);
|
||||
_selector.Visible = false;
|
||||
}
|
||||
|
||||
_lastCheckPointPosition = GlobalPosition;
|
||||
}
|
||||
|
||||
private void GameManagerOnGameStateChange(GameState state)
|
||||
|
|
@ -215,7 +253,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private void FindInteractable()
|
||||
{
|
||||
var selected = _selector.SelectedInteractable;
|
||||
if (!Input.IsActionJustPressed("Use") || selected == null) return;
|
||||
if (!Input.IsActionJustPressed(_useActionName) || selected == null) return;
|
||||
if (!selected.CanActivate()) return;
|
||||
bool success = selected.Activate();
|
||||
|
||||
|
|
@ -235,7 +273,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private void HandleShoot()
|
||||
{
|
||||
if (EquippedWeapon == null) return;
|
||||
if (!Input.IsActionPressed("shoot")) return;
|
||||
if (!Input.IsActionPressed(_shootActionName)) return;
|
||||
|
||||
EquippedWeapon.ShootDirection = this._facingDirection;
|
||||
EquippedWeapon.Shoot();
|
||||
|
|
@ -295,18 +333,23 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
|
||||
//var cPos = new Vector2(this.Position.X + CrosshairDistance * Godot.Mathf.Cos(angle), this.Position.Y + CrosshairDistance * Godot.Mathf.Sin(angle));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_isDestroyed)
|
||||
{
|
||||
if (Input.IsActionJustPressed(_shootActionName))
|
||||
Respawn();
|
||||
return;
|
||||
};
|
||||
|
||||
SetAnimation();
|
||||
if (!_canMove) return;
|
||||
|
||||
_movementDirection = GetInput();
|
||||
|
||||
_isStrafing = Input.IsActionPressed("strafe");
|
||||
_isStrafing = Input.IsActionPressed(_strafeActionName);
|
||||
// Toggle visibility of the hitbox sprite based on strafing
|
||||
if (HitboxSprite != null)
|
||||
{
|
||||
|
|
@ -331,12 +374,12 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
HandleShoot();
|
||||
FindInteractable();
|
||||
|
||||
if (Input.IsActionJustPressed("next_weapon"))
|
||||
if (Input.IsActionJustPressed(_nextWeaponActionName))
|
||||
{
|
||||
NextWeapon();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("previous_weapon"))
|
||||
if (Input.IsActionJustPressed(_previousWeaponActionName))
|
||||
{
|
||||
PreviousWeapon();
|
||||
}
|
||||
|
|
@ -344,8 +387,18 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
_crosshair.Position = CalculateCrosshairPosition();
|
||||
}
|
||||
|
||||
public void Respawn()
|
||||
{
|
||||
if (!_isDestroyed) return;
|
||||
_isDestroyed = false;
|
||||
this.GlobalPosition = LastCheckPointPosition;
|
||||
_healthProvider.FillResource();
|
||||
this.Visible = true;
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (_isDestroyed) return;
|
||||
if (!_canMove) return;
|
||||
|
||||
Velocity = _movementDirection * MovementSpeed;
|
||||
|
|
@ -391,14 +444,18 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
Debug.WriteLine("Ded");
|
||||
//CreateParticles();
|
||||
//CreateDebris();
|
||||
if (GameOverScene != null)
|
||||
{
|
||||
GetTree().ChangeSceneToFile(GameOverScene);
|
||||
}
|
||||
else
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
// if (GameOverScene != null)
|
||||
// {
|
||||
// GetTree().ChangeSceneToFile(GameOverScene);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// QueueFree();
|
||||
// }
|
||||
var particles = this.CreateSibling<AutodeleteParticle>(_deathParticles, this.GlobalPosition);
|
||||
//particles.Init();
|
||||
this.Visible = false;
|
||||
EmitSignal(SignalName.Death);
|
||||
}
|
||||
|
||||
public void Hit(float damage, DamageType type = DamageType.Neutral)
|
||||
|
|
@ -410,7 +467,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid) {
|
||||
// Reduce shield
|
||||
CurrentShield -= damage;
|
||||
if (_currentHealth < 0 ) {
|
||||
if (CurrentShield < 0 ) {
|
||||
CurrentHealth -= Math.Abs(CurrentShield);
|
||||
CurrentShield = 0;
|
||||
}
|
||||
|
|
|
|||
32
Scripts/Resources/Events/UpdateCheckPointEvent.cs
Normal file
32
Scripts/Resources/Events/UpdateCheckPointEvent.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.Events;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class UpdateCheckPointEvent : EventResource
|
||||
{
|
||||
private GameManager _gameManager;
|
||||
|
||||
[Export]
|
||||
public NodePath Target { get; set; }
|
||||
|
||||
public override void Init(Node2D parent)
|
||||
{
|
||||
_gameManager = parent.GetGameManager();
|
||||
}
|
||||
|
||||
public override void Start(Node2D parent)
|
||||
{
|
||||
_gameManager.Player.LastCheckPointPosition = parent.GetNode<Node2D>(Target).GlobalPosition;
|
||||
}
|
||||
|
||||
public override void UpdateEvent(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue