1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-22 04:34:19 +00:00

💥 Boom

This commit is contained in:
Steffo 2022-04-04 22:22:25 +02:00
parent 057a06212b
commit e1164b3871
Signed by: steffo
GPG key ID: 6965406171929D01
17 changed files with 113 additions and 12 deletions

View file

@ -69,6 +69,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/behaviours/graphics/FourSidedSprite.gd" "path": "res://src/behaviours/graphics/FourSidedSprite.gd"
}, { }, {
"base": "Node",
"class": "FreeOnRequest",
"language": "GDScript",
"path": "res://src/behaviours/damage/FreeOnRequest.gd"
}, {
"base": "VisibilityNotifier2D", "base": "VisibilityNotifier2D",
"class": "FreeWhenShapeIsOffScreen", "class": "FreeWhenShapeIsOffScreen",
"language": "GDScript", "language": "GDScript",
@ -90,6 +95,11 @@ _global_script_classes=[ {
"path": "res://src/behaviours/damage/Ownership.gd" "path": "res://src/behaviours/damage/Ownership.gd"
}, { }, {
"base": "Node", "base": "Node",
"class": "PathMovement",
"language": "GDScript",
"path": "res://src/behaviours/movement/PathMovement.gd"
}, {
"base": "Node",
"class": "PlayerMovement", "class": "PlayerMovement",
"language": "GDScript", "language": "GDScript",
"path": "res://src/behaviours/movement/PlayerMovement.gd" "path": "res://src/behaviours/movement/PlayerMovement.gd"
@ -162,10 +172,12 @@ _global_script_class_icons={
"Fire": "", "Fire": "",
"Flammable": "", "Flammable": "",
"FourSidedSprite": "", "FourSidedSprite": "",
"FreeOnRequest": "",
"FreeWhenShapeIsOffScreen": "", "FreeWhenShapeIsOffScreen": "",
"Music": "", "Music": "",
"MuteButton": "", "MuteButton": "",
"Ownership": "", "Ownership": "",
"PathMovement": "",
"PlayerMovement": "", "PlayerMovement": "",
"RNG": "", "RNG": "",
"RandomRotationOnReady": "", "RandomRotationOnReady": "",

View file

@ -31,4 +31,11 @@ func do_damage(to, multiplier):
damageable.health += damage * multiplier damageable.health += damage * multiplier
# Emit the signal # Emit the signal
emit_signal("damaged", self, to) emit_signal("damaged", self, to)
# Destroy self if necessary
if destroy_after_damage:
parent.queue_free()
func _on_BulletMovement_collided(_origin, collision):
do_damage(collision.collider, 1)

View file

@ -0,0 +1,9 @@
extends Node
class_name FreeOnRequest
onready var parent = get_parent()
func _on_Damageable_health_reached_min(_origin, _value):
parent.queue_free()

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/behaviours/damage/FreeOnRequest.gd" type="Script" id=1]
[node name="FreeOnRequest" type="Node"]
script = ExtResource( 1 )

View file

@ -8,7 +8,7 @@ const DOWN_RIGHT = TAU/8
const DOWN_LEFT = 3*TAU/8 const DOWN_LEFT = 3*TAU/8
func turn(direction: Vector2) -> String: func turn(direction):
var angle = direction.angle() var angle = direction.angle()
var anime var anime
@ -23,3 +23,7 @@ func turn(direction: Vector2) -> String:
play(anime) play(anime)
return animation return animation
func _on_AttractedToMovement_moved_in_direction(_origin, direction):
turn(direction)

View file

@ -0,0 +1,11 @@
extends Node
class_name PathMovement
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/behaviours/movement/PathMovement.gd" type="Script" id=1]
[sub_resource type="Curve2D" id=1]
_data = {
"points": PoolVector2Array( )
}
[node name="PathMovement" type="Node"]
script = ExtResource( 1 )
[node name="Path" type="Path2D" parent="."]
curve = SubResource( 1 )

View file

@ -45,3 +45,7 @@ func create_drop():
container.add_child(node) container.add_child(node)
node.set_position(source.global_position) node.set_position(source.global_position)
return node return node
func _on_Damageable_health_reached_min(_origin, _value):
create_drop()

View file

@ -14,3 +14,5 @@ collision_mask = 2
[node name="Damaging" parent="." instance=ExtResource( 3 )] [node name="Damaging" parent="." instance=ExtResource( 3 )]
destroy_after_damage = true destroy_after_damage = true
[connection signal="collided" from="BulletMovement" to="Damaging" method="_on_BulletMovement_collided"]

View file

@ -12,12 +12,10 @@ export(int) var lit_damage
func _on_Flammable_caught_fire(_origin): func _on_Flammable_caught_fire(_origin):
$Shape/Sprite.texture = lit_texture $Shape/Sprite.texture = lit_texture
$Damaging.damage = lit_damage $Damaging.damage = lit_damage
$Damaging.destroy_after_damage = false
$Light.visible = true $Light.visible = true
func _on_Flammable_extinguished_fire(_origin): func _on_Flammable_extinguished_fire(_origin):
$Shape/Sprite.texture = dim_texture $Shape/Sprite.texture = dim_texture
$Damaging.damage = dim_damage $Damaging.damage = dim_damage
$Damaging.destroy_after_damage = true
$Light.visible = false $Light.visible = false

View file

@ -14,9 +14,9 @@ extents = Vector2( 6, 1.5 )
[node name="Arrow" instance=ExtResource( 1 )] [node name="Arrow" instance=ExtResource( 1 )]
script = ExtResource( 3 ) script = ExtResource( 3 )
dim_texture = ExtResource( 2 ) dim_texture = ExtResource( 2 )
dim_damage = 1 dim_damage = -10
lit_texture = ExtResource( 7 ) lit_texture = ExtResource( 7 )
lit_damage = 5 lit_damage = -10
[node name="Shape" type="CollisionShape2D" parent="." index="0"] [node name="Shape" type="CollisionShape2D" parent="." index="0"]
shape = SubResource( 1 ) shape = SubResource( 1 )

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://src/behaviours/spawning/DropLoot.tscn" type="PackedScene" id=1] [ext_resource path="res://src/behaviours/spawning/DropLoot.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/entities/AbstractEntity.tscn" type="PackedScene" id=2] [ext_resource path="res://src/entities/AbstractEntity.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/behaviours/damage/FreeOnRequest.tscn" type="PackedScene" id=3]
[node name="AbstractEnemy" instance=ExtResource( 2 )] [node name="AbstractEnemy" instance=ExtResource( 2 )]
@ -10,3 +11,8 @@ alliance = -1
[node name="DropLoot" parent="." index="2" instance=ExtResource( 1 )] [node name="DropLoot" parent="." index="2" instance=ExtResource( 1 )]
container_name = "Pickups" container_name = "Pickups"
[node name="FreeOnRequest" parent="." index="3" instance=ExtResource( 3 )]
[connection signal="health_reached_min" from="Damageable" to="DropLoot" method="_on_Damageable_health_reached_min"]
[connection signal="health_reached_min" from="Damageable" to="FreeOnRequest" method="_on_Damageable_health_reached_min"]

View file

@ -46,8 +46,14 @@ shape = SubResource( 1 )
frames = SubResource( 2 ) frames = SubResource( 2 )
animation = "down" animation = "down"
[node name="Damageable" parent="." index="2"]
max_health = 10.0
health = 10.0
[node name="DropLoot" parent="." index="3"] [node name="DropLoot" parent="." index="3"]
loot_types = [ null, ExtResource( 2 ), ExtResource( 5 ) ] loot_types = [ null, ExtResource( 2 ), ExtResource( 5 ) ]
loot_weights = [ 1.0, 1.0, 0.1 ] loot_weights = [ 1.0, 1.0, 0.1 ]
[node name="AttractedToMovement" parent="." index="4" instance=ExtResource( 3 )] [node name="AttractedToMovement" parent="." index="5" instance=ExtResource( 3 )]
[connection signal="moved_in_direction" from="AttractedToMovement" to="Shape/FourSidedSprite" method="_on_AttractedToMovement_moved_in_direction"]

View file

@ -39,7 +39,7 @@ position = Vector2( 421, -275 )
scale = Vector2( 4, 4 ) scale = Vector2( 4, 4 )
[node name="FlameSprite" parent="TheDarkNightUI/MenuFire/Flame/Shape" index="0"] [node name="FlameSprite" parent="TheDarkNightUI/MenuFire/Flame/Shape" index="0"]
frame = 3 frame = 5
[node name="Damaging" parent="TheDarkNightUI/MenuFire" index="3"] [node name="Damaging" parent="TheDarkNightUI/MenuFire" index="3"]
damage = -5.0 damage = -5.0

File diff suppressed because one or more lines are too long

View file

@ -32,5 +32,5 @@ func _on_body_entered(_other):
func set_active(value): func set_active(value):
active = value active = value
$Shape.visible = value $Shape.set_deferred("visible", value)
$Shape.disabled = not value $Shape.set_deferred("disabled", not value)

View file

@ -2,7 +2,7 @@ extends Node
class_name RapidFire class_name RapidFire
onready var target = get_tree().root.find_node("PhaseOnePlayer", true, false).get_node("ShootOnClick") onready var target = get_tree().root.find_node("PhaseOnePlayer", true, false).get_node("SpawnOnShoot/ShootOnClick")
onready var pickup: Area2D = get_parent() onready var pickup: Area2D = get_parent()