From c77e5f9dcb9435afc37f05154edfbe0a5fb5c62e Mon Sep 17 00:00:00 2001 From: Logan Date: Tue, 21 Jul 2020 18:08:31 -0500 Subject: [PATCH] Explosive projectile works with prism --- magic/Beams/Beam.gd | 1 + magic/Beams/EcoBeam.tscn | 6 ++++- magic/Beams/ExplosiveBeam.gd | 18 ++++++++++++++ magic/Beams/ExplosiveBeam.tscn | 21 +++++++++++++++- magic/Beams/PhantomBeam.gd | 13 +++++----- magic/Beams/PhantomBeam.tscn | 6 ++++- magic/Beams/WaveBeam.gd | 1 + magic/Beams/WaveBeam.tscn | 6 ++++- magic/ExplosionParticles.tscn | 27 ++++++++++++++++++++ magic/Projectiles/ExplosiveProjectile.tscn | 29 +++------------------- 10 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 magic/ExplosionParticles.tscn diff --git a/magic/Beams/Beam.gd b/magic/Beams/Beam.gd index 07f54bd..9ba830e 100644 --- a/magic/Beams/Beam.gd +++ b/magic/Beams/Beam.gd @@ -7,6 +7,7 @@ var energy_cost = 1 var max_cast = Vector2(400, 0) func get_collider(): + $FireSound.play(0.0) return $RayCast2D.get_collider() func activate(): diff --git a/magic/Beams/EcoBeam.tscn b/magic/Beams/EcoBeam.tscn index 7eec23c..5ac71ed 100644 --- a/magic/Beams/EcoBeam.tscn +++ b/magic/Beams/EcoBeam.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://magic/Beams/EcoBeam.png" type="Texture" id=1] [ext_resource path="res://magic/Beams/EcoBeam.gd" type="Script" id=2] +[ext_resource path="res://Sound Effects/EcoProjectile.wav" type="AudioStream" id=3] [node name="EcoBeam" type="Node2D"] script = ExtResource( 2 ) @@ -21,3 +22,6 @@ cast_to = Vector2( 400, 0 ) collision_mask = 6 [node name="End" type="Position2D" parent="."] + +[node name="FireSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 3 ) diff --git a/magic/Beams/ExplosiveBeam.gd b/magic/Beams/ExplosiveBeam.gd index 716ea9c..50e526a 100644 --- a/magic/Beams/ExplosiveBeam.gd +++ b/magic/Beams/ExplosiveBeam.gd @@ -3,3 +3,21 @@ extends Beam func _ready(): damage = 3 energy_cost = 5 + +func activate(): + $Beam.visible = true + $RayCast2D.enabled = true + $End/Area2D.monitoring = true + +func deactivate(): + $Beam.visible = false + $RayCast2D.enabled = false + $End/Area2D.monitoring = false + +func get_collider(): + $FireSound.play(0.0) + $End/Particles2D.emitting = true + var r = [] + for b in $End/Area2D.get_overlapping_bodies(): + r.append(b) + return r diff --git a/magic/Beams/ExplosiveBeam.tscn b/magic/Beams/ExplosiveBeam.tscn index 7c5ae6c..94a8807 100644 --- a/magic/Beams/ExplosiveBeam.tscn +++ b/magic/Beams/ExplosiveBeam.tscn @@ -1,7 +1,12 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://magic/Beams/ExplosiveBeam.gd" type="Script" id=1] [ext_resource path="res://magic/Beams/ExplosiveBeam.png" type="Texture" id=2] +[ext_resource path="res://Sound Effects/Explosion.wav" type="AudioStream" id=3] +[ext_resource path="res://magic/ExplosionParticles.tscn" type="PackedScene" id=4] + +[sub_resource type="CircleShape2D" id=1] +radius = 50.0 [node name="ExplosiveBeam" type="Node2D"] script = ExtResource( 1 ) @@ -21,3 +26,17 @@ cast_to = Vector2( 400, 0 ) collision_mask = 6 [node name="End" type="Position2D" parent="."] + +[node name="Area2D" type="Area2D" parent="End"] +monitorable = false +collision_layer = 0 +collision_mask = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="End/Area2D"] +shape = SubResource( 1 ) + +[node name="Particles2D" parent="End" instance=ExtResource( 4 )] +one_shot = false + +[node name="FireSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 3 ) diff --git a/magic/Beams/PhantomBeam.gd b/magic/Beams/PhantomBeam.gd index 6887fa4..fe0c6e8 100644 --- a/magic/Beams/PhantomBeam.gd +++ b/magic/Beams/PhantomBeam.gd @@ -9,17 +9,18 @@ func activate(): $RayCast2D.enabled = true $Area2D.monitoring = true -func get_collider(): - var r = [] - for b in $Area2D.get_overlapping_bodies(): - r.append(b) - return r - func deactivate(): $Beam.visible = false $RayCast2D.enabled = false $Area2D.monitoring = false +func get_collider(): + $FireSound.play(0.0) + var r = [] + for b in $Area2D.get_overlapping_bodies(): + r.append(b) + return r + func _physics_process(delta): $RayCast2D.cast_to = max_cast if $RayCast2D.is_colliding(): diff --git a/magic/Beams/PhantomBeam.tscn b/magic/Beams/PhantomBeam.tscn index 85c8043..40c3008 100644 --- a/magic/Beams/PhantomBeam.tscn +++ b/magic/Beams/PhantomBeam.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://magic/Beams/PhantomBeam.png" type="Texture" id=1] [ext_resource path="res://magic/Beams/PhantomBeam.gd" type="Script" id=2] +[ext_resource path="res://Sound Effects/PhantomProjectile.wav" type="AudioStream" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 4, 4 ) @@ -34,3 +35,6 @@ collision_mask = 4 modulate = Color( 0.945313, 1, 0, 1 ) position = Vector2( 4, 0 ) shape = SubResource( 1 ) + +[node name="FireSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 3 ) diff --git a/magic/Beams/WaveBeam.gd b/magic/Beams/WaveBeam.gd index 4c7d48b..75526f4 100644 --- a/magic/Beams/WaveBeam.gd +++ b/magic/Beams/WaveBeam.gd @@ -5,6 +5,7 @@ func _ready(): damage = 1 func get_collider(): + $FireSound.play(0.0) var c = $RayCast2D.get_collider() if c != null and c.has_method("get_type") and c.get_type() == "enemy": print("knock") diff --git a/magic/Beams/WaveBeam.tscn b/magic/Beams/WaveBeam.tscn index 2fb98ce..0cfb2d5 100644 --- a/magic/Beams/WaveBeam.tscn +++ b/magic/Beams/WaveBeam.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://magic/Beams/WaveBeam.gd" type="Script" id=1] [ext_resource path="res://magic/Beams/KnockbackBeam.png" type="Texture" id=2] +[ext_resource path="res://Sound Effects/WaveProjectile.wav" type="AudioStream" id=3] [node name="WaveBeam" type="Node2D"] script = ExtResource( 1 ) @@ -21,3 +22,6 @@ cast_to = Vector2( 400, 0 ) collision_mask = 6 [node name="End" type="Position2D" parent="."] + +[node name="FireSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 3 ) diff --git a/magic/ExplosionParticles.tscn b/magic/ExplosionParticles.tscn new file mode 100644 index 0000000..20ac09f --- /dev/null +++ b/magic/ExplosionParticles.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=2] + +[sub_resource type="Gradient" id=2] +offsets = PoolRealArray( 0.0120482, 0.192771, 0.534137, 1 ) +colors = PoolColorArray( 1, 0.449219, 0.449219, 1, 1, 0, 0, 1, 1, 0.351563, 0, 1, 0.155762, 0.155762, 0.155762, 1 ) + +[sub_resource type="GradientTexture" id=3] +gradient = SubResource( 2 ) + +[sub_resource type="ParticlesMaterial" id=4] +emission_shape = 1 +emission_sphere_radius = 1.0 +flag_disable_z = true +spread = 180.0 +gravity = Vector3( 0, 0, 0 ) +initial_velocity = 50.0 +orbit_velocity = 0.0 +orbit_velocity_random = 0.0 +color_ramp = SubResource( 3 ) + +[node name="Particles2D" type="Particles2D"] +emitting = false +amount = 200 +one_shot = true +speed_scale = 2.5 +explosiveness = 0.8 +process_material = SubResource( 4 ) diff --git a/magic/Projectiles/ExplosiveProjectile.tscn b/magic/Projectiles/ExplosiveProjectile.tscn index 89ee41e..34383ed 100644 --- a/magic/Projectiles/ExplosiveProjectile.tscn +++ b/magic/Projectiles/ExplosiveProjectile.tscn @@ -1,30 +1,13 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://art/MineProjectile.png" type="Texture" id=1] [ext_resource path="res://magic/Projectiles/ExplosiveProjectile.gd" type="Script" id=2] [ext_resource path="res://Sound Effects/Explosion.wav" type="AudioStream" id=3] +[ext_resource path="res://magic/ExplosionParticles.tscn" type="PackedScene" id=4] [sub_resource type="CircleShape2D" id=1] radius = 6.0 -[sub_resource type="Gradient" id=2] -offsets = PoolRealArray( 0.0120482, 0.192771, 0.534137, 1 ) -colors = PoolColorArray( 1, 0.449219, 0.449219, 1, 1, 0, 0, 1, 1, 0.351563, 0, 1, 0.155762, 0.155762, 0.155762, 1 ) - -[sub_resource type="GradientTexture" id=3] -gradient = SubResource( 2 ) - -[sub_resource type="ParticlesMaterial" id=4] -emission_shape = 1 -emission_sphere_radius = 1.0 -flag_disable_z = true -spread = 180.0 -gravity = Vector3( 0, 0, 0 ) -initial_velocity = 50.0 -orbit_velocity = 0.0 -orbit_velocity_random = 0.0 -color_ramp = SubResource( 3 ) - [sub_resource type="CircleShape2D" id=5] radius = 50.0 @@ -41,13 +24,7 @@ texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) -[node name="Particles2D" type="Particles2D" parent="."] -emitting = false -amount = 200 -one_shot = true -speed_scale = 2.5 -explosiveness = 0.8 -process_material = SubResource( 4 ) +[node name="Particles2D" parent="." instance=ExtResource( 4 )] [node name="Area2D" type="Area2D" parent="."] visible = false