Use inheritance for the foe and friend scenes

This commit is contained in:
CactiChameleon9 2022-03-22 09:19:56 +00:00
parent e40f35c61a
commit 596b879b41
3 changed files with 139 additions and 260 deletions

133
src/classes/Unit.tscn Normal file
View File

@ -0,0 +1,133 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://src/classes/Unit.gd" type="Script" id=1]
[ext_resource path="res://src/assets/shadow.png" type="Texture" id=2]
[ext_resource path="res://src/nodes/UI/UnitPopup.tscn" type="PackedScene" id=3]
[sub_resource type="Animation" id=1]
resource_name = "Attack back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15, 14, 13 ]
}
[sub_resource type="Animation" id=2]
resource_name = "Attack front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11, 10, 9 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Attacked back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 20, 21, 22, 23, 22, 21 ]
}
[sub_resource type="Animation" id=3]
resource_name = "Attacked front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 16, 17, 18, 19, 18, 17 ]
}
[sub_resource type="Animation" id=5]
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 2, 1 ]
}
[sub_resource type="Animation" id=6]
resource_name = "Idle back"
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7, 6, 5 ]
}
[node name="Unit" type="Node2D"]
z_index = 100
script = ExtResource( 1 )
[node name="Shadow" type="Sprite" parent="."]
position = Vector2( 2.5, -8.5 )
scale = Vector2( 1.28125, 0.90625 )
texture = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 2, -12 )
hframes = 4
vframes = 6
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
"anims/Attacked back" = SubResource( 4 )
"anims/Attacked front" = SubResource( 3 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )
[node name="UnitPopup" parent="." instance=ExtResource( 3 )]

View File

@ -1,135 +1,8 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://src/assets/shadow.png" type="Texture" id=1] [ext_resource path="res://src/classes/Unit.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/nodes/units/Foe.gd" type="Script" id=2] [ext_resource path="res://src/nodes/units/Foe.gd" type="Script" id=2]
[ext_resource path="res://src/nodes/UI/UnitPopup.tscn" type="PackedScene" id=3]
[sub_resource type="Animation" id=1] [node name="Foe" groups=["foes"] instance=ExtResource( 1 )]
resource_name = "Attack back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15, 14, 13 ]
}
[sub_resource type="Animation" id=2]
resource_name = "Attack front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11, 10, 9 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Attacked back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 20, 21, 22, 23, 22, 21 ]
}
[sub_resource type="Animation" id=3]
resource_name = "Attacked front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 16, 17, 18, 19, 18, 17 ]
}
[sub_resource type="Animation" id=5]
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 2, 1 ]
}
[sub_resource type="Animation" id=6]
resource_name = "Idle back"
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7, 6, 5 ]
}
[node name="Foe" type="Node2D" groups=["foes"]]
script = ExtResource( 2 ) script = ExtResource( 2 )
unit_type = "Foe" unit_type = "Foe"
movement_distance = 0
[node name="Shadow" type="Sprite" parent="."]
position = Vector2( 2.5, -8.5 )
scale = Vector2( 1.28125, 0.90625 )
texture = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 2, -12 )
hframes = 4
vframes = 6
frame = 12
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
"anims/Attacked back" = SubResource( 4 )
"anims/Attacked front" = SubResource( 3 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )
[node name="UnitPopup" parent="." instance=ExtResource( 3 )]

View File

@ -1,135 +1,8 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://src/nodes/UI/UnitPopup.tscn" type="PackedScene" id=1] [ext_resource path="res://src/classes/Unit.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/assets/shadow.png" type="Texture" id=2]
[ext_resource path="res://src/nodes/units/Friend.gd" type="Script" id=3] [ext_resource path="res://src/nodes/units/Friend.gd" type="Script" id=3]
[sub_resource type="Animation" id=1] [node name="Friend" groups=["friends"] instance=ExtResource( 1 )]
resource_name = "Attack back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15, 14, 13 ]
}
[sub_resource type="Animation" id=2]
resource_name = "Attack front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11, 10, 9 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Attacked back"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 20, 21, 22, 23, 22, 21 ]
}
[sub_resource type="Animation" id=3]
resource_name = "Attacked front"
length = 0.9
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 16, 17, 18, 19, 18, 17 ]
}
[sub_resource type="Animation" id=5]
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 2, 1 ]
}
[sub_resource type="Animation" id=6]
resource_name = "Idle back"
length = 0.9
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7, 6, 5 ]
}
[node name="Friend" type="Node2D" groups=["friends"]]
z_index = 100
script = ExtResource( 3 ) script = ExtResource( 3 )
unit_type = "Friend" unit_type = "Friend"
[node name="Shadow" type="Sprite" parent="."]
position = Vector2( 2.5, -8.5 )
scale = Vector2( 1.28125, 0.90625 )
texture = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 2, -12 )
hframes = 4
vframes = 6
frame = 4
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
"anims/Attacked back" = SubResource( 4 )
"anims/Attacked front" = SubResource( 3 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )
[node name="UnitPopup" parent="." instance=ExtResource( 1 )]