diff --git a/scenes/player_controller/PlayerController.tscn b/scenes/player_controller/PlayerController.tscn index 6ab18b29..6ea81023 100644 --- a/scenes/player_controller/PlayerController.tscn +++ b/scenes/player_controller/PlayerController.tscn @@ -54,7 +54,6 @@ [ext_resource type="Script" uid="uid://cf1nsco3w0mf6" path="res://addons/godot_state_charts/transition.gd" id="28_n7qhm"] [ext_resource type="PackedScene" uid="uid://ckm3d6k08a72u" path="res://scenes/player_controller/components/weapon/weapon.tscn" id="29_wv70j"] [ext_resource type="Script" uid="uid://bhuwv2nlcrunt" path="res://scenes/player_controller/PlayerUi.cs" id="30_2ghaa"] -[ext_resource type="Texture2D" uid="uid://bnwj7ltdfximr" path="res://icon.svg" id="30_h23go"] [ext_resource type="Texture2D" uid="uid://chvt6g0xn5c2m" path="res://scenes/player_controller/components/dash/light-ring.jpg" id="32_lgpc8"] [ext_resource type="Script" uid="uid://b4dwolbvt8our" path="res://addons/godot_state_charts/history_state.gd" id="41_ruloh"] [ext_resource type="Texture2D" uid="uid://c40orhfdgsim" path="res://assets/ui/IconGodotNode/white/icon_circle.png" id="45_u8rdp"] @@ -467,10 +466,6 @@ one_shot = true [node name="AirborneDashCooldown" type="Timer" parent="." unique_id=976335884] one_shot = true -[node name="PowerCooldown" type="Timer" parent="." unique_id=1091679675] -wait_time = 2.0 -one_shot = true - [node name="TimeScaleAimInAir" type="Timer" parent="." unique_id=1346687662] wait_time = 5.0 one_shot = true @@ -494,50 +489,6 @@ grow_vertical = 2 mouse_filter = 1 script = ExtResource("30_2ghaa") -[node name="MarginContainer" type="MarginContainer" parent="UI" unique_id=256626576] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -theme_override_constants/margin_left = 50 -theme_override_constants/margin_top = 50 -theme_override_constants/margin_right = 50 -theme_override_constants/margin_bottom = 50 - -[node name="VBoxContainer" type="VBoxContainer" parent="UI/MarginContainer" unique_id=74238183] -layout_mode = 2 -size_flags_horizontal = 0 -size_flags_vertical = 0 - -[node name="DashesLabel" type="Label" parent="UI/MarginContainer/VBoxContainer" unique_id=245851052] -layout_mode = 2 -text = "Empowered actions" - -[node name="HBoxContainer" type="HBoxContainer" parent="UI/MarginContainer/VBoxContainer" unique_id=81461575] -custom_minimum_size = Vector2(0, 30) -layout_mode = 2 - -[node name="Dash1" type="TextureRect" parent="UI/MarginContainer/VBoxContainer/HBoxContainer" unique_id=108366179] -unique_name_in_owner = true -layout_mode = 2 -texture = ExtResource("30_h23go") -expand_mode = 2 - -[node name="Dash2" type="TextureRect" parent="UI/MarginContainer/VBoxContainer/HBoxContainer" unique_id=140491034] -unique_name_in_owner = true -layout_mode = 2 -texture = ExtResource("30_h23go") -expand_mode = 2 - -[node name="Dash3" type="TextureRect" parent="UI/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1447308392] -unique_name_in_owner = true -layout_mode = 2 -texture = ExtResource("30_h23go") -expand_mode = 2 - [node name="CenterContainer" type="CenterContainer" parent="UI" unique_id=1479818685] custom_minimum_size = Vector2(1920, 1080) layout_mode = 1 @@ -556,24 +507,6 @@ layout_mode = 2 texture = ExtResource("32_lgpc8") expand_mode = 1 -[node name="CenterContainer2" type="CenterContainer" parent="UI" unique_id=1912042835] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 - -[node name="MarginContainer" type="MarginContainer" parent="UI/CenterContainer2" unique_id=812091083] -layout_mode = 2 -theme_override_constants/margin_top = 50 - -[node name="DashCooldownIndicator" type="ColorRect" parent="UI/CenterContainer2/MarginContainer" unique_id=1946930017] -unique_name_in_owner = true -custom_minimum_size = Vector2(100, 10) -layout_mode = 2 - [node name="EnemyTarget" type="TextureRect" parent="UI" unique_id=1113835926] unique_name_in_owner = true modulate = Color(0, 0.61278194, 0.56044877, 1) @@ -661,43 +594,6 @@ delay_in_seconds = "0.0" [node name="Canceled" type="Node" parent="StateChart/Root/Aim" unique_id=623373725] script = ExtResource("27_34snm") -[node name="PowerReserve" type="Node" parent="StateChart/Root" unique_id=240635144] -script = ExtResource("26_infe6") -initial_state = NodePath("Full") - -[node name="ToExpired" type="Node" parent="StateChart/Root/PowerReserve" unique_id=1254755786] -script = ExtResource("28_n7qhm") -to = NodePath("../Expired") -event = &"expired" -delay_in_seconds = "0.0" - -[node name="Recharge" type="Node" parent="StateChart/Root/PowerReserve" unique_id=832143267] -script = ExtResource("28_n7qhm") -to = NodePath("../AtLeastOneCharge") -event = &"recharge" -delay_in_seconds = "0.0" - -[node name="ToFull" type="Node" parent="StateChart/Root/PowerReserve" unique_id=984127202] -script = ExtResource("28_n7qhm") -to = NodePath("../Full") -event = &"fully_charged" -delay_in_seconds = "0.0" - -[node name="Expired" type="Node" parent="StateChart/Root/PowerReserve" unique_id=1558500638] -script = ExtResource("27_34snm") - -[node name="AtLeastOneCharge" type="Node" parent="StateChart/Root/PowerReserve" unique_id=10506240] -script = ExtResource("27_34snm") - -[node name="Full" type="Node" parent="StateChart/Root/PowerReserve" unique_id=1559116737] -script = ExtResource("27_34snm") - -[node name="PowerUsed" type="Node" parent="StateChart/Root/PowerReserve/Full" unique_id=397112501] -script = ExtResource("28_n7qhm") -to = NodePath("../../AtLeastOneCharge") -event = &"power_used" -delay_in_seconds = "0.0" - [node name="Attack" type="Node" parent="StateChart/Root" unique_id=808083793] script = ExtResource("26_infe6") initial_state = NodePath("Ready") diff --git a/scenes/player_controller/PlayerUi.cs b/scenes/player_controller/PlayerUi.cs index aa9b24a4..edcd5028 100644 --- a/scenes/player_controller/PlayerUi.cs +++ b/scenes/player_controller/PlayerUi.cs @@ -10,7 +10,6 @@ using Movementtests.tools; [GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")] public partial class PlayerUi : Control, ICueHandler { - internal TextureRect[] DashIcons = new TextureRect[3]; private TextureRect _enemyTarget = null!; private Healthbar _healthbar = null!; private Healthbar _manabar = null!; @@ -31,10 +30,6 @@ public partial class PlayerUi : Control, ICueHandler public override void _Ready() { - DashIcons[0] = GetNode("%Dash1"); - DashIcons[1] = GetNode("%Dash2"); - DashIcons[2] = GetNode("%Dash3"); - _enemyTarget = GetNode("%EnemyTarget"); _healthbar = GetNode("%Healthbar"); _manabar = GetNode("%Manabar"); @@ -67,17 +62,6 @@ public partial class PlayerUi : Control, ICueHandler _enemyTarget.SetModulate(modulation); } - - public void SetNumberOfDashesLeft(int numberOfDashes) - { - int index = 1; - foreach (var dashIcon in DashIcons) - { - dashIcon.SetVisible(index <= numberOfDashes); - index++; - } - } - public void OnHealthChanged(IHealthable healthable, HealthChangedRecord healthChanged) { _healthbar.CurrentHealth = healthChanged.CurrentHealth; diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 1dbb33f1..b7d702bf 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -85,8 +85,6 @@ public partial class PlayerController : CharacterBody3D, public WeaponSystem WeaponSystem = null!; public WallHugSystem WallHugSystem = null!; public PlayerUi PlayerUi = null!; - public TextureRect DashIndicator = null!; - public ColorRect PowerCooldownIndicator = null!; public Node3D DashIndicatorNode = null!; public MeshInstance3D DashIndicatorMesh = null!; public CylinderMesh DashIndicatorMeshCylinder = null!; @@ -108,8 +106,6 @@ public partial class PlayerController : CharacterBody3D, public Variables SharedVariables { get; } // Inspector stuff - [Export] public Marker3D TutorialWeaponTarget = null!; - [Export] public bool TutorialDone { get; set; } [Export] public bool HasSword { get; set; } = true; [Export] public bool HasParry { get; set; } = true; @@ -350,16 +346,6 @@ public partial class PlayerController : CharacterBody3D, private Vector3 _dashDirection = Vector3.Zero; private Vector3 _postDashThroughPosition = Vector3.Zero; private Vector3 _preDashVelocity = Vector3.Zero; - private int _empoweredActionsLeft; - public int EmpoweredActionsLeft - { - get => _empoweredActionsLeft; - set - { - _empoweredActionsLeft = value; - PlayerUi.SetNumberOfDashesLeft(value); - } - } // Settings private float _lookSensitivityMultiplier = 1.0f; @@ -373,7 +359,6 @@ public partial class PlayerController : CharacterBody3D, private Timer _weaponThrowUncatchableTimer = null!; private Timer _simpleDashCooldownTimer = null!; private Timer _airborneDashCooldownTimer = null!; - private Timer _powerCooldownTimer = null!; private Timer _invincibilityTimer = null!; private Timer _attackCooldown = null!; @@ -381,9 +366,6 @@ public partial class PlayerController : CharacterBody3D, private StateChart _playerState = null!; private StateChartState _aiming = null!; - private StateChartState _powerExpired = null!; - private StateChartState _powerRecharging = null!; - private StateChartState _powerFull = null!; private StateChartState _grounded = null!; private StateChartState _airborne = null!; @@ -510,9 +492,6 @@ public partial class PlayerController : CharacterBody3D, } // DashIndicator = GetNode("%DashIndicator"); - PowerCooldownIndicator = GetNode("%DashCooldownIndicator"); - PowerCooldownIndicator.Visible = false; - EmpoweredActionsLeft = MaxNumberOfEmpoweredActions; TargetSpeed = WalkSpeed; DashIndicatorNode = GetNode("DashIndicator"); DashIndicatorMesh = GetNode("DashIndicator/DashIndicatorMesh"); @@ -596,9 +575,6 @@ public partial class PlayerController : CharacterBody3D, _onGroundSlideJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide/OnJump")); _onAirGlideDoubleJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled/OnJump")); // _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging")); - _powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired")); - _powerRecharging = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/AtLeastOneCharge")); - _powerFull = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Full")); _grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded")); _airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne")); @@ -625,7 +601,6 @@ public partial class PlayerController : CharacterBody3D, _parryDash = StateChartState.Of(GetNode("StateChart/Root/Attack/DashParry")); // State timers - _powerCooldownTimer = GetNode("PowerCooldown"); _weaponThrowUncatchableTimer = GetNode("WeaponThrowUncatchable"); _timeScaleAimInAirTimer = GetNode("TimeScaleAimInAir"); _simpleDashCooldownTimer = GetNode("DashCooldown"); @@ -653,8 +628,6 @@ public partial class PlayerController : CharacterBody3D, WeaponSystem.Init(); WallHugSystem.Init(); - EmpoweredActionsLeft = MaxNumberOfEmpoweredActions; - // if (!TutorialDone) // PlaceWeaponForTutorial(); @@ -680,13 +653,6 @@ public partial class PlayerController : CharacterBody3D, _coyoteEnabled.StateEntered += StartCoyoteTime; _timeScaleAimInAirTimer.Timeout += ResetTimeScale; - _powerFull.StateEntered += StopPowerCooldown; - _powerFull.StateExited += StartPowerCooldown; - _powerRecharging.StateEntered += StartPowerCooldown; - _powerCooldownTimer.Timeout += PowerCooldownExpired; - _powerRecharging.StateProcessing += PowerRecharging; - _powerExpired.StateProcessing += PowerRecharging; - _simpleJump.StateEntered += OnSimpleJumpStarted; _simpleJump.StatePhysicsProcessing += HandleSimpleJump; @@ -832,21 +798,6 @@ public partial class PlayerController : CharacterBody3D, _fovChangeMultiplier = (float) config.GetValue("InputSettings", "FovChangeWithSpeed", 1.0f); _aimAssistMultiplier = (float) config.GetValue("InputSettings", "AimAssist", 1.0f); } - public void OnTutorialDone(Node3D _) - { - TutorialDone = true; - } - public void PlaceWeaponForTutorial() - { - if (TutorialDone) - return; - - RemoveChild(WeaponSystem); - GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, WeaponSystem); - WeaponSystem.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition); - WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition); - } - /////////////////////////// // Toolbox Utils // @@ -2009,28 +1960,6 @@ public partial class PlayerController : CharacterBody3D, /////////////////////////// // Empowerement management // /////////////////////////// - public void PowerRecharging(float delta) - { - var progress = (float) (_powerCooldownTimer.TimeLeft / _powerCooldownTimer.WaitTime); - PowerCooldownIndicator.SetCustomMinimumSize(new Vector2(100 * progress, 10)); - } - public void StartPowerCooldown() - { - _powerCooldownTimer.Start(); - PowerCooldownIndicator.Visible = true; - } - public void StopPowerCooldown() - { - _powerCooldownTimer.Stop(); - PowerCooldownIndicator.Visible = false; - } - public void PowerCooldownExpired() - { - EmpoweredActionsLeft += 1; - var eventToSend = EmpoweredActionsLeft == MaxNumberOfEmpoweredActions ? "fully_charged" : "recharge"; - _playerState.SendEvent(eventToSend); - } - public bool CanPerformEmpoweredAction() { if(_empoweredActionHandle == null) return false; @@ -2059,8 +1988,6 @@ public partial class PlayerController : CharacterBody3D, _isWallJumpAvailable = true; _canDashAirborne = true; - EmpoweredActionsLeft--; - _playerState.SendEvent(EmpoweredActionsLeft <= 0 ? "expired" : "power_used"); Events.Raise(new EventData { diff --git a/tests/player/PlayerControllerUnitTest.cs b/tests/player/PlayerControllerUnitTest.cs index a32d4cec..45a40ba6 100644 --- a/tests/player/PlayerControllerUnitTest.cs +++ b/tests/player/PlayerControllerUnitTest.cs @@ -94,22 +94,6 @@ public class PlayerControllerUnitTest AssertFloat(_player.CHealth.CurrentHealth).IsEqual(75.0f); } - [TestCase] - public void TestEmpoweredActionsLeft() - { - var mockUi = new PlayerUi(); - var dashIcons = new TextureRect[3] { new TextureRect(), new TextureRect(), new TextureRect() }; - mockUi.DashIcons = dashIcons; - - _player.PlayerUi = mockUi; - - _player.EmpoweredActionsLeft = 2; - AssertInt(_player.EmpoweredActionsLeft).IsEqual(2); - AssertBool(dashIcons[0].Visible).IsTrue(); - AssertBool(dashIcons[1].Visible).IsTrue(); - AssertBool(dashIcons[2].Visible).IsFalse(); - } - [TestCase] public void TestDashCooldownTimeout() {