setup for ai

This commit is contained in:
Jonas Mucke
2020-04-18 21:17:13 +02:00
parent b75cdf7a76
commit e7d5d9eacc
11 changed files with 345 additions and 94 deletions

View File

@@ -0,0 +1,23 @@
extends StaticBody2D
export(int, 1, 5) var lifePoints = 3
export(int, 1, 30) var spawnRate = 5
var elapsedTime = 0.0
func _physics_process(delta):
elapsedTime += delta
if(elapsedTime>=spawnRate):
elapsedTime-=spawnRate
var Minion = load("")
var world = get_tree().current_scene.get_child(2)
var minion = Minion.instance()
world.add_child(minion)
minion.global_position = global_position
func _on_Hurtbox_area_entered(area):
lifePoints -= area.damage
if(lifePoints<0):
queue_free()
pass

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
[ext_resource path="res://testSprites/fackel.png" type="Texture" id=2]
[ext_resource path="res://Objects/Torch/Torch.gd" type="Script" id=3]
[sub_resource type="CapsuleShape2D" id=1]
radius = 8.0
height = 12.0
[node name="Torch" type="StaticBody2D"]
script = ExtResource( 3 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -8 )
texture = ExtResource( 2 )
[node name="Hurtbox" parent="." instance=ExtResource( 1 )]
collision_layer = 8
collision_mask = 0
script = null
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -8 )
shape = SubResource( 1 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]