diff --git a/packed-scenes/skeleton_warrior.tscn b/packed-scenes/skeleton_warrior.tscn index d11fb89..3885226 100644 --- a/packed-scenes/skeleton_warrior.tscn +++ b/packed-scenes/skeleton_warrior.tscn @@ -794,36 +794,36 @@ bones/1/name = "hips" bones/1/parent = 0 bones/1/rest = Transform3D(1, -1.92983e-22, -2.06635e-07, 9.18536e-22, 1, 3.51128e-15, 2.06635e-07, -3.51128e-15, 1, -2.1013e-22, 0.405663, 8.88178e-16) bones/1/enabled = true -bones/1/position = Vector3(4.83777e-19, 0.388773, 1.62826e-15) -bones/1/rotation = Quaternion(5.5129e-05, 0.0425453, 3.42029e-05, 0.999095) +bones/1/position = Vector3(6.36775e-19, 0.379191, 1.31748e-15) +bones/1/rotation = Quaternion(5.51022e-05, 0.0425453, 3.42042e-05, 0.999095) bones/1/scale = Vector3(1, 1, 1) bones/2/name = "spine" bones/2/parent = 1 bones/2/rest = Transform3D(1, 8.67181e-22, 3.55271e-15, -8.67181e-22, 1, 3.52176e-23, -3.55271e-15, -3.52176e-23, 1, -4.36903e-23, 0.191978, -8.88178e-16) bones/2/enabled = true bones/2/position = Vector3(5.98822e-12, 0.191978, -2.81142e-12) -bones/2/rotation = Quaternion(-2.85666e-05, 0.00396509, 0.000182735, 0.999992) +bones/2/rotation = Quaternion(-2.83959e-05, 0.00397263, 0.000182425, 0.999992) bones/2/scale = Vector3(1, 1, 1) bones/3/name = "chest" bones/3/parent = 2 bones/3/rest = Transform3D(1, -2.05374e-22, -1.77636e-14, 2.05374e-22, 1, -1.11653e-14, 1.77636e-14, 1.11653e-14, 1, -9.6328e-23, 0.374988, 1.77636e-15) bones/3/enabled = true bones/3/position = Vector3(-1.41718e-11, 0.374988, 2.56119e-11) -bones/3/rotation = Quaternion(3.39795e-05, 8.1794e-05, 0.000555999, 1) +bones/3/rotation = Quaternion(3.45197e-05, 8.19443e-05, 0.000556775, 1) bones/3/scale = Vector3(1, 1, 1) bones/4/name = "upperarm.l" bones/4/parent = 3 bones/4/rest = Transform3D(0.0572952, 0.998357, 5.96046e-08, -2.98023e-07, -1.19209e-07, 1, 0.998357, -0.0572953, 2.38419e-07, 0.212007, 0.134132, 8.92131e-08) bones/4/enabled = true -bones/4/position = Vector3(0.212002, 0.134125, -2.43281e-05) -bones/4/rotation = Quaternion(-0.559688, -0.0624469, -0.642516, 0.519638) +bones/4/position = Vector3(0.212003, 0.134125, -2.44845e-05) +bones/4/rotation = Quaternion(-0.553009, -0.0652423, -0.656884, 0.508359) bones/4/scale = Vector3(0.999999, 0.999999, 1) bones/5/name = "lowerarm.l" bones/5/parent = 4 bones/5/rest = Transform3D(0.993885, 0.110424, -1.77241e-07, -0.110424, 0.993885, -4.82524e-07, 1.22875e-07, 4.99145e-07, 1, -3.31295e-09, 0.241897, 4.4799e-09) bones/5/enabled = true bones/5/position = Vector3(4.27124e-08, 0.241897, -1.72472e-07) -bones/5/rotation = Quaternion(2.11101e-07, 8.00425e-08, -0.498853, 0.866687) +bones/5/rotation = Quaternion(2.05164e-07, 4.52682e-08, -0.475956, 0.879469) bones/5/scale = Vector3(1, 1, 1) bones/6/name = "wrist.l" bones/6/parent = 5 @@ -837,28 +837,28 @@ bones/7/parent = 6 bones/7/rest = Transform3D(1, 8.33334e-14, -2.83571e-14, -8.33334e-14, 1, -2.54025e-13, 2.83571e-14, 2.54025e-13, 1, -2.04281e-14, 0.0738259, -1.19209e-07) bones/7/enabled = true bones/7/position = Vector3(-7.1782e-09, 0.0738259, -1.0869e-08) -bones/7/rotation = Quaternion(-0.322034, -0.326942, 0.142432, 0.876993) +bones/7/rotation = Quaternion(-0.317514, -0.328801, 0.129598, 0.879932) bones/7/scale = Vector3(1, 1, 1) bones/8/name = "handslot.l" bones/8/parent = 7 bones/8/rest = Transform3D(0, 1, -2.32809e-07, -1, 0, -6.82762e-08, -6.82761e-08, 2.32809e-07, 1, 8.34841e-10, 0.0961251, -0.0575) bones/8/enabled = true bones/8/position = Vector3(9.24142e-10, 0.0961252, -0.0575) -bones/8/rotation = Quaternion(9.5007e-05, 8.59356e-05, -0.706428, 0.707785) +bones/8/rotation = Quaternion(0.00157883, 0.00156621, -0.700961, 0.713196) bones/8/scale = Vector3(1, 1, 1) bones/9/name = "upperarm.r" bones/9/parent = 3 bones/9/rest = Transform3D(0.0572954, -0.998357, -1.49012e-07, 2.38419e-07, -1.19209e-07, 1, -0.998357, -0.0572954, 2.38419e-07, -0.212007, 0.134132, 7.46997e-08) bones/9/enabled = true -bones/9/position = Vector3(-0.212, 0.134123, -2.11732e-05) -bones/9/rotation = Quaternion(-0.618803, 0.0819918, 0.613012, 0.484331) +bones/9/position = Vector3(-0.212, 0.134122, -2.10167e-05) +bones/9/rotation = Quaternion(-0.613335, 0.0849252, 0.625927, 0.474157) bones/9/scale = Vector3(0.999999, 0.999999, 1) bones/10/name = "lowerarm.r" bones/10/parent = 9 bones/10/rest = Transform3D(0.993885, -0.110424, 1.06327e-07, 0.110424, 0.993885, -4.82539e-07, -5.23934e-08, 4.91329e-07, 1, 4.03071e-09, 0.241897, 3.62012e-09) bones/10/enabled = true bones/10/position = Vector3(-4.04491e-08, 0.241897, -5.30697e-08) -bones/10/rotation = Quaternion(2.02505e-07, -1.01366e-07, 0.523453, 0.852054) +bones/10/rotation = Quaternion(1.94532e-07, -7.75853e-08, 0.501648, 0.865072) bones/10/scale = Vector3(1, 1, 1) bones/11/name = "wrist.r" bones/11/parent = 10 @@ -872,21 +872,21 @@ bones/12/parent = 11 bones/12/rest = Transform3D(1, -8.32931e-14, 2.83546e-14, 8.32931e-14, 1, -6.34575e-14, -2.83546e-14, 6.34575e-14, 1, 2.04281e-14, 0.0738259, -1.19209e-07) bones/12/enabled = true bones/12/position = Vector3(-1.3659e-08, 0.0738259, -6.36405e-08) -bones/12/rotation = Quaternion(-0.315843, 0.306202, -0.225925, 0.869162) +bones/12/rotation = Quaternion(-0.311614, 0.306849, -0.213073, 0.873694) bones/12/scale = Vector3(1, 1, 1) bones/13/name = "handslot.r" bones/13/parent = 12 bones/13/rest = Transform3D(0, -1, 2.32809e-07, 1, 0, -6.86063e-08, 6.86063e-08, 2.32809e-07, 1, -8.34841e-10, 0.0961251, -0.0575) bones/13/enabled = true bones/13/position = Vector3(-1.97277e-08, 0.0961251, -0.0575) -bones/13/rotation = Quaternion(0.000359388, 0.000403948, 0.706598, 0.707615) +bones/13/rotation = Quaternion(0.00417116, 0.00489415, 0.702617, 0.711539) bones/13/scale = Vector3(1, 1, 1) bones/14/name = "head" bones/14/parent = 3 bones/14/rest = Transform3D(1, 8.09955e-22, 1.77636e-14, -8.09955e-22, 1, 1.49605e-14, -1.77636e-14, -1.49605e-14, 1, 4.67612e-25, 0.268797, 0) bones/14/enabled = true bones/14/position = Vector3(-1.24878e-11, 0.268797, 4.0423e-15) -bones/14/rotation = Quaternion(0.000533881, -0.0309567, -1.53053e-05, 0.999521) +bones/14/rotation = Quaternion(0.00053455, -0.0309621, -1.49467e-05, 0.99952) bones/14/scale = Vector3(1, 1, 1) bones/15/name = "Skeleton_Warrior_Helmet" bones/15/parent = 14 @@ -899,71 +899,71 @@ bones/16/name = "upperleg.l" bones/16/parent = 1 bones/16/rest = Transform3D(1, -1.31243e-07, -1.34242e-07, -1.35828e-07, -0.999396, -0.0347426, -1.29601e-07, 0.0347426, -0.999397, 0.170945, 0.113587, 1.70271e-08) bones/16/enabled = true -bones/16/position = Vector3(0.170945, 0.113587, 0.000226713) -bones/16/rotation = Quaternion(0.993498, 0.0818774, 0.0737715, 0.0285482) +bones/16/position = Vector3(0.170945, 0.113587, 0.000225167) +bones/16/rotation = Quaternion(0.991742, 0.0816348, 0.0761748, 0.0631037) bones/16/scale = Vector3(1, 1, 1) bones/17/name = "lowerleg.l" bones/17/parent = 16 bones/17/rest = Transform3D(1, 1.62704e-07, 1.37175e-07, -1.30054e-07, 0.977432, -0.211252, -1.68451e-07, 0.211252, 0.977432, -1.1194e-08, 0.227077, -2.32076e-08) bones/17/enabled = true bones/17/position = Vector3(3.92422e-08, 0.227078, -1.35528e-10) -bones/17/rotation = Quaternion(0.233395, 6.84983e-08, -1.59559e-07, 0.972382) +bones/17/rotation = Quaternion(0.323659, 7.1516e-08, -2.23078e-07, 0.946174) bones/17/scale = Vector3(1, 1, 1) bones/18/name = "foot.l" bones/18/parent = 17 bones/18/rest = Transform3D(1, -6.39488e-14, 1.68587e-07, -1.36667e-07, 0.585513, 0.810663, -9.87102e-08, -0.810663, 0.585513, -1.49012e-08, 0.149437, 3.72566e-09) bones/18/enabled = true bones/18/position = Vector3(4.37849e-08, 0.149437, -6.94943e-09) -bones/18/rotation = Quaternion(-0.537535, -0.205658, 0.0475679, 0.816393) +bones/18/rotation = Quaternion(-0.584444, -0.202137, 0.0622363, 0.783385) bones/18/scale = Vector3(1, 1, 0.999999) bones/19/name = "toes.l" bones/19/parent = 18 bones/19/rest = Transform3D(-1, 1.21361e-07, 3.37844e-07, -1.58967e-07, 0.694106, -0.719873, -3.21865e-07, -0.719873, -0.694106, -1.6149e-10, 0.16565, 8.79764e-10) bones/19/enabled = true bones/19/position = Vector3(-7.03199e-09, 0.16565, 2.68891e-08) -bones/19/rotation = Quaternion(7.31899e-05, 0.920222, -0.391397, -1.64009e-05) +bones/19/rotation = Quaternion(1.96437e-05, 0.920174, -0.39151, -4.27243e-06) bones/19/scale = Vector3(1, 0.999998, 1) bones/20/name = "upperleg.r" bones/20/parent = 1 bones/20/rest = Transform3D(1, 1.31243e-07, 2.02657e-07, 1.38205e-07, -0.999396, -0.0347426, 1.97975e-07, 0.0347426, -0.999397, -0.170945, 0.113587, 5.32468e-09) bones/20/enabled = true -bones/20/position = Vector3(-0.170945, 0.113344, -0.000227036) -bones/20/rotation = Quaternion(0.996766, -0.0295855, 0.0308184, 0.0680589) +bones/20/position = Vector3(-0.170945, 0.113344, -0.000225491) +bones/20/rotation = Quaternion(0.994367, -0.0312744, 0.0300567, 0.0967084) bones/20/scale = Vector3(1, 1, 1) bones/21/name = "lowerleg.r" bones/21/parent = 20 bones/21/rest = Transform3D(1, -1.65029e-07, -1.36672e-07, 1.32432e-07, 0.977432, -0.211252, 1.6845e-07, 0.211252, 0.977432, 1.18882e-08, 0.227077, -2.32075e-08) bones/21/enabled = true bones/21/position = Vector3(-9.67559e-09, 0.227077, -1.42054e-08) -bones/21/rotation = Quaternion(0.306672, -7.15384e-08, 2.14497e-07, 0.951815) +bones/21/rotation = Quaternion(0.380338, -6.88774e-08, 2.68208e-07, 0.924848) bones/21/scale = Vector3(1, 1, 1) bones/22/name = "foot.r" bones/22/parent = 21 bones/22/rest = Transform3D(1, 5.68434e-14, 1.68587e-07, -1.36668e-07, 0.585513, 0.810663, -9.87101e-08, -0.810663, 0.585513, 1.49012e-08, 0.149437, 3.72559e-09) bones/22/enabled = true bones/22/position = Vector3(1.60742e-08, 0.149437, 6.9127e-09) -bones/22/rotation = Quaternion(-0.575026, 0.11277, -0.0101084, 0.810263) +bones/22/rotation = Quaternion(-0.614402, 0.112022, -0.0165697, 0.780824) bones/22/scale = Vector3(1, 1, 0.999999) bones/23/name = "toes.r" bones/23/parent = 22 bones/23/rest = Transform3D(-1, 1.21361e-07, 3.58529e-08, 5.84281e-08, 0.694106, -0.719873, -1.12251e-07, -0.719873, -0.694106, -1.61491e-10, 0.16565, 2.84604e-09) bones/23/enabled = true bones/23/position = Vector3(6.94013e-09, 0.16565, 2.44373e-08) -bones/23/rotation = Quaternion(-8.80699e-05, 0.920215, -0.391413, 2.01282e-05) +bones/23/rotation = Quaternion(-8.80701e-05, 0.920215, -0.391413, 2.01282e-05) bones/23/scale = Vector3(1, 0.999998, 1) bones/24/name = "kneeIK.l" bones/24/parent = 0 bones/24/rest = Transform3D(1, -2.47926e-07, -3.89414e-07, -3.89414e-07, 3.57628e-07, -1, 2.47926e-07, 1, 3.57628e-07, 0.170945, 0.29231, 0.575812) bones/24/enabled = true -bones/24/position = Vector3(0.170945, 0.29235, 0.575852) +bones/24/position = Vector3(0.170945, 0.292345, 0.575847) bones/24/rotation = Quaternion(0.707107, -2.25334e-07, -5.00237e-08, 0.707107) bones/24/scale = Vector3(1, 1, 1) bones/25/name = "control-toe-roll.l" bones/25/parent = 0 bones/25/rest = Transform3D(1, 2.05345e-07, -6.39488e-14, -7.10543e-15, 3.57628e-07, 1, 2.05345e-07, -1, 3.57628e-07, 0.170945, 0.0259902, 0.245789) bones/25/enabled = true -bones/25/position = Vector3(0.201736, 0.0278023, 0.207886) -bones/25/rotation = Quaternion(-0.709147, -7.23865e-08, -7.28127e-08, 0.705061) +bones/25/position = Vector3(0.201736, 0.0278131, 0.207861) +bones/25/rotation = Quaternion(-0.709116, -7.23897e-08, -7.28099e-08, 0.705091) bones/25/scale = Vector3(1, 1, 1) bones/26/name = "control-heel-roll.l" bones/26/parent = 25 @@ -977,7 +977,7 @@ bones/27/parent = 26 bones/27/rest = Transform3D(-1, -1.44017e-07, -2.51498e-07, -8.10837e-08, -0.694106, 0.719873, -2.7824e-07, 0.719873, 0.694106, -8.85797e-10, 0.213436, -8.66923e-10) bones/27/enabled = true bones/27/position = Vector3(-4.34108e-08, 0.213436, -1.24871e-08) -bones/27/rotation = Quaternion(-1.33533e-07, 0.391084, 0.920355, 2.11993e-08) +bones/27/rotation = Quaternion(-1.33533e-07, 0.391084, 0.920355, 2.11992e-08) bones/27/scale = Vector3(1, 1, 1) bones/28/name = "heelIK.l" bones/28/parent = 27 @@ -1004,15 +1004,15 @@ bones/31/name = "kneeIK.r" bones/31/parent = 0 bones/31/rest = Transform3D(1, -2.47926e-07, 1.50996e-07, 1.50996e-07, 3.57628e-07, -1, 2.47926e-07, 1, 3.57628e-07, -0.170945, 0.29231, 0.575812) bones/31/enabled = true -bones/31/position = Vector3(-0.170945, 0.29235, 0.575852) +bones/31/position = Vector3(-0.170945, 0.292345, 0.575847) bones/31/rotation = Quaternion(0.707107, -3.427e-08, 1.4104e-07, 0.707107) bones/31/scale = Vector3(1, 1, 1) bones/32/name = "control-toe-roll.r" bones/32/parent = 0 bones/32/rest = Transform3D(1, 2.05345e-07, -5.68434e-14, -1.42109e-14, 3.57628e-07, 1, 2.05345e-07, -1, 3.57628e-07, -0.170945, 0.0259902, 0.245789) bones/32/enabled = true -bones/32/position = Vector3(-0.170945, 0.0251808, 0.241307) -bones/32/rotation = Quaternion(-0.7031, -7.30609e-08, -7.21375e-08, 0.711091) +bones/32/position = Vector3(-0.170945, 0.0251996, 0.241324) +bones/32/rotation = Quaternion(-0.703124, -7.30575e-08, -7.21395e-08, 0.711067) bones/32/scale = Vector3(1, 1, 1) bones/33/name = "control-heel-roll.r" bones/33/parent = 32 @@ -1026,7 +1026,7 @@ bones/34/parent = 33 bones/34/rest = Transform3D(-1, -1.44017e-07, -2.51498e-07, -8.10837e-08, -0.694106, 0.719873, -2.7824e-07, 0.719873, 0.694106, 1.40154e-08, 0.213436, -5.23748e-10) bones/34/enabled = true bones/34/position = Vector3(-2.94849e-09, 0.213436, -1.62925e-08) -bones/34/rotation = Quaternion(-1.46971e-07, 0.391084, 0.920355, 2.4035e-08) +bones/34/rotation = Quaternion(-1.4697e-07, 0.391084, 0.920355, 2.40348e-08) bones/34/scale = Vector3(1, 1, 1) bones/35/name = "heelIK.r" bones/35/parent = 34 @@ -1060,7 +1060,7 @@ bones/39/name = "handIK.l" bones/39/parent = 0 bones/39/rest = Transform3D(-1.19209e-07, 1, 0, -1.19209e-07, 0, 1, 1, 1.19209e-07, 1.19209e-07, 0.713181, 1.10676, 2.99767e-07) bones/39/enabled = true -bones/39/position = Vector3(0.520733, 0.788109, -0.0592629) +bones/39/position = Vector3(0.520733, 0.769562, -0.0592629) bones/39/rotation = Quaternion(0.795616, 0.00380772, 0.605784, 0.00243902) bones/39/scale = Vector3(1, 1, 1) bones/40/name = "elbowIK.r" @@ -1074,12 +1074,12 @@ bones/41/name = "handIK.r" bones/41/parent = 0 bones/41/rest = Transform3D(0, -1, -5.96046e-08, 1.78814e-07, -1.19209e-07, 1, -1, -5.96046e-08, 1.19209e-07, -0.713182, 1.10676, -6.1348e-08) bones/41/enabled = true -bones/41/position = Vector3(-0.510811, 0.788561, 0.0633181) +bones/41/position = Vector3(-0.510811, 0.770014, 0.0633181) bones/41/rotation = Quaternion(-0.762388, 0.00756036, 0.647063, -0.00406019) bones/41/scale = Vector3(1, 1, 1) [node name="Skeleton_Head" type="BoneAttachment3D" parent="Rig/Skeleton3D"] -transform = Transform3D(0.999527, -0.00143737, 0.0307342, 0.00147734, 0.999998, -0.00127793, -0.0307323, 0.00132273, 0.999527, -0.000586798, 1.22453, 0.000124435) +transform = Transform3D(0.999526, -0.00143879, 0.0307388, 0.00147885, 0.999998, -0.00128073, -0.0307369, 0.00132558, 0.999527, -0.000586771, 1.21495, 0.000124908) bone_name = "head" bone_idx = 14 @@ -1126,7 +1126,7 @@ mesh = SubResource("ArrayMesh_or0td") skin = SubResource("Skin_irdo5") [node name="Skeleton_Hand_L" type="BoneAttachment3D" parent="Rig/Skeleton3D"] -transform = Transform3D(0.263509, 0.00145069, 0.964655, 0.0126542, -0.999917, -0.00195184, 0.964573, 0.0127208, -0.263506, 0.563732, 0.73266, -0.0346319) +transform = Transform3D(0.263375, 0.00125009, 0.964692, 0.0125667, -0.999918, -0.00213414, 0.964611, 0.0126847, -0.26337, 0.563408, 0.712969, -0.0363088) bone_name = "hand.l" bone_idx = 7 @@ -1149,7 +1149,7 @@ shape = SubResource("CapsuleShape3D_70xfu") disabled = true [node name="Skeleton_Hand_R" type="BoneAttachment3D" parent="Rig/Skeleton3D"] -transform = Transform3D(0.151746, -0.0115832, -0.988351, -0.0148398, -0.999845, 0.00944018, -0.988307, 0.0132339, -0.151895, -0.549854, 0.738259, 0.101643) +transform = Transform3D(0.151665, -0.0113823, -0.988366, -0.0148164, -0.999847, 0.00924167, -0.98832, 0.0132418, -0.151811, -0.549893, 0.71828, 0.0999996) bone_name = "hand.r" bone_idx = 12 @@ -1180,8 +1180,8 @@ libraries = { tree_root = SubResource("AnimationNodeStateMachine_34gcr") anim_player = NodePath("../AnimationPlayer") parameters/current_length = 1.04167 -parameters/current_position = 0.111452 -parameters/current_delta = 0.0133837 +parameters/current_position = 0.79176 +parameters/current_delta = 0.0137034 parameters/conditions/grounded = false parameters/conditions/jumping = false parameters/Death_A/current_length = 0.791667 @@ -1200,12 +1200,12 @@ parameters/Hit_B/current_length = 0.833333 parameters/Hit_B/current_position = 0.833333 parameters/Hit_B/current_delta = 0.0175824 parameters/IWR/current_length = 1.04167 -parameters/IWR/current_position = 0.111452 -parameters/IWR/current_delta = 0.0133837 +parameters/IWR/current_position = 0.79176 +parameters/IWR/current_delta = 0.0137034 parameters/IWR/blend_position = Vector2(0.000524879, -0.0137615) parameters/IWR/0/current_length = 1.04167 -parameters/IWR/0/current_position = 0.111452 -parameters/IWR/0/current_delta = 0.0133837 +parameters/IWR/0/current_position = 0.79176 +parameters/IWR/0/current_delta = 0.0137034 parameters/IWR/1/current_length = 0.791667 parameters/IWR/1/current_position = 0.708259 parameters/IWR/1/current_delta = 0.0166667 @@ -1213,8 +1213,8 @@ parameters/IWR/2/current_length = 1.04167 parameters/IWR/2/current_position = 1.04167 parameters/IWR/2/current_delta = 0.0 parameters/IWR/3/current_length = 0.791667 -parameters/IWR/3/current_position = 0.236442 -parameters/IWR/3/current_delta = 0.0133837 +parameters/IWR/3/current_position = 0.248939 +parameters/IWR/3/current_delta = 0.0137034 parameters/IWR/4/current_length = 0.791667 parameters/IWR/4/current_position = 0.390352 parameters/IWR/4/current_delta = 0.0166667 diff --git a/scripts/enemy.gd b/scripts/enemy.gd index 7d17a17..7fc7270 100644 --- a/scripts/enemy.gd +++ b/scripts/enemy.gd @@ -11,8 +11,8 @@ var attacks := ["Unarmed_Melee_Attack_Punch_A","Unarmed_Melee_Attack_Punch_B"] func _physics_process(_delta: float) -> void: if player == null: return - if player.dead: return - if dead: return + if player.state == States.dead: return + if state == States.dead: return var distance = global_position.distance_to(player.global_position) #print(distance) if distance <= attack_range: diff --git a/scripts/player.gd b/scripts/player.gd index e6c24e4..0d8d83b 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,11 +1,10 @@ -extends Unit class_name Player +extends Unit @export var mouse_sensitivity := 0.006 @export var rotation_speed := 24.0 var attacks := ["1h_slice_diagonal","1h_slice_horizontal","1h_attack_chop"] -var blocking := false @onready var spring_arm := $SpringArm3D @@ -13,10 +12,12 @@ var blocking := false signal gold_changed(current_gold) func _ready() -> void: - died.connect(_on_died) + state_changed.connect(_on_state_changed) -func _on_died() -> void: - print("Game Over!") +func _on_state_changed(new_state: States) -> void: + match new_state: + States.dead: + print("Game Over!") func add_gold(gold_amount: int) -> void: gold += gold_amount @@ -40,31 +41,31 @@ func _input(event: InputEvent) -> void: if event.is_action_pressed("attack"): if enough_stamina_available(attack_cost): use_stamina(attack_cost) - if blocking: anim_state.travel("Block_Attack") + if state == States.blocking: anim_state.travel("Block_Attack") else: anim_state.travel(attacks.pick_random()) #block - if Input.is_action_just_pressed("block"): blocking = true - if Input.is_action_just_released("block"): blocking = false - anim_tree.set("parameters/conditions/blocking", blocking) - anim_tree.set("parameters/conditions/not_blocking", !blocking) + if Input.is_action_just_pressed("block"): state = States.blocking + if Input.is_action_just_released("block"): state = States.idle + anim_tree.set("parameters/conditions/blocking", state == States.blocking) + anim_tree.set("parameters/conditions/not_blocking", state != States.blocking) #jump if is_on_floor() and Input.is_action_just_pressed("jump"): if enough_stamina_available(jump_cost): use_stamina(jump_cost) velocity.y = jump_speed - jumping = true + state = States.jumping anim_tree.set("parameters/conditions/grounded", false) # We just hit the floor after being in the air if is_on_floor() and not last_floor: - jumping = false + state = States.jumping anim_tree.set("parameters/conditions/grounded", true) # We're in the air, but we didn't jump - if not is_on_floor() and not jumping: + if not is_on_floor() and state != States.jumping: anim_state.travel("Jump_Idle") anim_tree.set("parameters/conditions/grounded", false) - anim_tree.set("parameters/conditions/jumping", jumping) + anim_tree.set("parameters/conditions/jumping", state == States.jumping) last_floor = is_on_floor() func get_move_input(delta: float) -> void: @@ -72,7 +73,7 @@ func get_move_input(delta: float) -> void: velocity.y = 0 var input = Input.get_vector("left", "right", "forward", "back") var dir = Vector3(input.x, 0, input.y).rotated(Vector3.UP, spring_arm.rotation.y) - if blocking: dir = Vector3.ZERO + if state == States.blocking: dir = Vector3.ZERO velocity = lerp(velocity, dir * speed, acceleration * delta) var vl = velocity * model.transform.basis anim_tree.set("parameters/IWR/blend_position", Vector2(vl.x, -vl.z) / speed) diff --git a/scripts/ui.gd b/scripts/ui.gd index 8a991d1..f6e4a0e 100644 --- a/scripts/ui.gd +++ b/scripts/ui.gd @@ -11,10 +11,10 @@ func _ready() -> void: player.stamina_changed.connect(update_stamina_bar) player.gold_changed.connect(update_gold_text) -func update_health_bar (current_health: int, maximal_health: int) -> void: +func update_health_bar (current_health, maximal_health) -> void: health_bar.value = (100 / maximal_health) * current_health -func update_stamina_bar (current_stamina: int, maximal_stamina: int) -> void: +func update_stamina_bar (current_stamina, maximal_stamina) -> void: stamina_bar.value = (100 / maximal_stamina) * current_stamina func update_gold_text (gold: int) -> void: diff --git a/scripts/unit.gd b/scripts/unit.gd index 4f1547f..e12def6 100644 --- a/scripts/unit.gd +++ b/scripts/unit.gd @@ -1,5 +1,5 @@ -extends CharacterBody3D class_name Unit +extends CharacterBody3D @export var unit_name: String @export var maximum_health := 100 @@ -19,18 +19,33 @@ class_name Unit @onready var anim_state = $AnimationTree.get("parameters/playback") var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") -var jumping := false var last_floor := true -var dead := false var stamina_timer: float var stamina_timer_max := 0.1 var hits := ["Hit_A", "Hit_B"] var deaths := ["Death_A", "Death_B"] +enum States { + idle, + walking, + running, + jumping, + attacking, + blocking, + dead +} + +var state := States.idle : + get: + return state + set(value): + state = value + state_changed.emit(value) + signal name_changed(unit_name: String) signal health_changed(current_health: int, maximum_health: int) signal stamina_changed(current_stamina: int, maximum_stamina: int) -signal died +signal state_changed(new_state: States) func _ready() -> void: name_changed.emit(unit_name) @@ -62,6 +77,5 @@ func use_stamina(stamina_needed: int) -> void: func die() -> void: print(unit_name + " died!") - dead = true + state = States.dead anim_state.travel(deaths.pick_random()) - died.emit()