starting work on final boss fight
This commit is contained in:
parent
34a466ae71
commit
6888928fbb
8 changed files with 222 additions and 96 deletions
84
objects/enemy/boss/famira.gd
Normal file
84
objects/enemy/boss/famira.gd
Normal file
|
@ -0,0 +1,84 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
export var decisions: Dictionary = {
|
||||
"wait": 2,
|
||||
"chase": 3,
|
||||
"punch": 3,
|
||||
"beam": 1,
|
||||
}
|
||||
export var wait_time: float = 1.0
|
||||
export var chase_speed: float = 50.0
|
||||
|
||||
|
||||
var rng := RandomNumberGenerator.new()
|
||||
var current_action: String = "wait"
|
||||
|
||||
|
||||
onready var punch_cast: RayCast2D = $PunchCast
|
||||
onready var chase_cast: RayCast2D = $ChaseCast
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
rng.seed = "HEROMARK2".hash()
|
||||
_decide_action()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match current_action:
|
||||
"chase":
|
||||
if chase_cast.is_colliding():
|
||||
print("huh")
|
||||
_decide_action()
|
||||
else:
|
||||
print("hehe")
|
||||
position.x -= chase_speed * delta
|
||||
|
||||
|
||||
func _decide_action() -> void:
|
||||
# fill array based on weights
|
||||
var weighted_decisions := []
|
||||
for k in decisions.keys():
|
||||
for i in decisions[k]:
|
||||
weighted_decisions.append(k)
|
||||
# choose an action
|
||||
current_action = weighted_decisions[rng.randi() % weighted_decisions.size()]
|
||||
# act based on new action
|
||||
match current_action:
|
||||
"wait":
|
||||
wait()
|
||||
"chase":
|
||||
chase()
|
||||
"punch":
|
||||
if punch_cast.is_colliding():
|
||||
punch()
|
||||
else:
|
||||
current_action = "chase"
|
||||
chase()
|
||||
"beam":
|
||||
beam()
|
||||
|
||||
|
||||
func wait() -> void:
|
||||
print("waiting")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
||||
|
||||
|
||||
func chase() -> void:
|
||||
# TODO: play animation
|
||||
print("chasing")
|
||||
|
||||
|
||||
func punch() -> void:
|
||||
# TODO: play animation
|
||||
print("PUNCH")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
||||
|
||||
|
||||
func beam() -> void:
|
||||
# TODO: play animation and stuff
|
||||
print("BEAM")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
Loading…
Add table
Add a link
Reference in a new issue