ai adaptation

This commit is contained in:
Jonas Mucke
2020-04-20 13:15:24 +02:00
parent b8b026d063
commit 3ec908f6c3
12 changed files with 399 additions and 93 deletions

View File

@@ -1,4 +1,4 @@
extends KinematicBody2D
extends Minion
var velocity := Vector2.ZERO
@@ -12,9 +12,14 @@ onready var debug_label := $DebugLabel
var damage_per_second := 0.0
var totaldamage := 0.0
var rollvector = Vector2.ZERO
func _debug_update():
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n"
func _ready():
grid = get_tree().current_scene.get_node("Grid")
# IMPORTANT: If you are using move_and_slide don't multiply by delta
# Godots physics system does that internally
# In move_and_collide(...) you have to multiply by delta.
@@ -31,6 +36,9 @@ func _physics_process(delta):
totaldamage += 1
player_stats.health += 1
_debug_update()
run(Vector2.ZERO, delta)
makeMove(delta)
move()
@@ -45,3 +53,14 @@ func _on_Hurtbox_area_entered(area):
func _on_Hurtbox_area_exited(area):
damage_per_second -= area.damage
# API Interface for ai_hero
func run(direction, delta):
direction = direction.normalized()
rollvector = direction
velocity = velocity.move_toward(player_stats.speed * rollvector, ACCELERATION * delta)
if direction == Vector2.ZERO:
pass
else:
pass

View File

@@ -12,14 +12,15 @@ radius = 6.0
[sub_resource type="CapsuleShape2D" id=2]
radius = 11.0
height = 11.0
height = 1.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 11.0
height = 11.0
height = 1.0
[node name="Minion" type="KinematicBody2D"]
script = ExtResource( 6 )
ACCELERATION = 500
[node name="Kind" parent="." instance=ExtResource( 3 )]
kind = 3
@@ -37,7 +38,7 @@ collision_layer = 0
collision_mask = 65
[node name="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2( 0, -9 )
position = Vector2( 0.110184, -4.81305 )
shape = SubResource( 2 )
[node name="Hurtbox" parent="." groups=[
@@ -47,7 +48,7 @@ collision_layer = 8
collision_mask = 128
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -9 )
position = Vector2( 0.110184, -4.81305 )
shape = SubResource( 3 )
[node name="DebugLabel" type="Label" parent="."]
@@ -62,6 +63,7 @@ __meta__ = {
[node name="Stats" parent="." instance=ExtResource( 4 )]
max_health = 2
max_speed = 80.0
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]