mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-16 15:10:20 +02:00
Fixed the random position move state
This commit is contained in:
@@ -477,11 +477,11 @@ one_shot = true
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -28 )
|
||||
texture = ExtResource( 5 )
|
||||
vframes = 10
|
||||
hframes = 24
|
||||
frame = 2
|
||||
position = Vector2( -5, -28 )
|
||||
texture = ExtResource( 6 )
|
||||
vframes = 7
|
||||
hframes = 11
|
||||
frame = 50
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
|
||||
20
src/Boss/SlimeBoss/States/BossState.gd
Normal file
20
src/Boss/SlimeBoss/States/BossState.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends "res://Overlap/StateMachine/State.gd"
|
||||
|
||||
onready var animation_player = owner.get_node("AnimationPlayer")
|
||||
onready var animation_tree = owner.get_node("AnimationTree")
|
||||
onready var animation_playback = animation_tree.get("parameters/playback")
|
||||
|
||||
var _animation_type = ANIMATION_TYPE.TREE
|
||||
|
||||
enum ANIMATION_TYPE {
|
||||
PLAYER,
|
||||
TREE
|
||||
}
|
||||
|
||||
func set_animation_type(val):
|
||||
print("wow")
|
||||
_animation_type = val
|
||||
animation_player.playback_active = _animation_type == ANIMATION_TYPE.PLAYER
|
||||
animation_tree.active = _animation_type == ANIMATION_TYPE.TREE
|
||||
|
||||
|
||||
23
src/Boss/SlimeBoss/States/Charge/Sprint.gd
Normal file
23
src/Boss/SlimeBoss/States/Charge/Sprint.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
extends "res://Boss/SlimeBoss/States/BossState.gd"
|
||||
|
||||
export(float) var SPEED = 1000.0
|
||||
|
||||
var player_pos = owner.get_parent().get_node("Player").global_position
|
||||
var direction = Vector2()
|
||||
|
||||
func enter():
|
||||
# Set animation
|
||||
set_animation_type(ANIMATION_TYPE.TREE)
|
||||
animation_playback.play("move")
|
||||
|
||||
direction = (player_pos - owner.global_position).normalized()
|
||||
owner.set_particles_active(true)
|
||||
|
||||
func exit():
|
||||
owner.set_particles_active(false)
|
||||
|
||||
func update(delta):
|
||||
owner.move_and_slide(SPEED * direction)
|
||||
|
||||
if owner.get_slide_count() > 0 or owner.position.x > 1800:
|
||||
emit_signal('finished')
|
||||
@@ -1,7 +1,4 @@
|
||||
extends "res://Overlap/StateMachine/State.gd"
|
||||
|
||||
onready var animation_player = owner.get_node("AnimationPlayer")
|
||||
onready var animation_tree = owner.get_node("AnimationTree")
|
||||
extends "BossState.gd"
|
||||
|
||||
func enter():
|
||||
animation_tree.active = false
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
extends "res://Overlap/StateMachine/State.gd"
|
||||
extends "../BossState.gd"
|
||||
|
||||
export(float) var ARRIVE_DISTANCE = 6.0
|
||||
export(float) var SLOW_RADIUS = 200.0
|
||||
export(float) var MASS = 4.0
|
||||
export(float) var MASS = 5.0
|
||||
export(float) var MAX_SPEED = 300.0
|
||||
export(float) var ROAM_RADIUS = 150.0
|
||||
|
||||
export(float) var ROAM_RADIUS = 200.0
|
||||
|
||||
var time_since_start = 0
|
||||
|
||||
var target_position = Vector2()
|
||||
var start_position = Vector2()
|
||||
var velocity = Vector2()
|
||||
var last_vel = Vector2()
|
||||
|
||||
func enter():
|
||||
# Set animation
|
||||
set_animation_type(ANIMATION_TYPE.TREE)
|
||||
animation_playback.start("move")
|
||||
|
||||
time_since_start = 0
|
||||
start_position = get_parent().start_position
|
||||
target_position = calculate_new_target_position()
|
||||
owner.get_node('AnimationPlayer').play('move')
|
||||
|
||||
|
||||
func update(delta):
|
||||
velocity = Steering.arrive_to(velocity, owner.global_position, target_position, MASS, SLOW_RADIUS, MAX_SPEED)
|
||||
owner.move_and_slide(velocity)
|
||||
time_since_start += delta
|
||||
last_vel = owner.move_and_slide(velocity)
|
||||
animation_tree.set("parameters/move/blend_position", last_vel)
|
||||
|
||||
if owner.global_position.distance_to(target_position) < ARRIVE_DISTANCE:
|
||||
if owner.global_position.distance_to(target_position) < ARRIVE_DISTANCE or time_since_start > 2.0:
|
||||
emit_signal('finished')
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
extends "res://Overlap/StateMachine/State.gd"
|
||||
extends "res://Boss/SlimeBoss/States/BossState.gd"
|
||||
|
||||
func enter():
|
||||
owner.get_node('AnimationPlayer').play('idle')
|
||||
set_animation_type(ANIMATION_TYPE.PLAYER)
|
||||
# owner.get_node('AnimationPlayer').play('idle')
|
||||
$Timer.start()
|
||||
|
||||
func update(delta):
|
||||
|
||||
Reference in New Issue
Block a user