Explosions

This commit is contained in:
MaddoScientisto 2024-06-09 11:45:22 +02:00
commit e1d6afa512
21 changed files with 323 additions and 24 deletions

13
.idea/.idea.Cirno/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/projectSettingsUpdater.xml
/contentModel.xml
/.idea.Cirno.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

1
.idea/.idea.Cirno/.idea/.name generated Normal file
View file

@ -0,0 +1 @@
Cirno

4
.idea/.idea.Cirno/.idea/encodings.xml generated Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

8
.idea/.idea.Cirno/.idea/indexLayout.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
.idea/.idea.Cirno/.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -4,12 +4,13 @@ using System.Diagnostics;
public partial class Barrel : Area2D, IDestructible
{
[Export] public float Health = 1f;
[Export]
public float Health = 1f;
[Export] public float ExplosionRadius = 1;
[Export]
public float ExplosionRadius = 1;
[Export] public float ExplosionDamage = 1;
[Export] public PackedScene DebrisScene { get; set; }
private float _currentHealth;
@ -26,23 +27,34 @@ public partial class Barrel : Area2D, IDestructible
{
}
public void Explode() {
private void Explode()
{
Debug.WriteLine("Boom");
CreateDebris();
QueueFree();
}
private void CreateDebris()
{
if (DebrisScene == null) return;
var debris = DebrisScene.Instantiate<Barrel>();
Owner.AddChild(debris);
debris.Transform = this.GlobalTransform;
debris.Position = this.Position;
}
public void Hit(float damage)
{
if (_isDestroyed) return;
_currentHealth -= damage;
if (!(_currentHealth <= 0)) return;
_isDestroyed = true;
Explode();
// TODO: Change sprite
}
public bool IsDestroyed()
{
return _isDestroyed;
}
}

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://bj28qiai2x2ar"]
[gd_scene load_steps=7 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/Broken_Barrel.tscn" id="2_f145b"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
@ -17,6 +18,10 @@ size = Vector2(11, 14)
collision_layer = 64
collision_mask = 10
script = ExtResource("1_avwdx")
Health = 2.0
ExplosionRadius = 2.0
ExplosionDamage = 2.0
DebrisScene = ExtResource("2_f145b")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://bgk7fgwiis425"]
[gd_scene load_steps=6 format=3 uid="uid://bgk7fgwiis425"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_flhlf"]
[ext_resource type="PackedScene" uid="uid://dpaobtgb3l4ft" path="res://Scenes/Box_Red_Broken.tscn" id="2_baxfl"]
[ext_resource type="Texture2D" uid="uid://c1djpk8lbgjfe" path="res://Sprites/Box_Red.png" id="2_g1pum"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
@ -9,10 +10,14 @@ size = Vector2(11, 14)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
size = Vector2(11, 14)
[node name="Barrel" type="Area2D" groups=["Destroyable"]]
[node name="Red Box" type="Area2D" groups=["Destroyable"]]
collision_layer = 64
collision_mask = 10
script = ExtResource("1_flhlf")
Health = 4.0
ExplosionRadius = 0.0
ExplosionDamage = 0.0
DebrisScene = ExtResource("2_baxfl")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View file

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=3 uid="uid://dpaobtgb3l4ft"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_bmfxn"]
[ext_resource type="Texture2D" uid="uid://cs07w6ekvoyog" path="res://Sprites/Box_Red_Broken.png" id="2_j8sot"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
size = Vector2(11, 14)
[node name="Red Box" type="Area2D" groups=["Destroyable"]]
collision_layer = 64
collision_mask = 10
script = ExtResource("1_bmfxn")
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="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_j8sot")
[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")

41
Scenes/Broken_Barrel.tscn Normal file
View file

@ -0,0 +1,41 @@
[gd_scene load_steps=6 format=3 uid="uid://clyyl3jgpfoo7"]
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_gn5xq"]
[ext_resource type="Texture2D" uid="uid://d2f16ke8c7vwx" path="res://Sprites/Barrel.png" id="3_c3t2t"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
size = Vector2(11, 14)
[sub_resource type="AtlasTexture" id="AtlasTexture_v7gy8"]
atlas = ExtResource("3_c3t2t")
region = Rect2(16, 0, 16, 16)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ss2y0"]
size = Vector2(11, 14)
[node name="Barrel" type="Area2D" groups=["Destroyable"]]
collision_layer = 64
collision_mask = 10
script = ExtResource("1_gn5xq")
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="Sprite2D" type="Sprite2D" parent="."]
texture = SubResource("AtlasTexture_v7gy8")
[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")

30
Scenes/Explosion.tscn Normal file
View file

@ -0,0 +1,30 @@
[gd_scene load_steps=6 format=3 uid="uid://jmijre3eaf8m"]
[sub_resource type="Gradient" id="Gradient_417ds"]
colors = PackedColorArray(0.90732, 0.880677, 0.238848, 1, 1, 0.223786, 0.223786, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_b2evf"]
gradient = SubResource("Gradient_417ds")
[sub_resource type="Curve" id="Curve_xis5v"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.340659), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_y21cl"]
curve = SubResource("Curve_xis5v")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_4vw6r"]
particle_flag_disable_z = true
spread = 180.0
initial_velocity_min = 30.0
initial_velocity_max = 75.0
gravity = Vector3(0, 0, 0)
damping_min = 28.0
damping_max = 28.0
scale_curve = SubResource("CurveTexture_y21cl")
color_ramp = SubResource("GradientTexture1D_b2evf")
[node name="Explosion" type="GPUParticles2D"]
amount = 20
process_material = SubResource("ParticleProcessMaterial_4vw6r")
explosiveness = 1.0

29
Scenes/Flame.tscn Normal file
View file

@ -0,0 +1,29 @@
[gd_scene load_steps=6 format=3 uid="uid://crf8u0wylcgob"]
[sub_resource type="Gradient" id="Gradient_rdypf"]
offsets = PackedFloat32Array(0, 0.5, 1)
colors = PackedColorArray(0.961629, 0.709712, 0.208875, 1, 0.920897, 0.430377, 0.230309, 1, 1, 1, 1, 0.568627)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_tkcjt"]
gradient = SubResource("Gradient_rdypf")
[sub_resource type="Curve" id="Curve_ar4pe"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_2gmgs"]
curve = SubResource("Curve_ar4pe")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_8rmhf"]
particle_flag_disable_z = true
gravity = Vector3(0, -98, 0)
scale_min = 2.0
scale_max = 2.0
scale_curve = SubResource("CurveTexture_2gmgs")
color_ramp = SubResource("GradientTexture1D_tkcjt")
turbulence_enabled = true
turbulence_noise_scale = 1.08
[node name="Flame" type="GPUParticles2D"]
amount = 50
process_material = SubResource("ParticleProcessMaterial_8rmhf")

34
Scenes/Smoke.tscn Normal file
View file

@ -0,0 +1,34 @@
[gd_scene load_steps=7 format=3 uid="uid://cdvk0ifhabrms"]
[ext_resource type="Texture2D" uid="uid://d0gbsrene2hqu" path="res://Sprites/Smoke.png" id="1_mprmi"]
[sub_resource type="Gradient" id="Gradient_puegb"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_pv7nn"]
gradient = SubResource("Gradient_puegb")
[sub_resource type="Curve" id="Curve_00di7"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_ga0hc"]
curve = SubResource("Curve_00di7")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_kuwpg"]
particle_flag_disable_z = true
spread = 180.0
initial_velocity_min = 25.0
initial_velocity_max = 75.0
gravity = Vector3(0, 0, 0)
damping_min = 28.0
damping_max = 28.0
scale_curve = SubResource("CurveTexture_ga0hc")
color_ramp = SubResource("GradientTexture1D_pv7nn")
turbulence_enabled = true
[node name="Smoke" type="GPUParticles2D"]
amount = 30
process_material = SubResource("ParticleProcessMaterial_kuwpg")
texture = ExtResource("1_mprmi")
explosiveness = 1.0

View file

@ -6952,15 +6952,12 @@ layer_2/tile_data = PackedInt32Array(-852021, 131072, 6, -786485, 131072, 6, -72
[node name="Barrel" parent="Factory Tilemaps/Solid" instance=ExtResource("5_3uba3")]
position = Vector2(-751, -166)
Health = 2.0
[node name="Barrel2" parent="Factory Tilemaps/Solid" instance=ExtResource("5_3uba3")]
position = Vector2(-615, -103)
Health = 2.0
[node name="Barrel3" parent="Factory Tilemaps/Solid" instance=ExtResource("5_3uba3")]
position = Vector2(-631, -103)
Health = 2.0
[node name="LargeTank" parent="Factory Tilemaps/Solid" instance=ExtResource("6_nkauc")]
position = Vector2(-639, 71)

View file

@ -53,16 +53,13 @@ public partial class PlayerMovement : CharacterBody2D
private void HandleShoot()
{
if (Input.IsActionJustPressed("shoot"))
{
//Debug.WriteLine("Shoot");
Bullet bullet = BulletScene.Instantiate<Bullet>();
Owner.AddChild(bullet);
bullet.Transform = Muzzle.GlobalTransform;
bullet.Position = this.Position;
bullet.SetDirection(this._facingDirection);
}
if (!Input.IsActionJustPressed("shoot")) return;
//Debug.WriteLine("Shoot");
var bullet = BulletScene.Instantiate<Bullet>();
Owner.AddChild(bullet);
bullet.Transform = Muzzle.GlobalTransform;
bullet.Position = this.Position;
bullet.SetDirection(this._facingDirection);
}
private void SetAnimation()

BIN
Sprites/Box_Red_Broken.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Box_Red_Broken.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cs07w6ekvoyog"
path="res://.godot/imported/Box_Red_Broken.png-a1c26e614b54f2e861abdea687489d65.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Box_Red_Broken.png"
dest_files=["res://.godot/imported/Box_Red_Broken.png-a1c26e614b54f2e861abdea687489d65.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Sprites/Smoke.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Smoke.png (Stored with Git LFS) Normal file

Binary file not shown.

34
Sprites/Smoke.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d0gbsrene2hqu"
path="res://.godot/imported/Smoke.png-5692449a3d406e5c061bff54037cb28a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Smoke.png"
dest_files=["res://.godot/imported/Smoke.png-5692449a3d406e5c061bff54037cb28a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1