fleshy mines mk 2
This commit is contained in:
parent
4ad5c1877e
commit
6e4d0e77a2
3 changed files with 67 additions and 7 deletions
|
@ -2,12 +2,17 @@ extends "res://objects/enemy/enemy.gd"
|
|||
|
||||
const Explosion = preload("res://objects/enemy/explosion.tscn")
|
||||
|
||||
export var linked_shard: int
|
||||
|
||||
onready var chain = $Chain
|
||||
onready var hitbox = $Hitbox
|
||||
onready var respawn_time: float = 1.0
|
||||
onready var ground_cast = $GroundCast
|
||||
|
||||
var no_explosion := false
|
||||
var die_flag := false
|
||||
|
||||
func _ready():
|
||||
var ground_cast = $GroundCast
|
||||
ground_cast.force_raycast_update()
|
||||
if ground_cast.is_colliding():
|
||||
chain.points[1].y = chain.to_local(ground_cast.get_collision_point()).y
|
||||
|
@ -15,7 +20,14 @@ func _ready():
|
|||
func _process(delta):
|
||||
chain.points[0].x = hitbox.position.x
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Game.shards_collected[linked_shard] and not die_flag:
|
||||
die_flag = true
|
||||
kill_for_real()
|
||||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
if no_explosion:
|
||||
return
|
||||
if area.is_in_group("explosion"):
|
||||
var timer = get_tree().create_timer(0.2, false)
|
||||
timer.connect("timeout", self, "die")
|
||||
|
@ -26,16 +38,43 @@ func _on_Hitbox_area_entered(area):
|
|||
die()
|
||||
|
||||
func die():
|
||||
no_explosion = true
|
||||
if Game.shards_collected[linked_shard]:
|
||||
kill_for_real()
|
||||
return
|
||||
if blood:
|
||||
var death_particles = DeathParticles.instance()
|
||||
death_particles.global_position = hitbox.global_position
|
||||
death_particles.emitting = true
|
||||
get_parent().get_parent().add_child(death_particles)
|
||||
$Hitbox/Sprite.visible = false
|
||||
hitbox.monitoring = false
|
||||
$Hitbox/CollisionShape2D.disabled = true
|
||||
hitbox.monitorable = false
|
||||
yield(get_tree().create_timer(respawn_time), "timeout")
|
||||
hitbox.monitoring = false
|
||||
Audio.play_sound(death_sound, Audio.ac_die)
|
||||
yield(get_tree().create_timer(respawn_time, false), "timeout")
|
||||
$Hitbox/CollisionShape2D.disabled = false
|
||||
$Hitbox/Sprite.visible = true
|
||||
hitbox.monitorable = true
|
||||
hitbox.monitoring = true
|
||||
$Hitbox/Sprite.visible = true
|
||||
|
||||
no_explosion = false
|
||||
|
||||
func kill_for_real():
|
||||
hitbox.visible = false
|
||||
hitbox.monitorable = false
|
||||
hitbox.monitoring = false
|
||||
$Hitbox/CollisionShape2D.disabled = true
|
||||
if blood:
|
||||
var dist := 0.0
|
||||
while(true):
|
||||
var death_particles = DeathParticles.instance()
|
||||
death_particles.global_position = hitbox.global_position + Vector2(0.0, dist)
|
||||
death_particles.emitting = true
|
||||
get_parent().get_parent().add_child(death_particles)
|
||||
if dist < hitbox.to_local(ground_cast.get_collision_point()).y:
|
||||
dist += 8.0
|
||||
yield(get_tree().create_timer(0.05, false), "timeout")
|
||||
Audio.play_sound(death_sound, Audio.ac_die)
|
||||
else:
|
||||
break
|
||||
queue_free()
|
||||
|
|
|
@ -71,6 +71,7 @@ tracks/1/keys = {
|
|||
|
||||
[node name="Mine" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
linked_shard = 2
|
||||
|
||||
[node name="GroundCast" type="RayCast2D" parent="."]
|
||||
visible = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue