Merged with previous commit
This commit is contained in:
@@ -10,66 +10,66 @@ var counter: int = 0
|
|||||||
signal demon_boss_death
|
signal demon_boss_death
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
|
|
||||||
if player and position.distance_to(player.position) > 1:
|
if player and position.distance_to(player.position) > 1:
|
||||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||||
var angle = position.angle_to_point(player.position)
|
var angle = position.angle_to_point(player.position)
|
||||||
if abs(angle) > PI/2:
|
if abs(angle) > PI/2:
|
||||||
$AnimatedSprite1.scale.x = -0.563
|
$AnimatedSprite1.scale.x = -0.563
|
||||||
else:
|
else:
|
||||||
$AnimatedSprite1.scale.x = 0.563
|
$AnimatedSprite1.scale.x = 0.563
|
||||||
|
|
||||||
if hit == true:
|
if hit == true:
|
||||||
if counter < 15:
|
if counter < 15:
|
||||||
if counter % 5 == 0:
|
if counter % 5 == 0:
|
||||||
$AnimatedSprite1.visible = false
|
$AnimatedSprite1.visible = false
|
||||||
else:
|
else:
|
||||||
$AnimatedSprite1.visible = true
|
$AnimatedSprite1.visible = true
|
||||||
counter += 1
|
counter += 1
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
else:
|
else:
|
||||||
hit = false
|
hit = false
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
velocity = move_and_slide(velocity)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_entered(body: Node) -> void:
|
func _on_player_detector_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Walk'
|
$AnimatedSprite1.animation = 'Walk'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_exited(body: Node) -> void:
|
func _on_player_detector_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = null
|
player = null
|
||||||
$AnimatedSprite1.animation = 'Idle'
|
$AnimatedSprite1.animation = 'Idle'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
hit = true
|
hit = true
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
hit = true
|
hit = true
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
emit_signal("demon_boss_death")
|
emit_signal("demon_boss_death")
|
||||||
return
|
return
|
||||||
|
|
||||||
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Attack'
|
$AnimatedSprite1.animation = 'Attack'
|
||||||
|
|
||||||
|
|
||||||
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Walk'
|
$AnimatedSprite1.animation = 'Walk'
|
||||||
|
@@ -26,5 +26,9 @@ func _on_NextArea_area_entered(area: Area2D) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_Demon_Boss_demon_boss_death() -> void:
|
func _on_Demon_Boss_demon_boss_death() -> void:
|
||||||
|
$Timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout() -> void:
|
||||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||||
queue_free()
|
queue_free()
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user