Capacitors and parallax

This commit is contained in:
Marco 2025-02-21 16:27:57 +01:00
commit 3670da9719
29 changed files with 705 additions and 57 deletions

View file

@ -0,0 +1,164 @@
[gd_scene load_steps=21 format=3 uid="uid://b0gpbkxdfbnjh"]
[ext_resource type="Script" path="res://Scripts/Door.cs" id="1_uxoep"]
[ext_resource type="Texture2D" uid="uid://gc24sjyj47x6" path="res://Sprites/Actors/ForceFieldHorizontal.png" id="2_12wxm"]
[sub_resource type="AtlasTexture" id="AtlasTexture_gecst"]
atlas = ExtResource("2_12wxm")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_g2dl7"]
atlas = ExtResource("2_12wxm")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0mu7k"]
atlas = ExtResource("2_12wxm")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_drt56"]
atlas = ExtResource("2_12wxm")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vjndy"]
atlas = ExtResource("2_12wxm")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_83rc5"]
atlas = ExtResource("2_12wxm")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_b6r7h"]
atlas = ExtResource("2_12wxm")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_k15wc"]
atlas = ExtResource("2_12wxm")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_26ncf"]
atlas = ExtResource("2_12wxm")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hui6k"]
atlas = ExtResource("2_12wxm")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_djxwi"]
atlas = ExtResource("2_12wxm")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_j1q4l"]
atlas = ExtResource("2_12wxm")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_nfeg1"]
atlas = ExtResource("2_12wxm")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_uxj7e"]
atlas = ExtResource("2_12wxm")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_bwgur"]
atlas = ExtResource("2_12wxm")
region = Rect2(224, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_h2s1d"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_gecst")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_g2dl7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0mu7k")
}],
"loop": true,
"name": &"Closed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_drt56")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vjndy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_83rc5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b6r7h")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_k15wc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_26ncf")
}],
"loop": false,
"name": &"Closing",
"speed": 5.0
}, {
"frames": [],
"loop": true,
"name": &"Open",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_hui6k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_djxwi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j1q4l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nfeg1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uxj7e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bwgur")
}],
"loop": false,
"name": &"Opening",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0wg11"]
size = Vector2(32, 32)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f2rl6"]
size = Vector2(32, 32)
[node name="HorizontalForceField" type="Area2D" groups=["Solid"]]
collision_layer = 64
collision_mask = 154
script = ExtResource("1_uxoep")
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
modulate = Color(1, 1, 1, 0.784314)
sprite_frames = SubResource("SpriteFrames_h2s1d")
animation = &"Closed"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource("RectangleShape2D_0wg11")
[node name="RigidBody2D" type="RigidBody2D" parent="."]
collision_layer = 64
collision_mask = 10
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
visible = false
shape = SubResource("RectangleShape2D_f2rl6")
[connection signal="animation_changed" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_changed"]

View file

@ -19,6 +19,16 @@ public partial class Barrel : Area2D, IDestructible
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None;
[ExportCategory("On Death Activation")]
[Export]
public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
[Export]
public Node2D Target { get; private set;}
[Signal]
public delegate void ExplodedEventHandler();
private GameManager _gameManager;
private float _currentHealth = 0f;
@ -40,12 +50,22 @@ public partial class Barrel : Area2D, IDestructible
private void Explode()
{
//ApplyExplosionDamage();
EmitSignal(SignalName.Exploded, this, _currentHealth);
ActivateOnDeath();
CreateExplosion();
CreateParticles();
CreateDebris();
QueueFree();
}
private void ActivateOnDeath()
{
if (Target is IActivable node)
{
node.Activate(ActivationType);
}
}
private void CreateExplosion()
{
if (ExplosionData == null) return;

View file

@ -1,10 +1,32 @@
[gd_scene load_steps=4 format=3 uid="uid://crph24e6e0v0q"]
[gd_scene load_steps=7 format=3 uid="uid://crph24e6e0v0q"]
[ext_resource type="Script" path="res://Scripts/Interactables/Switch.cs" id="1_alima"]
[ext_resource type="Texture2D" uid="uid://d24g1qb40t72l" path="res://Sprites/Button_Small.png" id="2_7m30w"]
[sub_resource type="CircleShape2D" id="CircleShape2D_vvpve"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rie4n"]
atlas = ExtResource("2_7m30w")
region = Rect2(0, 0, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_sgwyd"]
atlas = ExtResource("2_7m30w")
region = Rect2(8, 0, 8, 8)
[sub_resource type="SpriteFrames" id="SpriteFrames_b2dxw"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rie4n")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sgwyd")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="ControlPad" type="Area2D" groups=["Interactable"]]
collision_layer = 4
collision_mask = 2
@ -13,5 +35,7 @@ script = ExtResource("1_alima")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_vvpve")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_7m30w")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_b2dxw")
autoplay = "default"
frame_progress = 0.061742

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=11 format=4 uid="uid://prgabjxh44lf"]
[gd_scene load_steps=13 format=4 uid="uid://prgabjxh44lf"]
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_4uv21"]
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_j0vja"]
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="3_a16tm"]
[ext_resource type="Script" path="res://Scripts/Resources/MapStartDataResource.cs" id="4_bc0u7"]
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="4_em3f4"]
[ext_resource type="Script" path="res://Scripts/TilemapAvoidance.cs" id="5_75e1c"]
[ext_resource type="Script" path="res://Scenes/CameraController.gd" id="11_uct4d"]
@ -11,12 +12,19 @@
[ext_resource type="Script" path="res://Scenes/CameraTarget.gd" id="14_2aa7w"]
[ext_resource type="Script" path="res://Scripts/AlarmManager.cs" id="15_d7e3u"]
[node name="GameScene" type="Node2D" node_paths=PackedStringArray("PlayerSpawnMarker")]
[sub_resource type="Resource" id="Resource_6wo78"]
script = ExtResource("4_bc0u7")
EggIndex = 0
StartingEquipment = []
[node name="GameScene" type="Node2D"]
script = ExtResource("1_4uv21")
PlayerTemplate = ExtResource("2_j0vja")
PlayerSpawnMarker = NodePath("PlayerStartPosition")
SpawnMarkers = {
0: NodePath("PlayerStartPosition")
}
WeaponTemplate = ExtResource("3_a16tm")
StartingEquipment = Array[Object]([])
MapStartData = SubResource("Resource_6wo78")
[node name="Tilemaps" type="Node2D" parent="."]

