Peashooters
This commit is contained in:
parent
161f87da75
commit
68cfe89f1d
47 changed files with 1571 additions and 279 deletions
|
|
@ -0,0 +1,33 @@
|
|||
extends Node
|
||||
|
||||
const projectile := preload("uid://ciqhjwh4sfe3u")
|
||||
|
||||
@export var projectile_transform : Marker2D
|
||||
|
||||
var detected : bool = false
|
||||
var can_shoot : bool = true
|
||||
|
||||
@onready var timer := $Timer
|
||||
@onready var entity : Entity = get_parent()
|
||||
|
||||
func is_shooting():
|
||||
return detected and can_shoot and entity.disabled == false
|
||||
|
||||
func _on_generic_hurtbox_collision_start() -> void:
|
||||
detected = true
|
||||
|
||||
func _on_generic_hurtbox_collision_end() -> void:
|
||||
detected = false
|
||||
|
||||
func shoot():
|
||||
if can_shoot == false:
|
||||
return
|
||||
can_shoot = false
|
||||
timer.start()
|
||||
var proj = projectile.instantiate()
|
||||
get_tree().current_scene.get_node("%Projectiles").add_child(proj)
|
||||
proj.global_transform = projectile_transform.global_transform
|
||||
proj.source = entity
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
can_shoot = true
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b0ka8lb5kl1fd
|
||||
29
scripts/components/controllers/zombies/basic_controller.gd
Normal file
29
scripts/components/controllers/zombies/basic_controller.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
extends Node
|
||||
|
||||
var eating:
|
||||
get:
|
||||
return is_eating()
|
||||
var walking:
|
||||
get:
|
||||
return is_walking()
|
||||
|
||||
@export var hurtbox : GenericHurtbox
|
||||
@export var damage : float
|
||||
@onready var disablable := get_parent()
|
||||
|
||||
var killed := false
|
||||
|
||||
func _on_entity_killed(_context: RefCounted) -> void:
|
||||
if killed: return
|
||||
$"../AnimationTree"["parameters/main/playback"].travel("death")
|
||||
killed = true
|
||||
|
||||
func is_eating() -> bool:
|
||||
return hurtbox.is_colliding() and disablable.disabled == false
|
||||
|
||||
func is_walking() -> bool:
|
||||
return disablable.disabled == false
|
||||
|
||||
func bite() -> void:
|
||||
if hurtbox.is_colliding() == false: return
|
||||
hurtbox.get_colliding_entity().deal_damage(damage,get_parent())
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bg88vb74hinkj
|
||||
Loading…
Add table
Add a link
Reference in a new issue