diff --git a/FireExtinguisherEnemy.gd b/FireExtinguisherEnemy.gd deleted file mode 100644 index d3c05d6..0000000 --- a/FireExtinguisherEnemy.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends KinematicBody2D -class_name FireExtinguisherEnemy - - -func _ready(): - $AttractedToMovement.goal = get_tree().root.find_node("*/Fire") - diff --git a/project.godot b/project.godot index daf47e4..59ad3e7 100644 --- a/project.godot +++ b/project.godot @@ -44,11 +44,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/behaviours/movement/ErraticMovement.gd" }, { -"base": "KinematicBody2D", -"class": "FireExtinguisherEnemy", -"language": "GDScript", -"path": "res://FireExtinguisherEnemy.gd" -}, { "base": "Node", "class": "Flammable", "language": "GDScript", @@ -117,7 +112,6 @@ _global_script_class_icons={ "Damaging": "", "DropLoot": "", "ErraticMovement": "", -"FireExtinguisherEnemy": "", "Flammable": "", "FourSidedSprite": "", "FreeWhenShapeIsOffScreen": "", diff --git a/src/behaviours/damage/Damageable.gd b/src/behaviours/damage/Damageable.gd index d7814d3..98b4278 100644 --- a/src/behaviours/damage/Damageable.gd +++ b/src/behaviours/damage/Damageable.gd @@ -1,11 +1,15 @@ extends Node +signal health_changed(value) +signal dead + + export var health: int = 1 setget set_health, get_health export var max_health: int = 1 -signal health_changed(value) -signal dead + +onready var parent: Node = get_parent() func set_health(value): @@ -13,6 +17,9 @@ func set_health(value): emit_signal("health_changed", value) if health <= 0: emit_signal("dead") + # WIP + parent.queue_free() + func get_health(): return health diff --git a/src/behaviours/damage/Damaging.gd b/src/behaviours/damage/Damaging.gd index 632af5c..c795878 100644 --- a/src/behaviours/damage/Damaging.gd +++ b/src/behaviours/damage/Damaging.gd @@ -25,4 +25,8 @@ func do_damage(to: Node): damageable.health -= damage # Alas, destroy self if destroy_on_damage: - queue_free() + parent.queue_free() + + +func do_damage_to_collider(collision: KinematicCollision2D): + do_damage(collision.collider) diff --git a/src/entities/bullets/AbstractBullet.tscn b/src/entities/bullets/AbstractBullet.tscn index cf23b94..2158d82 100644 --- a/src/entities/bullets/AbstractBullet.tscn +++ b/src/entities/bullets/AbstractBullet.tscn @@ -13,3 +13,5 @@ collision_mask = 2 [node name="Ownership" parent="." instance=ExtResource( 2 )] [node name="Damaging" parent="." instance=ExtResource( 3 )] + +[connection signal="hit" from="BulletMovement" to="Damaging" method="do_damage_to_collider"] diff --git a/src/entities/enemies/ChaserEnemy.tscn b/src/entities/enemies/ChaserEnemy.tscn index fbde14d..74684c7 100644 --- a/src/entities/enemies/ChaserEnemy.tscn +++ b/src/entities/enemies/ChaserEnemy.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://src/entities/enemies/EnemySnowmanLeft.png" type="Texture" id=1] [ext_resource path="res://src/behaviours/movement/ErraticMovement.tscn" type="PackedScene" id=2] [ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=3] [ext_resource path="res://src/entities/enemies/AbstractEnemy.tscn" type="PackedScene" id=4] -[ext_resource path="res://FireExtinguisherEnemy.gd" type="Script" id=5] [ext_resource path="res://src/entities/enemies/EnemySnowmanBack.png" type="Texture" id=6] [ext_resource path="res://src/entities/enemies/EnemySnowmanFront.png" type="Texture" id=7] [ext_resource path="res://src/entities/enemies/EnemySnowmanRight.png" type="Texture" id=8] @@ -38,7 +37,6 @@ animations = [ { } ] [node name="ChaserEnemy" instance=ExtResource( 4 )] -script = ExtResource( 5 ) [node name="Shape" type="CollisionShape2D" parent="." index="0"] shape = SubResource( 1 ) diff --git a/src/entities/fire/Fire.tscn b/src/entities/fire/Fire.tscn index 851e228..e68150b 100644 --- a/src/entities/fire/Fire.tscn +++ b/src/entities/fire/Fire.tscn @@ -35,7 +35,7 @@ collision_mask = 4 [node name="Light" type="Light2D" parent="Flame"] texture = ExtResource( 1 ) texture_scale = 0.5 -color = Color( 1, 0.607843, 0, 1 ) +color = Color( 1, 0.792157, 0.392157, 1 ) [node name="Shape" type="CollisionShape2D" parent="Flame"] position = Vector2( 0, -20 ) diff --git a/src/levels/Game.tscn b/src/levels/Game.tscn index a7099b7..435f73a 100644 --- a/src/levels/Game.tscn +++ b/src/levels/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=21 format=2] [ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1] [ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2] @@ -7,11 +7,44 @@ [ext_resource path="res://src/mechanics/RNG.tscn" type="PackedScene" id=5] [ext_resource path="res://src/levels/Game.gd" type="Script" id=6] [ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7] -[ext_resource path="res://src/mechanics/ScreenEdgeSpawner.tscn" type="PackedScene" id=8] -[ext_resource path="res://src/entities/enemies/ChaserEnemy.tscn" type="PackedScene" id=9] -[ext_resource path="res://src/behaviours/targeting/SetSpawnedGoalTo.tscn" type="PackedScene" id=10] +[ext_resource path="res://src/entities/enemies/EnemySnowmanLeft.png" type="Texture" id=8] +[ext_resource path="res://src/behaviours/damage/Alliance.tscn" type="PackedScene" id=9] +[ext_resource path="res://src/entities/enemies/EnemySnowmanBack.png" type="Texture" id=10] [ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11] +[ext_resource path="res://src/behaviours/damage/Damageable.tscn" type="PackedScene" id=12] +[ext_resource path="res://src/entities/enemies/EnemySnowmanFront.png" type="Texture" id=13] [ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14] +[ext_resource path="res://src/behaviours/spawning/DropLoot.tscn" type="PackedScene" id=15] +[ext_resource path="res://src/entities/enemies/EnemySnowmanRight.png" type="Texture" id=16] +[ext_resource path="res://src/behaviours/graphics/FourSidedSprite.tscn" type="PackedScene" id=17] +[ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=18] + +[sub_resource type="CapsuleShape2D" id=1] +radius = 9.0 +height = 10.0 + +[sub_resource type="SpriteFrames" id=2] +animations = [ { +"frames": [ ExtResource( 8 ) ], +"loop": true, +"name": "left", +"speed": 5.0 +}, { +"frames": [ ExtResource( 16 ) ], +"loop": true, +"name": "right", +"speed": 5.0 +}, { +"frames": [ ExtResource( 10 ) ], +"loop": true, +"name": "up", +"speed": 5.0 +}, { +"frames": [ ExtResource( 13 ) ], +"loop": true, +"name": "down", +"speed": 5.0 +} ] [node name="Game" type="Node2D"] script = ExtResource( 6 ) @@ -49,7 +82,7 @@ position = Vector2( 596, 268 ) [node name="Fire" parent="PhaseOne/Entities" instance=ExtResource( 3 )] position = Vector2( 640, 320 ) -intensity = 1.0 +intensity = 2.0 [node name="Pickups" type="Node" parent="PhaseOne/Entities"] @@ -57,20 +90,29 @@ intensity = 1.0 [node name="Enemies" type="Node" parent="PhaseOne/Entities"] -[node name="ScreenEdgeSpawner" parent="PhaseOne/Entities/Enemies" instance=ExtResource( 8 )] -spawning = ExtResource( 9 ) -bounds = Vector2( 1280, 640 ) -period_secs = 1.0 +[node name="ChaserEnemy" type="KinematicBody2D" parent="PhaseOne/Entities/Enemies"] +position = Vector2( 800, 307 ) +scale = Vector2( 8, 8 ) +collision_layer = 3 -[node name="SetSpawnedGoalTo" parent="PhaseOne/Entities/Enemies/ScreenEdgeSpawner" instance=ExtResource( 10 )] -goal_path = NodePath("../../../Fire") +[node name="Shape" type="CollisionShape2D" parent="PhaseOne/Entities/Enemies/ChaserEnemy"] +shape = SubResource( 1 ) -[node name="ScreenEdgeSpawner2" parent="PhaseOne/Entities/Enemies" instance=ExtResource( 8 )] -spawning = ExtResource( 9 ) -bounds = Vector2( 1280, 640 ) -period_secs = 1.0 +[node name="FourSidedSprite" parent="PhaseOne/Entities/Enemies/ChaserEnemy/Shape" instance=ExtResource( 17 )] +frames = SubResource( 2 ) +animation = "down" -[node name="SetSpawnedGoalTo" parent="PhaseOne/Entities/Enemies/ScreenEdgeSpawner2" instance=ExtResource( 10 )] +[node name="Alliance" parent="PhaseOne/Entities/Enemies/ChaserEnemy" instance=ExtResource( 9 )] +alliance = -1 + +[node name="Damageable" parent="PhaseOne/Entities/Enemies/ChaserEnemy" instance=ExtResource( 12 )] +health = 250 +max_health = 250 + +[node name="DropLoot" parent="PhaseOne/Entities/Enemies/ChaserEnemy" instance=ExtResource( 15 )] + +[node name="AttractedToMovement" parent="PhaseOne/Entities/Enemies/ChaserEnemy" instance=ExtResource( 18 )] +movement_per_second = 64.0 goal_path = NodePath("../../../PhaseOnePlayer") [node name="UserInterface" type="CanvasLayer" parent="."] @@ -91,5 +133,4 @@ margin_right = 640.0 margin_left = 14.0 [connection signal="intensity_changed" from="PhaseOne/Entities/Fire" to="PhaseOne/Music" method="_on_Fire_intensity_changed"] -[connection signal="spawned" from="PhaseOne/Entities/Enemies/ScreenEdgeSpawner" to="PhaseOne/Entities/Enemies/ScreenEdgeSpawner/SetSpawnedGoalTo" method="set_goal"] -[connection signal="spawned" from="PhaseOne/Entities/Enemies/ScreenEdgeSpawner2" to="PhaseOne/Entities/Enemies/ScreenEdgeSpawner2/SetSpawnedGoalTo" method="set_goal"] +[connection signal="moving_in_direction" from="PhaseOne/Entities/Enemies/ChaserEnemy/AttractedToMovement" to="PhaseOne/Entities/Enemies/ChaserEnemy/Shape/FourSidedSprite" method="turn"]