Merge branch 'master' of gitlab.com:MaddoScientisto/cirnogodot

This commit is contained in:
Marco 2025-01-30 08:56:30 +01:00
commit a4b39a97dc
11 changed files with 99 additions and 22 deletions

View file

@ -55,8 +55,6 @@ one_shot = true
BulletScene = ExtResource("2_ogldd")
BulletCapacity = 4
BulletSpeed = 50.0
BulletsPerShot = 3
BulletsSpreadAngle = 40.0
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]

View file

@ -1,10 +1,34 @@
[gd_scene load_steps=3 format=3 uid="uid://dkwi1hu1bixoe"]
[gd_scene load_steps=7 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"]
[ext_resource type="Texture2D" uid="uid://dde36pgb8fbwc" path="res://Sprites/selector_big.png" id="3_hee3i"]
[node name="HUD" type="CanvasLayer"]
[sub_resource type="AtlasTexture" id="AtlasTexture_h626b"]
atlas = ExtResource("3_hee3i")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_mejna"]
atlas = ExtResource("3_hee3i")
region = Rect2(16, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_78fwv"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_h626b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mejna")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_selector")]
script = ExtResource("1_m0hb0")
_selector = NodePath("AnimatedSprite2D")
[node name="HealthLabel" type="Label" parent="."]
anchors_preset = 2
@ -39,3 +63,10 @@ text = "GAME OVER"
[node name="MessageTimer" type="Timer" parent="."]
wait_time = 2.0
one_shot = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
visible = false
position = Vector2(67, 47)
sprite_frames = SubResource("SpriteFrames_78fwv")
frame = 1
frame_progress = 0.8514

View file

@ -1,9 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://dxs3ks2ucaxl4"]
[gd_scene load_steps=5 format=3 uid="uid://dxs3ks2ucaxl4"]
[ext_resource type="Script" path="res://Scenes/Interactable.cs" id="1_8ev2v"]
[ext_resource type="Texture2D" uid="uid://c53bchw2krocb" path="res://Sprites/Red_Keycard.png" id="2_onmup"]
[ext_resource type="Script" path="res://Scripts/Pickupper.cs" id="3_t6rqq"]
[ext_resource type="Resource" uid="uid://dibquna7fww7t" path="res://Resources/Items/Red_Keycard.tres" id="4_4o8tc"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x0adl"]
@ -21,4 +20,3 @@ texture = ExtResource("2_onmup")
[node name="Pickupper" type="Node2D" parent="."]
script = ExtResource("3_t6rqq")
LootTable = [ExtResource("4_4o8tc")]

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://chkpk7erlqajg"]
[gd_scene load_steps=6 format=3 uid="uid://chkpk7erlqajg"]
[ext_resource type="Texture2D" uid="uid://dde36pgb8fbwc" path="res://Sprites/selector_big.png" id="1_cc7mb"]
[ext_resource type="Script" path="res://Scripts/Selector.cs" id="1_pp2dj"]
[sub_resource type="AtlasTexture" id="AtlasTexture_gc2o5"]
atlas = ExtResource("1_cc7mb")
@ -25,10 +26,11 @@ animations = [{
}]
[node name="Selector" type="Node2D"]
top_level = true
z_index = 100
z_as_relative = false
script = ExtResource("1_pp2dj")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
top_level = true
z_index = -5
sprite_frames = SubResource("SpriteFrames_kehny")
frame_progress = 0.78335

View file

@ -142,18 +142,17 @@ radius = 17.2627
[sub_resource type="CircleShape2D" id="CircleShape2D_e6woi"]
radius = 1.0
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "EquippedWeapon", "HitboxSprite") groups=["Destroyable", "player"]]
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "EquippedWeapon") groups=["Destroyable", "player"]]
collision_layer = 2
collision_mask = 99
script = ExtResource("1_m27vu")
Speed = 3000
StrafeSpeed = 2500
StrafeSpeed = 2200
CrosshairDistance = 20.0
SelectorScene = ExtResource("3_8wt6s")
GameOverScene = "res://Scenes/GameOver.tscn"
Muzzle = NodePath("Muzzle")
EquippedWeapon = NodePath("Weapon")
HitboxSprite = NodePath("Smoothing2D/HitboxSprite")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -183,6 +182,7 @@ sprite_frames = SubResource("SpriteFrames_q0rt3")
animation = &"walk_left"
[node name="Crosshair" parent="Smoothing2D" instance=ExtResource("6_l43rf")]
z_index = 100
[node name="HitboxSprite" type="Sprite2D" parent="Smoothing2D"]
texture = ExtResource("7_msn8i")
@ -215,5 +215,8 @@ BulletCapacity = 100
ReloadTime = 0.4
BulletSpeed = 300.0
[node name="Selector" parent="." instance=ExtResource("3_8wt6s")]
[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"]

View file

@ -437,4 +437,4 @@ position = Vector2(-791, -153)
script = ExtResource("24_0c2yt")
[node name="PlayerStartPosition" type="Marker2D" parent="."]
position = Vector2(-779, -160)
position = Vector2(-790, -161)

View file

@ -39,6 +39,8 @@ public partial class GameManager : Node2D
}
_player.HealthChanged += (newHealth, maxHealth) => _hud.UpdateHealth(newHealth, maxHealth);
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
//_player.Connect(nameof(_player.HealthChanged), _hud, nameof(_hud.UpdateHealth));

