From d057391c550456cbd0f46e608d9aeed350723d1c Mon Sep 17 00:00:00 2001 From: Logan Date: Sun, 19 Jul 2020 23:16:44 -0500 Subject: [PATCH] Added triple wand --- magic/Wands/TripleWand.gd | 19 +++++++++++++++++++ magic/Wands/TripleWand.tscn | 7 ++++++- magic/Wands/WandClass.gd | 2 +- project.godot | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 magic/Wands/TripleWand.gd diff --git a/magic/Wands/TripleWand.gd b/magic/Wands/TripleWand.gd new file mode 100644 index 0000000..8cb3ba5 --- /dev/null +++ b/magic/Wands/TripleWand.gd @@ -0,0 +1,19 @@ +extends Wand + + +func fire(projectile, effect): + if $ShootDelay.is_stopped() and projectile != null: + var temp1 = projectile.instance() + var temp2 = projectile.instance() + var temp3 = projectile.instance() + get_tree().current_scene.add_child(temp1) + get_tree().current_scene.add_child(temp2) + get_tree().current_scene.add_child(temp3) + temp1.global_transform = $ProjectileSpawn1.global_transform + temp2.global_transform = $ProjectileSpawn2.global_transform + temp3.global_transform = $ProjectileSpawn3.global_transform + var energy_cost = temp1.launch(null, null) + temp2.launch(null, null) + temp3.launch(null, null) + $ShootDelay.start() + return energy_cost diff --git a/magic/Wands/TripleWand.tscn b/magic/Wands/TripleWand.tscn index 56b4b14..0c8b8cf 100644 --- a/magic/Wands/TripleWand.tscn +++ b/magic/Wands/TripleWand.tscn @@ -1,9 +1,10 @@ [gd_scene load_steps=3 format=2] [ext_resource path="res://art/TripleWand.png" type="Texture" id=1] -[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2] +[ext_resource path="res://magic/Wands/TripleWand.gd" type="Script" id=2] [node name="TripleWand" type="Sprite"] +position = Vector2( 2, -2 ) rotation = 1.5708 texture = ExtResource( 1 ) offset = Vector2( 0, -11 ) @@ -11,12 +12,16 @@ script = ExtResource( 2 ) [node name="ProjectileSpawn1" type="Position2D" parent="."] position = Vector2( -5.00007, -20 ) +rotation = -1.64061 [node name="ProjectileSpawn2" type="Position2D" parent="."] position = Vector2( -8.01086e-05, -22 ) +rotation = -1.6057 [node name="ProjectileSpawn3" type="Position2D" parent="."] position = Vector2( 4.99993, -20 ) +rotation = -1.5708 [node name="ShootDelay" type="Timer" parent="."] wait_time = 0.3 +one_shot = true diff --git a/magic/Wands/WandClass.gd b/magic/Wands/WandClass.gd index 67b1874..eb00024 100644 --- a/magic/Wands/WandClass.gd +++ b/magic/Wands/WandClass.gd @@ -1,5 +1,5 @@ extends Sprite -class_name Wands +class_name Wand func fire(projectile, effect): if $ShootDelay.is_stopped() and projectile != null: diff --git a/project.godot b/project.godot index 673fb89..7773123 100644 --- a/project.godot +++ b/project.godot @@ -30,7 +30,7 @@ _global_script_classes=[ { "path": "res://script/StateMachine.gd" }, { "base": "Sprite", -"class": "Wands", +"class": "Wand", "language": "GDScript", "path": "res://magic/Wands/WandClass.gd" } ] @@ -39,7 +39,7 @@ _global_script_class_icons={ "Enemy": "", "Projectile": "", "StateMachine": "", -"Wands": "" +"Wand": "" } [application]