Compare commits
No commits in common. "36dd21975cc7242060d5105f9e8d3f5c89f8c197" and "10e53ffc0980666b7fa83b6b96e31119bb68d2bc" have entirely different histories.
36dd21975c
...
10e53ffc09
|
@ -1,23 +1,12 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2.ZERO
|
||||
var speed = 128
|
||||
var poisoned = false
|
||||
var damage = 5
|
||||
var frozen = false
|
||||
var velocity = Vector2.ZERO
|
||||
var target
|
||||
|
||||
func _physics_process(delta):
|
||||
if target != null and is_instance_valid(target):
|
||||
if target != null:
|
||||
var target_texture = target.get_node("Sprite").frames.get_frame("idle", 0)
|
||||
var target_sprite_size = Vector2(target_texture.get_width(), target_texture.get_width())
|
||||
var target_center = target.global_position + (target_sprite_size / 2)
|
||||
self.global_position = self.global_position.move_toward(target_center, delta * speed)
|
||||
|
||||
func area_entered(area):
|
||||
var parent = area.get_parent()
|
||||
if parent.is_in_group("enemy"):
|
||||
parent.deal_damage(damage)
|
||||
parent.frozen = frozen
|
||||
parent.poisoned = poisoned
|
||||
call_deferred("free")
|
||||
|
|
|
@ -11,12 +11,6 @@ script = ExtResource( 2 )
|
|||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 3.5, 3.5 )
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="area_entered"]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 7, 9 )
|
||||
|
||||
[node name="Ghost" type="KinematicBody2D" groups=["enemy", "ghost"]]
|
||||
[node name="Ghost" type="KinematicBody2D" groups=["enemy"]]
|
||||
z_index = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
|
@ -14,7 +14,6 @@ script = ExtResource( 2 )
|
|||
use_parent_material = true
|
||||
frames = ExtResource( 1 )
|
||||
animation = "idle"
|
||||
frame = 1
|
||||
playing = true
|
||||
centered = false
|
||||
|
||||
|
|
|
@ -5,9 +5,6 @@ var dash_target = Vector2.ZERO
|
|||
var dash_timer = .0
|
||||
var dashing = false
|
||||
|
||||
func _ready():
|
||||
hp = 8
|
||||
|
||||
func _physics_process(delta):
|
||||
var dist = global_position.distance_to(player.global_position)
|
||||
if dist > 25 and dash_target == Vector2.ZERO:
|
||||
|
|
|
@ -72,14 +72,9 @@ func _shoot():
|
|||
bullet.global_position.y = self.global_position.y - 4
|
||||
|
||||
func _draw():
|
||||
if target != null and is_instance_valid(target):
|
||||
if target != null:
|
||||
var dist2enemy = position.distance_to(target.global_position)
|
||||
var mob_offset = Vector2.ZERO
|
||||
if target.is_in_group("bat"):
|
||||
mob_offset = Vector2(8, 7)
|
||||
if target.is_in_group("ghost"):
|
||||
mob_offset = Vector2(8, 12)
|
||||
draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + mob_offset, Color("ffde00"), 1)
|
||||
draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
|
||||
|
||||
func _process(_delta):
|
||||
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
||||
|
@ -92,9 +87,11 @@ func _physics_process(delta):
|
|||
get_input()
|
||||
|
||||
invincibility_timer += delta
|
||||
recharge_timer += delta
|
||||
|
||||
if recharge_timer <= get_recharge():
|
||||
recharge_timer += delta
|
||||
if recharge_timer >= get_recharge():
|
||||
_shoot()
|
||||
recharge_timer = .0
|
||||
|
||||
var areas = $EnemyCollision.get_overlapping_areas()
|
||||
slowed = false
|
||||
|
@ -113,11 +110,4 @@ func _physics_process(delta):
|
|||
|
||||
velocity = move_and_slide(velocity * speed_multiplier)
|
||||
choose_target()
|
||||
|
||||
if target != null and is_instance_valid(target):
|
||||
target.material = outline_material
|
||||
|
||||
if recharge_timer >= get_recharge():
|
||||
_shoot()
|
||||
recharge_timer = .0
|
||||
|
||||
target.material = outline_material
|
||||
|
|
|
@ -4,35 +4,17 @@ var hp
|
|||
var poisoned = false
|
||||
var poisoned_timer = .0
|
||||
var speed_multiplier = 1
|
||||
var frozen_timer = .0
|
||||
var frozen_time = 2
|
||||
var poisoned_time = 3
|
||||
var poisoned_damage = 5
|
||||
var poison_damage_timer = .0
|
||||
|
||||
var frozen = false
|
||||
|
||||
func deal_damage(amount):
|
||||
hp -= amount
|
||||
if hp <= 0:
|
||||
call_deferred("free")
|
||||
|
||||
func _physics_process(delta):
|
||||
if poisoned:
|
||||
poisoned_timer += delta
|
||||
poison_damage_timer += delta
|
||||
if poisoned_timer >= poisoned_time:
|
||||
poisoned_timer = .0
|
||||
poison_damage_timer = .0
|
||||
poisoned = false
|
||||
if poison_damage_timer >= 1:
|
||||
deal_damage(poisoned_damage)
|
||||
|
||||
func check_frozen():
|
||||
speed_multiplier = 1
|
||||
if frozen:
|
||||
frozen_timer += delta
|
||||
speed_multiplier = 0.5
|
||||
if frozen_timer >= frozen_time:
|
||||
frozen_time = 0
|
||||
frozen = false
|
||||
else:
|
||||
speed_multiplier = 1
|
||||
|
||||
func check_poisoned():
|
||||
if poisoned_timer >= 1:
|
||||
hp -= 5
|
||||
|
||||
func _physics_process(_delta):
|
||||
check_frozen()
|
||||
check_poisoned()
|
||||
|
|
Loading…
Reference in New Issue