mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-22 04:34:19 +00:00
✨ Allow arrows to catch on fire
This commit is contained in:
parent
3cd2ac2a39
commit
4e24e3465e
7 changed files with 93 additions and 9 deletions
|
@ -14,6 +14,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/behaviours/damage/Alliance.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "ArrowAlternative",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/entities/bullets/ArrowAlternative.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "AttractedToMovement",
|
||||
"language": "GDScript",
|
||||
|
@ -44,6 +49,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://FireExtinguisherEnemy.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Flammable",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/behaviours/damage/Flammable.gd"
|
||||
}, {
|
||||
"base": "AnimatedSprite",
|
||||
"class": "FourSidedSprite",
|
||||
"language": "GDScript",
|
||||
|
@ -91,12 +101,14 @@ _global_script_classes=[ {
|
|||
} ]
|
||||
_global_script_class_icons={
|
||||
"Alliance": "",
|
||||
"ArrowAlternative": "",
|
||||
"AttractedToMovement": "",
|
||||
"BulletMovement": "",
|
||||
"Damaging": "",
|
||||
"DropLoot": "",
|
||||
"ErraticMovement": "",
|
||||
"FireExtinguisherEnemy": "",
|
||||
"Flammable": "",
|
||||
"FourSidedSprite": "",
|
||||
"Ownership": "",
|
||||
"PlayerMovement": "",
|
||||
|
|
19
src/behaviours/damage/Flammable.gd
Normal file
19
src/behaviours/damage/Flammable.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends Node
|
||||
class_name Flammable
|
||||
|
||||
|
||||
signal caught_fire
|
||||
signal extinguished_fire
|
||||
|
||||
|
||||
var on_fire = false
|
||||
|
||||
|
||||
func catch_fire():
|
||||
if not on_fire:
|
||||
emit_signal("caught_fire")
|
||||
|
||||
|
||||
func extinguish_fire():
|
||||
if on_fire:
|
||||
emit_signal("extinguished_fire")
|
6
src/behaviours/damage/Flammable.tscn
Normal file
6
src/behaviours/damage/Flammable.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/behaviours/damage/Flammable.gd" type="Script" id=1]
|
||||
|
||||
[node name="Flammable" type="Node"]
|
||||
script = ExtResource( 1 )
|
19
src/entities/bullets/ArrowAlternative.gd
Normal file
19
src/entities/bullets/ArrowAlternative.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends KinematicBody2D
|
||||
class_name ArrowAlternative
|
||||
|
||||
|
||||
export var dim_texture: Texture = preload("res://src/entities/bullets/ArrowAlternative.png")
|
||||
export var dim_damage: int = 1
|
||||
|
||||
export var lit_texture: Texture = preload("res://src/entities/bullets/ArrowAlternativeOnFire.png")
|
||||
export var lit_damage: int = 5
|
||||
|
||||
|
||||
func _on_Flammable_caught_fire():
|
||||
$Shape/Sprite.texture = lit_texture
|
||||
$Damaging.damage = lit_damage
|
||||
|
||||
|
||||
func _on_Flammable_extinguished_fire():
|
||||
$Shape/Sprite.texture = dim_texture
|
||||
$Damaging.damage = dim_damage
|
|
@ -1,12 +1,15 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://src/entities/bullets/AbstractBullet.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/entities/bullets/ArrowAlternative.png" type="Texture" id=2]
|
||||
[ext_resource path="res://src/entities/bullets/ArrowAlternative.gd" type="Script" id=3]
|
||||
[ext_resource path="res://src/behaviours/damage/Flammable.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 6, 1.5 )
|
||||
|
||||
[node name="ArrowAlternative" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource( 1 )
|
||||
|
@ -16,3 +19,8 @@ texture = ExtResource( 2 )
|
|||
|
||||
[node name="BulletMovement" parent="." index="1"]
|
||||
movement_per_second = 400.0
|
||||
|
||||
[node name="Flammable" parent="." index="4" instance=ExtResource( 4 )]
|
||||
|
||||
[connection signal="caught_fire" from="Flammable" to="." method="_on_Flammable_caught_fire"]
|
||||
[connection signal="extinguished_fire" from="Flammable" to="." method="_on_Flammable_extinguished_fire"]
|
||||
|
|
|
@ -18,7 +18,7 @@ signal intensity_reached_max
|
|||
func set_intensity(value):
|
||||
intensity = clamp(value, min_intensity, max_intensity)
|
||||
# Update everything that needs to be updated when the intensity changes
|
||||
$Light.scale = Vector2(value, value)
|
||||
$Flame.scale = Vector2(value, value)
|
||||
# Trigger signals
|
||||
emit_signal("intensity_changed", intensity)
|
||||
# max intensity signal
|
||||
|
@ -41,3 +41,9 @@ func set_intensity(value):
|
|||
|
||||
func _process(delta):
|
||||
set_intensity(intensity + (delta * change_per_second))
|
||||
|
||||
|
||||
func _on_Flame_body_entered(body: PhysicsBody2D):
|
||||
var flammable = body.get_node("Flammable")
|
||||
if flammable != null:
|
||||
flammable.catch_fire()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://src/mechanics/Light.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/entities/fire/FirePit.png" type="Texture" id=2]
|
||||
|
@ -9,27 +9,41 @@
|
|||
radius = 20.0
|
||||
height = 10.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
radius = 14.0
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=2]
|
||||
blend_mode = 1
|
||||
|
||||
[node name="Fire" type="StaticBody2D"]
|
||||
[node name="Fire" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
[node name="Firepit" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="Firepit"]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Shape"]
|
||||
[node name="Sprite" type="Sprite" parent="Firepit/Shape"]
|
||||
rotation = -1.5708
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Light" type="Light2D" parent="."]
|
||||
[node name="Flame" type="Area2D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
|
||||
[node name="Light" type="Light2D" parent="Flame"]
|
||||
texture = ExtResource( 1 )
|
||||
texture_scale = 0.5
|
||||
color = Color( 1, 0.607843, 0, 1 )
|
||||
|
||||
[node name="FlameSprite" type="Sprite" parent="Light"]
|
||||
[node name="Shape" type="CollisionShape2D" parent="Flame"]
|
||||
position = Vector2( 0, -20 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="FlameSprite" type="Sprite" parent="Flame/Shape"]
|
||||
material = SubResource( 2 )
|
||||
z_index = 1
|
||||
texture = ExtResource( 4 )
|
||||
offset = Vector2( 0, -20 )
|
||||
|
||||
[connection signal="body_entered" from="Flame" to="." method="_on_Flame_body_entered"]
|
||||
|
|
Loading…
Reference in a new issue