2017-07-30 20:57:41 +01:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
2017-08-10 19:55:15 +01:00
|
|
|
const km = preload("Kinematic.gd")
|
|
|
|
|
2017-08-10 23:26:45 +01:00
|
|
|
var grunt_max_speed = 256 # pixels per second
|
2017-08-10 19:55:15 +01:00
|
|
|
var grunt_arrive_radius = 64
|
2017-08-10 20:17:39 +01:00
|
|
|
var grunt_arrive_speed = 1
|
2017-07-31 17:23:46 +01:00
|
|
|
var grunt_rot_speed = deg2rad(22.5) # degrees per second
|
2017-08-10 19:55:15 +01:00
|
|
|
|
|
|
|
var cur_kinematic
|
2017-08-10 20:17:39 +01:00
|
|
|
var steering
|
2017-08-10 19:55:15 +01:00
|
|
|
var s_seek
|
|
|
|
var s_arrive
|
2017-07-31 17:23:46 +01:00
|
|
|
|
2017-07-30 20:57:41 +01:00
|
|
|
func _ready():
|
2017-08-10 19:55:15 +01:00
|
|
|
var t = get_tree().get_root().get_node("Game/MinimapControl").register_entity(self)
|
|
|
|
set_fixed_process(true)
|
2017-07-31 17:23:46 +01:00
|
|
|
set_process(true)
|
2017-08-10 19:55:15 +01:00
|
|
|
|
|
|
|
cur_kinematic = km.Kinematic.new(self, grunt_max_speed)
|
2017-08-10 20:17:39 +01:00
|
|
|
steering = km.Steering.new()
|
|
|
|
|
2017-08-10 19:55:15 +01:00
|
|
|
s_seek = km.Seek.new(self)
|
2017-08-10 20:17:39 +01:00
|
|
|
s_arrive = km.Arrive.new(self, grunt_arrive_radius, grunt_arrive_speed)
|
2017-08-10 19:55:15 +01:00
|
|
|
|
|
|
|
var player = get_tree().get_root().get_node("Game/Player")
|
|
|
|
s_seek.set_target(player)
|
|
|
|
s_arrive.set_target(player)
|
2017-07-31 17:23:46 +01:00
|
|
|
|
2017-07-30 20:57:41 +01:00
|
|
|
func type():
|
|
|
|
return "EnemyGrunt"
|
2017-07-31 17:23:46 +01:00
|
|
|
|
2017-08-10 19:55:15 +01:00
|
|
|
func _fixed_process(delta):
|
2017-08-10 20:17:39 +01:00
|
|
|
s_seek.get_steering(steering)
|
|
|
|
s_arrive.get_steering(steering)
|
|
|
|
cur_kinematic.update(steering, delta)
|
2017-08-10 19:55:15 +01:00
|
|
|
|
2017-07-31 17:23:46 +01:00
|
|
|
func _process(delta):
|
2017-08-10 19:55:15 +01:00
|
|
|
pass
|
|
|
|
# rotate(grunt_rot_speed * delta)
|