102
Scenes/Maps/Tutorial.tscn Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,23 +1,10 @@
[gd_scene load_steps=11 format=3 uid="uid://bj28qiai2x2ar"]
[gd_scene load_steps=9 format=3 uid="uid://bj28qiai2x2ar"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_avwdx"]
[ext_resource type="Texture2D" uid="uid://d2f16ke8c7vwx" path="res://Sprites/Barrel.png" id="1_e66t6"]
[ext_resource type="PackedScene" uid="uid://clyyl3jgpfoo7" path="res://Scenes/Props/Broken_Barrel.tscn" id="2_f145b"]
[ext_resource type="PackedScene" uid="uid://jmijre3eaf8m" path="res://Scenes/Explosion.tscn" id="3_sm378"]
[ext_resource type="PackedScene" uid="uid://h11o0et1y54v" path="res://Scenes/Weapons/Bullets/explosion.tscn" id="4_epbro"]
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="5_xl8uf"]
[sub_resource type="Resource" id="Resource_kqink"]
script = ExtResource("5_xl8uf")
BulletScene = ExtResource("4_epbro")
BulletSpeed = 0.0
Direction = Vector2(1, 0)
BulletDamage = 8.0
LifeTime = 1.0
DestroyOnCollision = false
Owner = 0
DamageType = 4
TimeModifiers = null
[ext_resource type="Resource" uid="uid://ncukdupc7hbm" path="res://Resources/Bullets/Explosion.tres" id="4_eyb2j"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
@ -38,7 +25,7 @@ ExplosionRadius = 4.0
ExplosionDamage = 3.0
DebrisScene = ExtResource("2_f145b")
ExplosionParticles = ExtResource("3_sm378")
ExplosionData = SubResource("Resource_kqink")
ExplosionData = ExtResource("4_eyb2j")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View file

@ -0,0 +1,52 @@
[gd_scene load_steps=7 format=3 uid="uid://duaisem6rf56s"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_n1osj"]
[ext_resource type="Texture2D" uid="uid://5xl4cht2471h" path="res://Sprites/Props/Capacitor.png" id="2_l3vrs"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
[sub_resource type="AtlasTexture" id="AtlasTexture_mrlx1"]
atlas = ExtResource("2_l3vrs")
region = Rect2(48, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_0dae5"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_mrlx1")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
size = Vector2(11, 14)
[node name="BrokenCapacitor" type="Area2D" groups=["Destroyable"]]
collision_layer = 64
collision_mask = 10
script = ExtResource("1_n1osj")
Health = 2.0
ExplosionRadius = 0.0
ExplosionDamage = 0.0
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(0.5, -1)
shape = SubResource("RectangleShape2D_2ewfl")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_0dae5")
[node name="RigidBody2D" type="RigidBody2D" parent="."]
collision_layer = 64
collision_mask = 10
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
visible = false
position = Vector2(0.5, -1)
shape = SubResource("RectangleShape2D_ss2y0")

View file

@ -0,0 +1,75 @@
[gd_scene load_steps=12 format=3 uid="uid://dux8pv1y8wkt0"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_012qq"]
[ext_resource type="PackedScene" uid="uid://duaisem6rf56s" path="res://Scenes/Props/Broken_Capacitor.tscn" id="2_hnb2s"]
[ext_resource type="PackedScene" uid="uid://jmijre3eaf8m" path="res://Scenes/Explosion.tscn" id="3_fms01"]
[ext_resource type="Resource" uid="uid://dk2rbf88a5irh" path="res://Resources/Bullets/Explosion_Harmless.tres" id="4_q7brp"]
[ext_resource type="Texture2D" uid="uid://5xl4cht2471h" path="res://Sprites/Props/Capacitor.png" id="6_2htjq"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
[sub_resource type="AtlasTexture" id="AtlasTexture_y2ecd"]
atlas = ExtResource("6_2htjq")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fc7w7"]
atlas = ExtResource("6_2htjq")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jc6gn"]
atlas = ExtResource("6_2htjq")
region = Rect2(32, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_dcpu5"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_y2ecd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fc7w7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jc6gn")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
size = Vector2(11, 14)
[node name="Capacitor" type="Area2D" groups=["Destroyable"]]
collision_layer = 64
collision_mask = 138
script = ExtResource("1_012qq")
Health = 2.0
ExplosionRadius = 0.0
ExplosionDamage = 0.0
DebrisScene = ExtResource("2_hnb2s")
ExplosionParticles = ExtResource("3_fms01")
ExplosionData = ExtResource("4_q7brp")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(0.5, -1)
shape = SubResource("RectangleShape2D_2ewfl")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_dcpu5")
autoplay = "default"
frame = 2
frame_progress = 0.119855
[node name="RigidBody2D" type="RigidBody2D" parent="."]
collision_layer = 64
collision_mask = 10
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
visible = false
position = Vector2(0.5, -1)
shape = SubResource("RectangleShape2D_ss2y0")

File diff suppressed because one or more lines are too long