Wall implemented
This commit is contained in:
@ -1,12 +1,17 @@
|
||||
extends Node2D
|
||||
|
||||
var follower = false
|
||||
var health = 100
|
||||
static var NAMES = ["Forkman", "Cobold", "Ork"]
|
||||
|
||||
func _ready() -> void:
|
||||
follower = true
|
||||
if name.contains("Mine"):
|
||||
get_node("CharacterBody2D/AnimatedSprite2D").connect("animation_finished", Callable(self, "Remove_Mine"))
|
||||
set_process_input(true)
|
||||
|
||||
if name.contains("Wall"):
|
||||
get_node("CharacterBody2D/ProgressBar").hide()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if follower:
|
||||
@ -26,3 +31,34 @@ func Explode_Mine() -> void:
|
||||
|
||||
func Remove_Mine() -> void:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_area_2d_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
if follower == false:
|
||||
get_node("CharacterBody2D/Timer").start()
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
get_node("CharacterBody2D/ProgressBar").show()
|
||||
i.get_parent().set_process(false)
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
var minus = 0
|
||||
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
minus += 1
|
||||
|
||||
health -= minus
|
||||
get_node("CharacterBody2D/ProgressBar").value = health
|
||||
if minus == 0:
|
||||
get_node("CharacterBody2D/Timer").stop()
|
||||
|
||||
if health <= 0:
|
||||
for i in get_node("CharacterBody2D/Area2D").get_overlapping_bodies():
|
||||
for j in NAMES:
|
||||
if i.get_parent().name.contains(j):
|
||||
i.get_parent().set_process(true)
|
||||
queue_free()
|
||||
|
Reference in New Issue
Block a user