Compare commits

...

2 Commits

Author SHA1 Message Date
CactiChameleon9
5f04493981 Fix spelling mistake in animation names 2022-03-17 09:11:47 +00:00
CactiChameleon9
b200913a78 Fix crash while attacking nothing 2022-03-17 08:57:58 +00:00
3 changed files with 12 additions and 11 deletions

View File

@ -78,7 +78,7 @@ func move(movement : Vector2):
z_index = 100
func attack(damage : int, points : int, pattern : PoolVector2Array): #TODO
func attack(damage : int, points : int, pattern : PoolVector2Array):
if attack_points != 0:
#change animation to attacking
$AnimationPlayer.play("Attack front")
@ -87,9 +87,10 @@ func attack(damage : int, points : int, pattern : PoolVector2Array): #TODO
# and calls their attacked method
for i in range(pattern.size()):
var coord = Grid.position_to_coordinates(position, height)
var selected_name = Grid.grid[coord.x + pattern[i].x][coord.y + pattern[i].y][0]
var selected_name = Grid.grid[coord.x + pattern[i].x][coord.y + pattern[i].y]
print(coord.x + pattern[i].x, coord.y + pattern[i].y)
if selected_name:
get_node(("../" + selected_name)).attacked(damage, "") #TODO effects implementation
get_node(("../" + selected_name[0])).attacked(damage, "") #TODO effects implementation
#change the attack points left
attack_points = max(attack_points - points, 0) #keep >= 0

View File

@ -38,7 +38,7 @@ tracks/0/keys = {
}
[sub_resource type="Animation" id=3]
resource_name = "Attacted"
resource_name = "Attacked front"
length = 0.8
step = 0.05
tracks/0/type = "value"
@ -55,7 +55,7 @@ tracks/0/keys = {
}
[sub_resource type="Animation" id=4]
resource_name = "Attacted back"
resource_name = "Attacked back"
length = 0.8
step = 0.05
tracks/0/type = "value"
@ -128,7 +128,7 @@ frame = 12
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
anims/Attacted = SubResource( 3 )
"anims/Attacted back" = SubResource( 4 )
"anims/Attacked front" = SubResource( 3 )
"anims/Attacked back" = SubResource( 4 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )

View File

@ -38,7 +38,7 @@ tracks/0/keys = {
}
[sub_resource type="Animation" id=3]
resource_name = "Attacted"
resource_name = "Attacked front"
length = 0.8
step = 0.05
tracks/0/type = "value"
@ -55,7 +55,7 @@ tracks/0/keys = {
}
[sub_resource type="Animation" id=4]
resource_name = "Attacted back"
resource_name = "Attacked back"
length = 0.8
step = 0.05
tracks/0/type = "value"
@ -127,7 +127,7 @@ vframes = 6
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
anims/Attacted = SubResource( 3 )
"anims/Attacted back" = SubResource( 4 )
"anims/Attacked front" = SubResource( 3 )
"anims/Attacked back" = SubResource( 4 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )