From 2b26e3fba098b198950b6b377e2f24c8aff684de Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 20 Jul 2020 16:36:28 -0500 Subject: [PATCH] work on wands --- ai/Enemy.gd | 2 +- art/door.png.import | 34 +++++++++++++++++++ levels/test.tscn | 6 +--- magic/Projectiles/EcoProjectile.gd | 1 + magic/Projectiles/EcoProjectile.tscn | 3 +- magic/Projectiles/ExplosiveProjectile.gd | 13 ++++++++ magic/Projectiles/ExplosiveProjectile.tscn | 5 +-- magic/Projectiles/PhantomProjectile.gd | 6 +++- magic/Projectiles/PhantomProjectile.tscn | 12 +++---- magic/Projectiles/Projectile.gd | 39 ++++++++++++++++++++-- magic/Projectiles/WaveProjectile.gd | 5 +++ magic/Projectiles/WaveProjectile.tscn | 6 ++-- magic/Wands/BouncyWand.gd | 4 +++ magic/Wands/BouncyWand.tscn | 2 +- magic/Wands/ChargedWand.gd | 16 +++++++++ magic/Wands/TripleWand.gd | 9 +++-- magic/Wands/WandClass.gd | 4 ++- project.godot | 9 +++++ ui/PlayerStats.tscn | 2 +- 19 files changed, 151 insertions(+), 27 deletions(-) create mode 100644 art/door.png.import create mode 100644 magic/Projectiles/WaveProjectile.gd create mode 100644 magic/Wands/BouncyWand.gd create mode 100644 magic/Wands/ChargedWand.gd diff --git a/ai/Enemy.gd b/ai/Enemy.gd index cc857ab..6740fe9 100644 --- a/ai/Enemy.gd +++ b/ai/Enemy.gd @@ -15,6 +15,6 @@ func get_type(): func apply_gravity(delta, modifier = 1): velocity.y += gravity * delta * modifier - if is_on_wall() and is_on_floor(): velocity.y = -150 + diff --git a/art/door.png.import b/art/door.png.import new file mode 100644 index 0000000..1920daa --- /dev/null +++ b/art/door.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/door.png-7e406854813fcf118164bcf195a745da.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/door.png" +dest_files=[ "res://.import/door.png-7e406854813fcf118164bcf195a745da.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/levels/test.tscn b/levels/test.tscn index bd419b9..3a13c05 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2] -[ext_resource path="res://Items/TripleWandPickup.tscn" type="PackedScene" id=3] [ext_resource path="res://ai/Skeleton Enemy.tscn" type="PackedScene" id=4] [node name="Node2D" type="Node2D"] @@ -13,8 +12,5 @@ tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, [node name="Player" parent="." instance=ExtResource( 1 )] position = Vector2( 60, 176 ) -[node name="TripleWand" parent="." instance=ExtResource( 3 )] -position = Vector2( 67, 168 ) - [node name="Skeleton Enemy" parent="." instance=ExtResource( 4 )] position = Vector2( 274, 164 ) diff --git a/magic/Projectiles/EcoProjectile.gd b/magic/Projectiles/EcoProjectile.gd index ea4d88d..a9e4b1a 100644 --- a/magic/Projectiles/EcoProjectile.gd +++ b/magic/Projectiles/EcoProjectile.gd @@ -3,3 +3,4 @@ extends Projectile func _ready(): energy_cost = 0 + damage = 0.5 diff --git a/magic/Projectiles/EcoProjectile.tscn b/magic/Projectiles/EcoProjectile.tscn index 8a57994..07e0a23 100644 --- a/magic/Projectiles/EcoProjectile.tscn +++ b/magic/Projectiles/EcoProjectile.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://magic/Projectiles/EcoProjectile.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] -radius = 5.09902 +radius = 6.08276 [node name="EcoProjectile" type="KinematicBody2D"] collision_layer = 8 @@ -12,6 +12,7 @@ collision_mask = 6 script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/magic/Projectiles/ExplosiveProjectile.gd b/magic/Projectiles/ExplosiveProjectile.gd index d1b5b34..56d81c6 100644 --- a/magic/Projectiles/ExplosiveProjectile.gd +++ b/magic/Projectiles/ExplosiveProjectile.gd @@ -2,8 +2,21 @@ extends Projectile func _ready(): damage = 3 + energy_cost = 5 func on_impact(collision): + if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy": + var c = collision.collider + c.health -= damage * damage_mod + explode() + elif bounces_left != 0: + bounces_left -= 1 + look_at(position + velocity.bounce(collision.normal)) + launch(null, null) + else: + explode() + +func explode(): for body in $Area2D.get_overlapping_bodies(): if body.get("health") != null and body.get_type() != "player": body.health -= damage diff --git a/magic/Projectiles/ExplosiveProjectile.tscn b/magic/Projectiles/ExplosiveProjectile.tscn index 6cbfa13..e6000e3 100644 --- a/magic/Projectiles/ExplosiveProjectile.tscn +++ b/magic/Projectiles/ExplosiveProjectile.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://magic/Projectiles/ExplosiveProjectile.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] -radius = 4.12311 +radius = 6.0 [sub_resource type="Gradient" id=3] offsets = PoolRealArray( 0.0120482, 0.192771, 0.534137, 1 ) @@ -34,6 +34,7 @@ script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] rotation = 0.785398 +scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] @@ -48,9 +49,9 @@ explosiveness = 0.8 process_material = SubResource( 5 ) [node name="Area2D" type="Area2D" parent="."] +visible = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -visible = false shape = SubResource( 2 ) [node name="KillTimer" type="Timer" parent="."] diff --git a/magic/Projectiles/PhantomProjectile.gd b/magic/Projectiles/PhantomProjectile.gd index e2f7846..8c5eac1 100644 --- a/magic/Projectiles/PhantomProjectile.gd +++ b/magic/Projectiles/PhantomProjectile.gd @@ -3,7 +3,11 @@ extends Projectile var ignore = [] +func _ready(): + energy_cost = 3 + damage = 1 + func _on_body_entered(body): if body.get("health") != null: - body.health -= 1 + body.health -= damage * damage_mod diff --git a/magic/Projectiles/PhantomProjectile.tscn b/magic/Projectiles/PhantomProjectile.tscn index 8d40986..52751a0 100644 --- a/magic/Projectiles/PhantomProjectile.tscn +++ b/magic/Projectiles/PhantomProjectile.tscn @@ -3,12 +3,12 @@ [ext_resource path="res://art/PhantomProjectile.png" type="Texture" id=1] [ext_resource path="res://magic/Projectiles/PhantomProjectile.gd" type="Script" id=2] -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 1, 4 ) +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 3, 6 ) [sub_resource type="CapsuleShape2D" id=2] -radius = 3.0 -height = 6.0 +radius = 4.0 +height = 7.99999 [node name="PhantomProjectile" type="KinematicBody2D"] collision_layer = 8 @@ -16,12 +16,12 @@ collision_mask = 2 script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -visible = false rotation = 1.5708 -shape = SubResource( 1 ) +shape = SubResource( 3 ) [node name="Area2D" type="Area2D" parent="."] monitorable = false diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index 8c8c6b6..159d75c 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -6,6 +6,32 @@ var velocity = Vector2.ZERO var energy_cost = 1 var damage = 1 +var damage_mod = 1 +var energy_mod = 1 +var bounces_left = 0 + +var is_bounce = false +var is_charge = false +var is_prism = false +var is_triple = false + +func get_wand_type(wand_id): + match wand_id: + Globals.Conduit1: + is_charge = true + print("charge") + Globals.Conduit2: + is_triple = true + print("triple") + var damage_mod = 0.75 + Globals.Conduit3: + is_bounce = true + print("bounce") + bounces_left = 1 + Globals.Conduit4: + print("prism") + is_prism = true + func _physics_process(delta): var collision = move_and_collide(velocity * delta) if collision != null: @@ -13,10 +39,17 @@ func _physics_process(delta): func launch(wand, effect): velocity = (Vector2(speed, 0)).rotated(rotation) - return energy_cost + get_wand_type(wand) + return energy_cost * energy_mod func on_impact(collision): if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy": var c = collision.collider - c.health -= damage - queue_free() + c.health -= damage * damage_mod + queue_free() + elif bounces_left != 0: + bounces_left -= 1 + look_at(position + velocity.bounce(collision.normal)) + launch(null, null) + else: + queue_free() diff --git a/magic/Projectiles/WaveProjectile.gd b/magic/Projectiles/WaveProjectile.gd new file mode 100644 index 0000000..e7b74fb --- /dev/null +++ b/magic/Projectiles/WaveProjectile.gd @@ -0,0 +1,5 @@ +extends Projectile + +func _ready(): + energy_cost = 2 + damage = 1 diff --git a/magic/Projectiles/WaveProjectile.tscn b/magic/Projectiles/WaveProjectile.tscn index e715434..1397157 100644 --- a/magic/Projectiles/WaveProjectile.tscn +++ b/magic/Projectiles/WaveProjectile.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://art/WaveProjectile.png" type="Texture" id=1] -[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2] +[ext_resource path="res://magic/Projectiles/WaveProjectile.gd" type="Script" id=2] [sub_resource type="CapsuleShape2D" id=1] -radius = 4.0 +radius = 5.0 height = 4.0 [node name="WaveProjectile" type="KinematicBody2D"] @@ -13,7 +13,9 @@ collision_mask = 6 script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( -1, 0 ) shape = SubResource( 1 ) diff --git a/magic/Wands/BouncyWand.gd b/magic/Wands/BouncyWand.gd new file mode 100644 index 0000000..4109204 --- /dev/null +++ b/magic/Wands/BouncyWand.gd @@ -0,0 +1,4 @@ +extends Wand + +func _ready(): + wand_type = Globals.Conduit3 diff --git a/magic/Wands/BouncyWand.tscn b/magic/Wands/BouncyWand.tscn index 45bce4f..e390962 100644 --- a/magic/Wands/BouncyWand.tscn +++ b/magic/Wands/BouncyWand.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=2] [ext_resource path="res://art/BouncingWand.png" type="Texture" id=1] -[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2] +[ext_resource path="res://magic/Wands/BouncyWand.gd" type="Script" id=2] [node name="BouncyWand" type="Sprite"] rotation = 1.5708 diff --git a/magic/Wands/ChargedWand.gd b/magic/Wands/ChargedWand.gd new file mode 100644 index 0000000..439f7a9 --- /dev/null +++ b/magic/Wands/ChargedWand.gd @@ -0,0 +1,16 @@ +extends Sprite + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/magic/Wands/TripleWand.gd b/magic/Wands/TripleWand.gd index 96385ad..4b8f25f 100644 --- a/magic/Wands/TripleWand.gd +++ b/magic/Wands/TripleWand.gd @@ -1,5 +1,8 @@ extends Wand +func _ready(): + wand_type = Globals.Conduit2 + func fire(projectile, effect): if $ShootDelay.is_stopped() and projectile != null: var temp1 = projectile.instance() @@ -11,8 +14,8 @@ func fire(projectile, effect): 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) + var energy_cost = temp1.launch(wand_type, effect_type) + energy_cost += temp2.launch(wand_type, effect_type) + energy_cost += temp3.launch(wand_type, effect_type) $ShootDelay.start() return energy_cost diff --git a/magic/Wands/WandClass.gd b/magic/Wands/WandClass.gd index eb00024..6e19be0 100644 --- a/magic/Wands/WandClass.gd +++ b/magic/Wands/WandClass.gd @@ -1,11 +1,13 @@ extends Sprite class_name Wand +var wand_type +var effect_type func fire(projectile, effect): if $ShootDelay.is_stopped() and projectile != null: var temp = projectile.instance() get_tree().current_scene.add_child(temp) temp.global_transform = $ProjectileSpawn.global_transform - var energy_cost = temp.launch(null, null) + var energy_cost = temp.launch(wand_type, effect_type) $ShootDelay.start() return energy_cost diff --git a/project.godot b/project.godot index 7eaf3f7..05af399 100644 --- a/project.godot +++ b/project.godot @@ -103,6 +103,15 @@ texture={ [input] +ui_accept={ +"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":16777221,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) +, 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) + ] +} ui_end={ "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":16777230,"unicode":0,"echo":false,"script":null) diff --git a/ui/PlayerStats.tscn b/ui/PlayerStats.tscn index 76cbb82..8d0da9d 100644 --- a/ui/PlayerStats.tscn +++ b/ui/PlayerStats.tscn @@ -10,7 +10,7 @@ script = ExtResource( 1 ) [node name="Regen" type="Timer" parent="."] -wait_time = 0.5 +wait_time = 0.2 one_shot = true [node name="Player UI Frame 2" type="Sprite" parent="."]