Stun
parent
c3f57e2315
commit
076976db2c
|
@ -7,6 +7,7 @@ var damage = 5
|
||||||
var freeze_modifier = 1
|
var freeze_modifier = 1
|
||||||
var bounced = 0
|
var bounced = 0
|
||||||
var ricochet_count = 0
|
var ricochet_count = 0
|
||||||
|
var damage_multiplier = 1
|
||||||
var prev_target
|
var prev_target
|
||||||
var target
|
var target
|
||||||
var explosive_damage = 0
|
var explosive_damage = 0
|
||||||
|
@ -39,7 +40,7 @@ func area_entered(area):
|
||||||
var parent = area.get_parent()
|
var parent = area.get_parent()
|
||||||
if parent.is_in_group("enemy") and parent != prev_target:
|
if parent.is_in_group("enemy") and parent != prev_target:
|
||||||
prev_target = parent
|
prev_target = parent
|
||||||
parent.deal_damage(damage)
|
parent.deal_damage(damage * damage_multiplier)
|
||||||
parent.freeze_modifier = freeze_modifier
|
parent.freeze_modifier = freeze_modifier
|
||||||
parent.frozen_timer = 0
|
parent.frozen_timer = 0
|
||||||
parent.poison_damage = poison_damage
|
parent.poison_damage = poison_damage
|
||||||
|
|
|
@ -16,7 +16,7 @@ use_parent_material = true
|
||||||
position = Vector2( -3, 0 )
|
position = Vector2( -3, 0 )
|
||||||
frames = ExtResource( 1 )
|
frames = ExtResource( 1 )
|
||||||
animation = "idle"
|
animation = "idle"
|
||||||
frame = 2
|
frame = 1
|
||||||
playing = true
|
playing = true
|
||||||
centered = false
|
centered = false
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,6 @@ visible = false
|
||||||
position = Vector2( 11, 2 )
|
position = Vector2( 11, 2 )
|
||||||
frames = ExtResource( 5 )
|
frames = ExtResource( 5 )
|
||||||
animation = "idle"
|
animation = "idle"
|
||||||
frame = 1
|
|
||||||
playing = true
|
playing = true
|
||||||
|
|
||||||
[node name="AudioGetDamage" type="AudioStreamPlayer" parent="."]
|
[node name="AudioGetDamage" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
|
@ -10,6 +10,7 @@ var speed_multiplier: float = 1.0
|
||||||
var invincibility_timer = .0
|
var invincibility_timer = .0
|
||||||
var velocity = Vector2.ZERO
|
var velocity = Vector2.ZERO
|
||||||
var recharge_timer = .0
|
var recharge_timer = .0
|
||||||
|
var stunned_timer = .0
|
||||||
var invincible = false
|
var invincible = false
|
||||||
var stunned = false
|
var stunned = false
|
||||||
var target
|
var target
|
||||||
|
@ -60,6 +61,7 @@ func choose_target():
|
||||||
|
|
||||||
func area_entered(area):
|
func area_entered(area):
|
||||||
var parent = area.get_parent()
|
var parent = area.get_parent()
|
||||||
|
if not is_instance_valid(parent): return
|
||||||
if parent.is_in_group("enemy") and not parent.is_in_group("bat") and not invincible:
|
if parent.is_in_group("enemy") and not parent.is_in_group("bat") and not invincible:
|
||||||
$AnimationPlayer.play("damage")
|
$AnimationPlayer.play("damage")
|
||||||
$AudioGetDamage.play()
|
$AudioGetDamage.play()
|
||||||
|
@ -67,6 +69,12 @@ func area_entered(area):
|
||||||
invincible = true
|
invincible = true
|
||||||
invincibility_timer = .0
|
invincibility_timer = .0
|
||||||
get_tree().get_root().get_node("Game/View/Camera2D").current = true
|
get_tree().get_root().get_node("Game/View/Camera2D").current = true
|
||||||
|
if is_instance_valid(parent) and parent.is_in_group("sonic_wave") and not stunned and not invincible:
|
||||||
|
stunned = true
|
||||||
|
$Stars.visible = true
|
||||||
|
stunned_timer = .0
|
||||||
|
recharge_timer = .0
|
||||||
|
$Sprite.play("stun")
|
||||||
|
|
||||||
func get_recharge():
|
func get_recharge():
|
||||||
var recharge = 2.0
|
var recharge = 2.0
|
||||||
|
@ -87,7 +95,7 @@ func _shoot():
|
||||||
for modifier in spell_holder.modifiers:
|
for modifier in spell_holder.modifiers:
|
||||||
match modifier:
|
match modifier:
|
||||||
"ricochet": ricochet_count += 1
|
"ricochet": ricochet_count += 1
|
||||||
"big_magic": dmg_multiplier *= 1.25
|
"big_magic": dmg_multiplier *= 1.5
|
||||||
"explode": explosive_damage += 10
|
"explode": explosive_damage += 10
|
||||||
"fireball": fireball_amount += 1
|
"fireball": fireball_amount += 1
|
||||||
"freeze": freeze_modifier /= 2.0
|
"freeze": freeze_modifier /= 2.0
|
||||||
|
@ -97,7 +105,7 @@ func _shoot():
|
||||||
bullet = bullet_preload.instance()
|
bullet = bullet_preload.instance()
|
||||||
bullet.target = target
|
bullet.target = target
|
||||||
|
|
||||||
bullet.damage *= dmg_multiplier
|
bullet.damage_multiplier = dmg_multiplier
|
||||||
bullet.scale = Vector2(dmg_multiplier, dmg_multiplier)
|
bullet.scale = Vector2(dmg_multiplier, dmg_multiplier)
|
||||||
bullet.explosive_damage = explosive_damage
|
bullet.explosive_damage = explosive_damage
|
||||||
bullet.freeze_modifier = freeze_modifier
|
bullet.freeze_modifier = freeze_modifier
|
||||||
|
@ -130,7 +138,7 @@ func _draw():
|
||||||
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 + mob_offset, Color("ffde00"), 1)
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if Global.playing:
|
if Global.playing and not stunned:
|
||||||
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
|
||||||
if abs(velocity.x) > 10:
|
if abs(velocity.x) > 10:
|
||||||
$Sprite.flip_h = true if velocity.x < 0 else false
|
$Sprite.flip_h = true if velocity.x < 0 else false
|
||||||
|
@ -148,6 +156,12 @@ func _process(_delta):
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
get_input()
|
get_input()
|
||||||
|
|
||||||
|
if stunned:
|
||||||
|
stunned_timer += delta
|
||||||
|
if stunned_timer >= 1.5:
|
||||||
|
stunned = false
|
||||||
|
$Stars.visible = false
|
||||||
|
|
||||||
var areas = $DirtCollision.get_overlapping_areas()
|
var areas = $DirtCollision.get_overlapping_areas()
|
||||||
slowed = false
|
slowed = false
|
||||||
for area in areas:
|
for area in areas:
|
||||||
|
@ -172,6 +186,8 @@ func _physics_process(delta):
|
||||||
if Global.playing:
|
if Global.playing:
|
||||||
$Sprite.playing = true
|
$Sprite.playing = true
|
||||||
invincibility_timer += delta
|
invincibility_timer += delta
|
||||||
|
|
||||||
|
if not stunned:
|
||||||
if recharge_timer <= get_recharge():
|
if recharge_timer <= get_recharge():
|
||||||
recharge_timer += delta
|
recharge_timer += delta
|
||||||
velocity = move_and_slide(velocity * speed_multiplier)
|
velocity = move_and_slide(velocity * speed_multiplier)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 3, 4.25 )
|
extents = Vector2( 3, 4.25 )
|
||||||
|
|
||||||
[node name="Sonic_Wave" type="KinematicBody2D"]
|
[node name="Sonic_Wave" type="KinematicBody2D" groups=["sonic_wave"]]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
|
Loading…
Reference in New Issue