Fixed debugger errors in many files and optimized some scenes/code
This commit is contained in:
@@ -1,47 +1,49 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
onready var SNOWBALL_BLUE_SCENE = preload("res://Enemies/Snowball Blue.tscn")
|
||||
onready var SNOWBALL_BLUE_SCENE: Resource = preload('res://Enemies/Snowball Blue.tscn')
|
||||
|
||||
var player = null
|
||||
var move = Vector2.ZERO
|
||||
var speed = .5
|
||||
var player: KinematicBody2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
const SPEED: int = 50
|
||||
var health: int = 2
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move = Vector2.ZERO
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player != null:
|
||||
move = position.direction_to(player.position) * speed
|
||||
else:
|
||||
move = Vector2.ZERO
|
||||
|
||||
move = move.normalized()
|
||||
move = move_and_collide(move)
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body: Node) -> void:
|
||||
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_Area2D_body_exited(body: Node) -> void:
|
||||
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func fire():
|
||||
func fire() -> void:
|
||||
var snowball = SNOWBALL_BLUE_SCENE.instance()
|
||||
snowball.position = get_global_position()
|
||||
snowball.player = player
|
||||
get_parent().add_child(snowball)
|
||||
$Timer.set_wait_time(1)
|
||||
return
|
||||
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
if player != null:
|
||||
fire()
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
@@ -49,10 +51,11 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
func _on_player_detector_area_exited(_area: Area2D) -> void:
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
|
Reference in New Issue
Block a user