View file

@ -8,6 +8,12 @@ public partial class Hud : CanvasLayer
private Label _healthLabel;
[Export]
public PackedScene SelectorScene { get; set; }
[Export]
private Node2D _selector;
public override void _Ready()
{
// Assuming the HUD has a Label node named "HealthLabel"
@ -42,4 +48,12 @@ public partial class Hud : CanvasLayer
{
_healthLabel.Text = $"{newHealth}/{maxHealth}";
}
public void UpdateInteractable(Interactable interactable) {
GD.Print($"Interactable ${interactable.Name} entered in HUD");
//_selector.Position = _selector.tolo
}
}

View file

@ -56,6 +56,12 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
[Signal]
public delegate void HealthChangedEventHandler(float newHealth, float MaxHealth);
[Signal]
public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
[Signal]
public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
public float CurrentHealth
{
get => _currentHealth;
@ -259,6 +265,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
Debug.WriteLine($"Interactable {area.Name} Entered");
EmitSignal(nameof(InteractableAreaEntered), interactable);
if (_selector != null)
{
_selector.Position = interactable.Position;
@ -270,16 +278,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
private void _on_interaction_controller_area_exited(Area2D area)
{
if (area.IsInGroup("Interactable") && area is Interactable interactable)
if (area.IsInGroup("Interactable") && area is Interactable interactable)
{
Debug.WriteLine($"Interactable {area.Name} Exited");
if (_selector != null)
{
_selector.Position = interactable.Position;
_selector.Visible = true;
_lastInteractable = interactable;
}
EmitSignal(nameof(InteractableAreaExited), interactable);
}
}

26
Scripts/Selector.cs Normal file
View file

@ -0,0 +1,26 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class Selector : Node2D
{
private Interactable _lastInteractable;
private List<Interactable> _interactables = new List<Interactable>();
private int _selectedInteractable;
public void AddInteractable(Interactable interactable)
{
if (!_interactables.Contains(interactable)) {
_interactables.Add(interactable);
}
}
public void RemoveInteractable()
{
}
}

View file

@ -45,7 +45,7 @@ project/assembly_name="Cirno"
[editor_plugins]
enabled=PackedStringArray("res://addons/ButtonLink/plugin.cfg", "res://addons/DebugGUI/plugin.cfg", "res://addons/smoothing/plugin.cfg")
enabled=PackedStringArray("res://addons/DebugGUI/plugin.cfg", "res://addons/smoothing/plugin.cfg")
[global_group]