From 6b52d24e742220ac01a692694103b346d7908b78 Mon Sep 17 00:00:00 2001 From: Logan Date: Tue, 21 Jul 2020 17:49:04 -0500 Subject: [PATCH] Fix? --- Area2D.gd | 4 ++-- Items/Door.tscn | 1 + Player/PlayerVariables.gd | 2 +- levels/World.tscn | 2 +- levels/test.tscn | 6 +++--- magic/Beams/EcoBeam.gd | 3 ++- magic/Beams/EcoBeam.tscn | 1 - magic/Beams/ExplosiveBeam.gd | 5 +++++ magic/Beams/ExplosiveBeam.tscn | 23 ++++++++++++++++++++++ magic/Beams/PhantomBeam.gd | 31 +++++++++++++++++++++++++++++ magic/Beams/PhantomBeam.tscn | 36 ++++++++++++++++++++++++++++++++++ magic/Beams/WaveBeam.gd | 12 ++++++++++++ magic/Beams/WaveBeam.tscn | 23 ++++++++++++++++++++++ magic/Wands/PrismWand.gd | 26 +++++++++++++++++------- project.godot | 5 +++++ script/globals.gd | 6 +++--- 16 files changed, 167 insertions(+), 19 deletions(-) create mode 100644 magic/Beams/ExplosiveBeam.gd create mode 100644 magic/Beams/ExplosiveBeam.tscn create mode 100644 magic/Beams/PhantomBeam.gd create mode 100644 magic/Beams/PhantomBeam.tscn create mode 100644 magic/Beams/WaveBeam.gd create mode 100644 magic/Beams/WaveBeam.tscn diff --git a/Area2D.gd b/Area2D.gd index b6f8155..d5e1065 100644 --- a/Area2D.gd +++ b/Area2D.gd @@ -6,5 +6,5 @@ func _process(delta): if get_overlapping_bodies().size() != 0: print("1") if Input.is_action_pressed("open"): - Player.current_scene = "res://levels/World.tscn" - get_tree().change_scene("res://levels/test.tscn") + Player.current_scene = "res://levels/Level 1.tscn" + get_tree().change_scene("res://levels/Level 1.tscn") diff --git a/Items/Door.tscn b/Items/Door.tscn index eb41718..a67b79f 100644 --- a/Items/Door.tscn +++ b/Items/Door.tscn @@ -26,6 +26,7 @@ extents = Vector2( 14, 13 ) texture = ExtResource( 1 ) centered = false hframes = 2 +frame = 1 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] "anims/Door Opening" = SubResource( 1 ) diff --git a/Player/PlayerVariables.gd b/Player/PlayerVariables.gd index f3c98a2..ba2b79f 100644 --- a/Player/PlayerVariables.gd +++ b/Player/PlayerVariables.gd @@ -3,7 +3,7 @@ extends Node var position: Vector2 = Vector2() var health = null var energy = null -var unlocked: Array = [Globals.Conduit2] +var unlocked: Array = [] var current_scene: String func respawn(): diff --git a/levels/World.tscn b/levels/World.tscn index 1f0e083..bb929dc 100644 --- a/levels/World.tscn +++ b/levels/World.tscn @@ -176,7 +176,7 @@ __meta__ = { } [node name="Player" parent="." instance=ExtResource( 2 )] -position = Vector2( -25.7683, 148.492 ) +position = Vector2( 1919.33, 146.658 ) [node name="text" type="Node2D" parent="."] position = Vector2( -5.81107, -6.20908 ) diff --git a/levels/test.tscn b/levels/test.tscn index ea8101c..61ca700 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -7,13 +7,13 @@ [node name="Node2D" type="Node2D"] [node name="TileMap" parent="." instance=ExtResource( 2 )] -tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 10, 65557, 0, 10, 65558, 0, 10, 65559, 0, 10, 65560, 0, 10, 65561, 0, 10, 65562, 0, 10, 65563, 0, 10, 65564, 0, 10, 65565, 0, 10, 65566, 0, 10, 65567, 0, 10, 65568, 0, 10, 65569, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 196617, 131092, 0, 196617, 131093, 0, 196617, 131094, 0, 196617, 131095, 0, 196617, 131096, 0, 196617, 131097, 0, 196617, 131098, 0, 196617, 131099, 0, 196617, 131100, 0, 196617, 131101, 0, 196617, 131102, 0, 196617, 131103, 0, 196617, 131104, 0, 196617, 131105, 0, 196619, 196608, 0, 65544, 196609, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589858, 0, 8, 589859, 0, 11, 655360, 0, 65544, 655361, 0, 131083, 655394, 0, 65544, 655395, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 10, 720916, 0, 10, 720917, 0, 10, 720918, 0, 10, 720919, 0, 10, 720920, 0, 10, 720921, 0, 10, 720922, 0, 10, 720923, 0, 10, 720924, 0, 10, 720925, 0, 10, 720926, 0, 10, 720927, 0, 10, 720928, 0, 10, 720929, 0, 10, 720930, 0, 65541, 720931, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196617, 786453, 0, 196617, 786454, 0, 196617, 786455, 0, 196617, 786456, 0, 196617, 786457, 0, 196617, 786458, 0, 196617, 786459, 0, 196617, 786460, 0, 196617, 786461, 0, 196617, 786462, 0, 196617, 786463, 0, 196617, 786464, 0, 196617, 786465, 0, 196617, 786466, 0, 196617, 786467, 0, 196619 ) +tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 10, 65557, 0, 10, 65558, 0, 10, 65559, 0, 10, 65560, 0, 10, 65561, 0, 10, 65562, 0, 10, 65563, 0, 10, 65564, 0, 10, 65565, 0, 10, 65566, 0, 10, 65567, 0, 10, 65568, 0, 10, 65569, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 196617, 131092, 0, 196617, 131093, 0, 196617, 131094, 0, 196617, 131095, 0, 196617, 131096, 0, 196617, 131097, 0, 196617, 131098, 0, 196617, 131099, 0, 196617, 131100, 0, 196617, 131101, 0, 196617, 131102, 0, 196617, 131103, 0, 196617, 131104, 0, 196617, 131105, 0, 196619, 196608, 0, 65544, 196609, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589838, 0, 0, 589858, 0, 8, 589859, 0, 11, 655360, 0, 65544, 655361, 0, 131083, 655374, 0, 65540, 655375, 0, 11, 655394, 0, 65544, 655395, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 65541, 720911, 0, 65542, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 10, 720916, 0, 10, 720917, 0, 10, 720918, 0, 10, 720919, 0, 10, 720920, 0, 10, 720921, 0, 10, 720922, 0, 10, 720923, 0, 10, 720924, 0, 10, 720925, 0, 10, 720926, 0, 10, 720927, 0, 10, 720928, 0, 10, 720929, 0, 10, 720930, 0, 65541, 720931, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196617, 786453, 0, 196617, 786454, 0, 196617, 786455, 0, 196617, 786456, 0, 196617, 786457, 0, 196617, 786458, 0, 196617, 786459, 0, 196617, 786460, 0, 196617, 786461, 0, 196617, 786462, 0, 196617, 786463, 0, 196617, 786464, 0, 196617, 786465, 0, 196617, 786466, 0, 196617, 786467, 0, 196619 ) [node name="Player" parent="." instance=ExtResource( 1 )] position = Vector2( 60, 176 ) [node name="Ogre" parent="." instance=ExtResource( 3 )] -position = Vector2( 366, 166 ) +position = Vector2( 286, 170 ) [node name="Ogre2" parent="." instance=ExtResource( 3 )] -position = Vector2( 430, 164 ) +position = Vector2( 347, 159 ) diff --git a/magic/Beams/EcoBeam.gd b/magic/Beams/EcoBeam.gd index 1847160..20e954e 100644 --- a/magic/Beams/EcoBeam.gd +++ b/magic/Beams/EcoBeam.gd @@ -1,4 +1,5 @@ extends Beam func _ready(): - energy_cost = 1 + energy_cost = 0 + damage = 0.5 diff --git a/magic/Beams/EcoBeam.tscn b/magic/Beams/EcoBeam.tscn index 6406a33..7eec23c 100644 --- a/magic/Beams/EcoBeam.tscn +++ b/magic/Beams/EcoBeam.tscn @@ -3,7 +3,6 @@ [ext_resource path="res://magic/Beams/EcoBeam.png" type="Texture" id=1] [ext_resource path="res://magic/Beams/EcoBeam.gd" type="Script" id=2] - [node name="EcoBeam" type="Node2D"] script = ExtResource( 2 ) diff --git a/magic/Beams/ExplosiveBeam.gd b/magic/Beams/ExplosiveBeam.gd new file mode 100644 index 0000000..716ea9c --- /dev/null +++ b/magic/Beams/ExplosiveBeam.gd @@ -0,0 +1,5 @@ +extends Beam + +func _ready(): + damage = 3 + energy_cost = 5 diff --git a/magic/Beams/ExplosiveBeam.tscn b/magic/Beams/ExplosiveBeam.tscn new file mode 100644 index 0000000..7c5ae6c --- /dev/null +++ b/magic/Beams/ExplosiveBeam.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=3 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] + +[node name="ExplosiveBeam" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Beam" type="Sprite" parent="."] +position = Vector2( 0, -4 ) +texture = ExtResource( 2 ) +centered = false +region_enabled = true +region_rect = Rect2( 0, 0, 8, 8 ) + +[node name="Begin" type="Sprite" parent="."] + +[node name="RayCast2D" type="RayCast2D" parent="."] +enabled = true +cast_to = Vector2( 400, 0 ) +collision_mask = 6 + +[node name="End" type="Position2D" parent="."] diff --git a/magic/Beams/PhantomBeam.gd b/magic/Beams/PhantomBeam.gd new file mode 100644 index 0000000..6887fa4 --- /dev/null +++ b/magic/Beams/PhantomBeam.gd @@ -0,0 +1,31 @@ +extends Beam + +func _ready(): + energy_cost = 3 + damage = 1 + +func activate(): + $Beam.visible = true + $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 _physics_process(delta): + $RayCast2D.cast_to = max_cast + if $RayCast2D.is_colliding(): + $End.global_position = $RayCast2D.get_collision_point() + else: + $End.position = max_cast + $Beam.region_rect.end.x = $End.position.length() + $Area2D/CollisionShape2D.shape.extents.x = $End.position.length() / 2 + $Area2D.position.x = $End.position.length() / 2 diff --git a/magic/Beams/PhantomBeam.tscn b/magic/Beams/PhantomBeam.tscn new file mode 100644 index 0000000..85c8043 --- /dev/null +++ b/magic/Beams/PhantomBeam.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=4 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] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 4, 4 ) + +[node name="PhantomBeam" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Beam" type="Sprite" parent="."] +position = Vector2( 0, -4 ) +texture = ExtResource( 1 ) +centered = false +region_enabled = true +region_rect = Rect2( 0, 0, 8, 8 ) + +[node name="Begin" type="Sprite" parent="."] + +[node name="RayCast2D" type="RayCast2D" parent="."] +enabled = true +cast_to = Vector2( 400, 0 ) +collision_mask = 2 + +[node name="End" type="Position2D" parent="."] + +[node name="Area2D" type="Area2D" parent="."] +monitorable = false +collision_layer = 0 +collision_mask = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +modulate = Color( 0.945313, 1, 0, 1 ) +position = Vector2( 4, 0 ) +shape = SubResource( 1 ) diff --git a/magic/Beams/WaveBeam.gd b/magic/Beams/WaveBeam.gd new file mode 100644 index 0000000..4c7d48b --- /dev/null +++ b/magic/Beams/WaveBeam.gd @@ -0,0 +1,12 @@ +extends Beam + +func _ready(): + energy_cost = 2 + damage = 1 + +func get_collider(): + var c = $RayCast2D.get_collider() + if c != null and c.has_method("get_type") and c.get_type() == "enemy": + print("knock") + c.do_knockback($RayCast2D.get_collision_normal()) + return $RayCast2D.get_collider() diff --git a/magic/Beams/WaveBeam.tscn b/magic/Beams/WaveBeam.tscn new file mode 100644 index 0000000..2fb98ce --- /dev/null +++ b/magic/Beams/WaveBeam.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=3 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] + +[node name="WaveBeam" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Beam" type="Sprite" parent="."] +position = Vector2( 0, -4 ) +texture = ExtResource( 2 ) +centered = false +region_enabled = true +region_rect = Rect2( 0, 0, 8, 8 ) + +[node name="Begin" type="Sprite" parent="."] + +[node name="RayCast2D" type="RayCast2D" parent="."] +enabled = true +cast_to = Vector2( 400, 0 ) +collision_mask = 6 + +[node name="End" type="Position2D" parent="."] diff --git a/magic/Wands/PrismWand.gd b/magic/Wands/PrismWand.gd index 217d59b..1d6a5ee 100644 --- a/magic/Wands/PrismWand.gd +++ b/magic/Wands/PrismWand.gd @@ -3,16 +3,22 @@ extends Wand func _ready(): $ProjectileSpawn.add_child(Globals.ecobeam_ps.instance()) $ProjectileSpawn/EcoBeam.deactivate() + $ProjectileSpawn.add_child(Globals.phantombeam_ps.instance()) + $ProjectileSpawn/PhantomBeam.deactivate() + $ProjectileSpawn.add_child(Globals.wavebeam_ps.instance()) + $ProjectileSpawn/WaveBeam.deactivate() + $ProjectileSpawn.add_child(Globals.explosivebeam_ps.instance()) + $ProjectileSpawn/ExplosiveBeam.deactivate() func get_beam_type(p): if p == Globals.Magic[Globals.Projectile1]: return $ProjectileSpawn/EcoBeam elif p == Globals.Magic[Globals.Projectile2]: - return null + return $ProjectileSpawn/PhantomBeam elif p == Globals.Magic[Globals.Projectile3]: - return null + return $ProjectileSpawn/WaveBeam elif p == Globals.Magic[Globals.Projectile4]: - return null + return $ProjectileSpawn/ExplosiveBeam else: return null @@ -23,10 +29,16 @@ func fire(projectile): if $ShootDelay.is_stopped(): $ShootDelay.start() var c = beam.get_collider() - print(c) - if c != null and c.has_method("get_type") && c.get_type() == "enemy": - c.health -= beam.damage - return beam.energy_cost + if typeof(c) == TYPE_ARRAY: + for body in c: + if body != null and body.has_method("get_type") && body.get_type() == "enemy": + body.health -= beam.damage + body.play_hit() + else: + if c != null and c.has_method("get_type") && c.get_type() == "enemy": + c.health -= beam.damage + c.play_hit() + return 0 func _input(event): if event.is_action_released("shoot"): diff --git a/project.godot b/project.godot index f635f4f..f3c8e77 100644 --- a/project.godot +++ b/project.godot @@ -161,6 +161,11 @@ inventory={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) ] } +open={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"unicode":0,"echo":false,"script":null) + ] +} [layer_names] diff --git a/script/globals.gd b/script/globals.gd index 8d21657..a459c96 100644 --- a/script/globals.gd +++ b/script/globals.gd @@ -18,9 +18,9 @@ var projectile3_ps = preload("res://magic/Projectiles/WaveProjectile.tscn") var projectile4_ps = preload("res://magic/Projectiles/ExplosiveProjectile.tscn") var ecobeam_ps = preload("res://magic/Beams/EcoBeam.tscn") -var phasebeam_ps -var wavebeam_ps -var explosivebeam_ps +var phantombeam_ps = preload("res://magic/Beams/PhantomBeam.tscn") +var wavebeam_ps = preload("res://magic/Beams/WaveBeam.tscn") +var explosivebeam_ps = preload("res://magic/Beams/ExplosiveBeam.tscn") var Magic: Array = [ conduit1_ps,