Sagi Dayan
08cf3e1462
- Player now has an attack move - Player wall jump more refined - New Enemy superclass for patrol type enemies - Goblin enemy. - Player abilty toggles. Can turn on/off wall_jump/attack/dash [WIP]
38 lines
928 B
GDScript
38 lines
928 B
GDScript
tool
|
|
extends Enemy
|
|
|
|
|
|
func _on_Area2D_body_entered(body: Node) -> void:
|
|
if not _damage_enabled: return
|
|
if body.name == 'Player':
|
|
var player:Player = body
|
|
player.die()
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
if not _is_alive: return
|
|
if _triggerd and _damage_enabled:
|
|
var player_direction = (_player_ref.position - position).normalized()
|
|
$Sprite.scale = Vector2(-1 if player_direction.x < 0 else 1, 1)
|
|
if _get_pit_direction() == 0 and dont_fall_patrol:
|
|
_velocity.x = $Sprite.scale.x * walking_speed * 2
|
|
else:
|
|
_velocity.x = 0
|
|
_velocity.y += gravity * delta
|
|
$AnimationPlayer.play("attack")
|
|
_velocity = move_and_slide(_velocity, Vector2.UP)
|
|
pass
|
|
|
|
|
|
|
|
|
|
func _on_TriggerZone_body_entered(body: Node) -> void:
|
|
if body.name == 'Player':
|
|
_triggerd = true
|
|
_player_ref = body
|
|
|
|
|
|
func _on_TriggerZone_body_exited(body: Node) -> void:
|
|
if body.name == 'Player':
|
|
_triggerd = false
|
|
_player_ref = null
|