chicken man
This commit is contained in:
parent
a7f5ad6db2
commit
63b24cb614
9 changed files with 1469 additions and 97 deletions
|
@ -1,17 +1,19 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
enum State {STAND, FORWARD, BACK, DUCK, BEAM}
|
||||
enum State {STAND, FORWARD, BACK, DUCK, BEAM, DEAD}
|
||||
|
||||
const Bullet = preload("res://objects/enemy/2600_bullet.tscn")
|
||||
const SmallExplosion = preload("res://objects/enemy/boss/2600_small_explosion.tscn")
|
||||
|
||||
|
||||
export var hp: float = 100.0
|
||||
export var shot_speed: float = 50.0
|
||||
export var move_speed: float = 30.0
|
||||
export var safe_from_breath: bool = false
|
||||
export var make_explosions: bool = false
|
||||
export var explosion_rect: Rect2
|
||||
export var famira_path: NodePath
|
||||
|
||||
|
||||
var state: int = State.STAND
|
||||
|
@ -24,6 +26,8 @@ onready var head_sprite = $"%Head"
|
|||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match state:
|
||||
State.DEAD:
|
||||
return
|
||||
State.STAND:
|
||||
if Input.is_action_pressed("move_down"):
|
||||
state = State.DUCK
|
||||
|
@ -44,17 +48,16 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
|
||||
if state == State.DEAD:
|
||||
return
|
||||
if event.is_action_pressed("shoot") and (state == State.STAND or state == State.FORWARD or state == State.BACK):
|
||||
shoot()
|
||||
if event.is_action_pressed("jump") and state == State.STAND:
|
||||
beam()
|
||||
if event.is_action_pressed("move_up"):
|
||||
anims.play("die")
|
||||
|
||||
|
||||
func shoot() -> void:
|
||||
Audio.play_sound(Audio.a_bullet_barrage,Audio.ac_boss)
|
||||
Audio.play_sound(Audio.a_bullet_barrage,Audio.ac_collectible)
|
||||
for pos in bullet_positions.get_children():
|
||||
var bullet = Bullet.instance()
|
||||
bullet.global_position = pos.global_position
|
||||
|
@ -68,18 +71,32 @@ func beam() -> void:
|
|||
anims.play("Beam")
|
||||
|
||||
|
||||
func hurt(amount: float, can_duck: bool = false) -> void:
|
||||
if can_duck and state == State.DUCK:
|
||||
return
|
||||
hp -= amount
|
||||
if state != State.DEAD and hp <= 0.0:
|
||||
state = State.DEAD
|
||||
anims.play("die")
|
||||
|
||||
|
||||
func _play_laser_sound(play: bool):
|
||||
var famira = get_node(famira_path)
|
||||
if play:
|
||||
Audio.play_sound(Audio.a_rainbow_laser,Audio.ac_boss)
|
||||
if famira.has_method("start_push"):
|
||||
famira.start_push()
|
||||
Audio.play_sound(Audio.a_rainbow_laser,Audio.ac_collectible)
|
||||
else:
|
||||
Audio.ac_boss.playing = false
|
||||
if famira.has_method("stop_push"):
|
||||
famira.stop_push()
|
||||
Audio.ac_collectible.playing = false
|
||||
|
||||
|
||||
func _play_charge_sound(play: bool):
|
||||
if play:
|
||||
Audio.play_sound(Audio.a_2600_charge,Audio.ac_boss)
|
||||
Audio.play_sound(Audio.a_2600_charge,Audio.ac_collectible)
|
||||
else:
|
||||
Audio.ac_boss.playing = false
|
||||
Audio.ac_collectible.playing = false
|
||||
|
||||
|
||||
func _spawn_explosions() -> void:
|
||||
|
@ -106,3 +123,5 @@ func _on_animation_finished(anim_name: String) -> void:
|
|||
state = State.STAND
|
||||
"Beam":
|
||||
state = State.STAND
|
||||
"die":
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue