diff --git a/ai/Enemy.gd b/ai/Enemy.gd index 37ec697..d3cdd83 100644 --- a/ai/Enemy.gd +++ b/ai/Enemy.gd @@ -11,6 +11,9 @@ const UP = Vector2(0, -1) var velocity = Vector2() +func play_hit(): + $AnimationPlayer2.play("Hit") + func get_player_position(): return Player.position diff --git a/ai/Hell.gd b/ai/Hell.gd index c2959ff..b728811 100644 --- a/ai/Hell.gd +++ b/ai/Hell.gd @@ -8,6 +8,7 @@ onready var PlayerRaycast: RayCast2D = $PlayerRaycast func _ready(): health = 0.5 + knockback_amount = 700 func _physics_process(_delta): if knockback != Vector2.ZERO: diff --git a/ai/Hell.tscn b/ai/Hell.tscn index ef8ec09..21e9f2f 100644 --- a/ai/Hell.tscn +++ b/ai/Hell.tscn @@ -9,7 +9,7 @@ extents = Vector2( 5.06709, 5.78183 ) [sub_resource type="Animation" id=2] -length = 0.6 +length = 0.65 loop = true tracks/0/type = "value" tracks/0/path = NodePath("Hell:frame") @@ -30,11 +30,11 @@ collision_mask = 11 script = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( 0, 1.87833 ) +position = Vector2( 0, 2 ) shape = SubResource( 1 ) [node name="Hell" type="Sprite" parent="."] -position = Vector2( -7.56425, -7.87261 ) +position = Vector2( -8, -8 ) texture = ExtResource( 1 ) centered = false hframes = 8 diff --git a/levels/test.tscn b/levels/test.tscn index 48e089b..544cf4d 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2] -[ext_resource path="res://ai/Hell.tscn" type="PackedScene" id=3] -[ext_resource path="res://Music and Fonts(Misc.)/Main music.ogg" type="AudioStream" id=4] +[ext_resource path="res://ai/ogre.tscn" type="PackedScene" id=3] [node name="Node2D" type="Node2D"] @@ -13,10 +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="KinematicBody2D" parent="." instance=ExtResource( 3 )] -position = Vector2( 266, 142 ) - -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] -stream = ExtResource( 4 ) -volume_db = -14.136 -autoplay = true +[node name="Ogre" parent="." instance=ExtResource( 3 )] +position = Vector2( 345, 153 ) diff --git a/magic/Beams/Beam.gd b/magic/Beams/Beam.gd index 693bfd0..07f54bd 100644 --- a/magic/Beams/Beam.gd +++ b/magic/Beams/Beam.gd @@ -1,17 +1,26 @@ extends Node2D class_name Beam +var damage = 1 +var energy_cost = 1 + var max_cast = Vector2(400, 0) -onready var Beam: Sprite = $Beam -onready var Begin: Sprite = $Begin -onready var Ray: RayCast2D = $Raycast2D -onready var End: Position2D = $End +func get_collider(): + return $RayCast2D.get_collider() + +func activate(): + $Beam.visible = true + $RayCast2D.enabled = true + +func deactivate(): + $Beam.visible = false + $RayCast2D.enabled = false func _physics_process(delta): - Ray.cast_to = max_cast - if Ray.is_colliding(): - End.global_position = Ray.get_collision_point() + $RayCast2D.cast_to = max_cast + if $RayCast2D.is_colliding(): + $End.global_position = $RayCast2D.get_collision_point() else: - End.position = max_cast - Beam. + $End.position = max_cast + $Beam.region_rect.end.x = $End.position.length() diff --git a/magic/Beams/EcoBeam.gd b/magic/Beams/EcoBeam.gd index e251cf8..1847160 100644 --- a/magic/Beams/EcoBeam.gd +++ b/magic/Beams/EcoBeam.gd @@ -1 +1,4 @@ -extends Node2D +extends Beam + +func _ready(): + energy_cost = 1 diff --git a/magic/Beams/EcoBeam.tscn b/magic/Beams/EcoBeam.tscn index a0c1f93..1d73ced 100644 --- a/magic/Beams/EcoBeam.tscn +++ b/magic/Beams/EcoBeam.tscn @@ -18,5 +18,6 @@ region_rect = Rect2( 0, 0, 8, 8 ) [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/Projectiles/ExplosiveProjectile.gd b/magic/Projectiles/ExplosiveProjectile.gd index 56d81c6..b5c1e76 100644 --- a/magic/Projectiles/ExplosiveProjectile.gd +++ b/magic/Projectiles/ExplosiveProjectile.gd @@ -12,7 +12,7 @@ func on_impact(collision): elif bounces_left != 0: bounces_left -= 1 look_at(position + velocity.bounce(collision.normal)) - launch(null, null) + launch(null) else: explode() @@ -20,6 +20,8 @@ func explode(): for body in $Area2D.get_overlapping_bodies(): if body.get("health") != null and body.get_type() != "player": body.health -= damage + if body.has_method("play_hit"): + body.play_hit() $Particles2D.emitting = true $KillTimer.start() set_physics_process(false) diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index 159d75c..a8bbae0 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -37,7 +37,7 @@ func _physics_process(delta): if collision != null: on_impact(collision) -func launch(wand, effect): +func launch(wand): velocity = (Vector2(speed, 0)).rotated(rotation) get_wand_type(wand) return energy_cost * energy_mod @@ -46,10 +46,11 @@ 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 + c.play_hit() queue_free() elif bounces_left != 0: bounces_left -= 1 look_at(position + velocity.bounce(collision.normal)) - launch(null, null) + launch(null) else: queue_free() diff --git a/magic/Projectiles/WaveProjectile.gd b/magic/Projectiles/WaveProjectile.gd index 53168df..4bf566f 100644 --- a/magic/Projectiles/WaveProjectile.gd +++ b/magic/Projectiles/WaveProjectile.gd @@ -10,10 +10,11 @@ func on_impact(collision): var c = collision.collider c.health -= damage * damage_mod c.do_knockback(collision.normal) + c.play_hit() queue_free() elif bounces_left != 0: bounces_left -= 1 look_at(position + velocity.bounce(collision.normal)) - launch(null, null) + launch(null) else: queue_free() diff --git a/magic/Wands/PrismWand.gd b/magic/Wands/PrismWand.gd new file mode 100644 index 0000000..217d59b --- /dev/null +++ b/magic/Wands/PrismWand.gd @@ -0,0 +1,34 @@ +extends Wand + +func _ready(): + $ProjectileSpawn.add_child(Globals.ecobeam_ps.instance()) + $ProjectileSpawn/EcoBeam.deactivate() + +func get_beam_type(p): + if p == Globals.Magic[Globals.Projectile1]: + return $ProjectileSpawn/EcoBeam + elif p == Globals.Magic[Globals.Projectile2]: + return null + elif p == Globals.Magic[Globals.Projectile3]: + return null + elif p == Globals.Magic[Globals.Projectile4]: + return null + else: + return null + +func fire(projectile): + var beam = get_beam_type(projectile) + if beam != null: + beam.activate() + 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 + +func _input(event): + if event.is_action_released("shoot"): + for c in $ProjectileSpawn.get_children(): + c.deactivate() diff --git a/magic/Wands/PrismWand.tscn b/magic/Wands/PrismWand.tscn index f4d9456..a5a4bf4 100644 --- a/magic/Wands/PrismWand.tscn +++ b/magic/Wands/PrismWand.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=3 format=2] [ext_resource path="res://art/PrismaticWand.png" type="Texture" id=1] -[ext_resource path="res://magic/Wands/WandClass.gd" type="Script" id=2] +[ext_resource path="res://magic/Wands/PrismWand.gd" type="Script" id=2] [node name="PrismWand" type="Sprite"] -position = Vector2( 4, 0 ) +position = Vector2( 1, 0 ) rotation = 1.5708 texture = ExtResource( 1 ) offset = Vector2( 0, -10 ) @@ -15,5 +15,5 @@ position = Vector2( 0, -20 ) rotation = -1.5708 [node name="ShootDelay" type="Timer" parent="."] -wait_time = 0.3 +wait_time = 0.2 one_shot = true diff --git a/magic/Wands/TripleWand.gd b/magic/Wands/TripleWand.gd index 4b8f25f..75c619d 100644 --- a/magic/Wands/TripleWand.gd +++ b/magic/Wands/TripleWand.gd @@ -3,7 +3,7 @@ extends Wand func _ready(): wand_type = Globals.Conduit2 -func fire(projectile, effect): +func fire(projectile): if $ShootDelay.is_stopped() and projectile != null: var temp1 = projectile.instance() var temp2 = projectile.instance() @@ -14,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(wand_type, effect_type) - energy_cost += temp2.launch(wand_type, effect_type) - energy_cost += temp3.launch(wand_type, effect_type) + var energy_cost = temp1.launch(wand_type) + energy_cost += temp2.launch(wand_type) + energy_cost += temp3.launch(wand_type) $ShootDelay.start() return energy_cost diff --git a/magic/Wands/WandClass.gd b/magic/Wands/WandClass.gd index 6e19be0..bbd5498 100644 --- a/magic/Wands/WandClass.gd +++ b/magic/Wands/WandClass.gd @@ -1,13 +1,12 @@ extends Sprite class_name Wand var wand_type -var effect_type -func fire(projectile, effect): +func fire(projectile): 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(wand_type, effect_type) + var energy_cost = temp.launch(wand_type) $ShootDelay.start() return energy_cost diff --git a/project.godot b/project.godot index f3c8e77..f635f4f 100644 --- a/project.godot +++ b/project.godot @@ -161,11 +161,6 @@ 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/WandPosition.gd b/script/WandPosition.gd index 2c0ea3c..fac68af 100644 --- a/script/WandPosition.gd +++ b/script/WandPosition.gd @@ -12,7 +12,7 @@ func set_current_conduit(conduit): func _process(delta): if Input.is_action_pressed("shoot") and get_child_count() != 0 and parent.Stats.energy > 0 and not parent.Inventory.open: - var energy_cost = get_children()[0].fire(get_parent().Inventory.active_projectile, null) + var energy_cost = get_children()[0].fire(get_parent().Inventory.active_projectile) if energy_cost != null: parent.energy -= energy_cost parent.Stats.interrupt_regen() diff --git a/script/globals.gd b/script/globals.gd index 32e20a6..8d21657 100644 --- a/script/globals.gd +++ b/script/globals.gd @@ -17,10 +17,10 @@ var projectile2_ps = preload("res://magic/Projectiles/PhantomProjectile.tscn") var projectile3_ps = preload("res://magic/Projectiles/WaveProjectile.tscn") var projectile4_ps = preload("res://magic/Projectiles/ExplosiveProjectile.tscn") -var effect1_ps -var effect2_ps -var effect3_ps -var effect4_ps +var ecobeam_ps = preload("res://magic/Beams/EcoBeam.tscn") +var phasebeam_ps +var wavebeam_ps +var explosivebeam_ps var Magic: Array = [ conduit1_ps, @@ -31,10 +31,6 @@ var Magic: Array = [ projectile2_ps, projectile3_ps, projectile4_ps, - effect1_ps, - effect2_ps, - effect3_ps, - effect4_ps, ] ###