two empoered actions on cooldown
This commit is contained in:
@ -208,7 +208,6 @@ offset_left = 1524.0
|
||||
offset_top = 1.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = 1.0
|
||||
enabled = false
|
||||
initial_node_to_watch = NodePath("../StateChart")
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="."]
|
||||
@ -241,36 +240,25 @@ layout_mode = 2
|
||||
texture = ExtResource("30_h23go")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="DashCooldownIndicator" type="ColorRect" parent="UI"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 910.0
|
||||
offset_top = 549.0
|
||||
offset_right = 1010.0
|
||||
offset_bottom = 559.0
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="UI"]
|
||||
custom_minimum_size = Vector2(1920, 1080)
|
||||
offset_right = 1919.0
|
||||
offset_bottom = 1080.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="UI/CenterContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Container" type="CenterContainer" parent="UI/CenterContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CenterIcon" type="TextureRect" parent="UI/CenterContainer/VBoxContainer/Container"]
|
||||
[node name="CenterIcon" type="TextureRect" parent="UI/CenterContainer"]
|
||||
material = SubResource("CanvasItemMaterial_2q0ik")
|
||||
custom_minimum_size = Vector2(5, 5)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("32_lgpc8")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="DashIndicator" type="TextureRect" parent="UI/CenterContainer/VBoxContainer/Container"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("CanvasItemMaterial_2q0ik")
|
||||
layout_mode = 2
|
||||
texture = ExtResource("32_lgpc8")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="DashCooldownIndicator" type="ColorRect" parent="UI/CenterContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 10)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StateChart" type="Node" parent="."]
|
||||
script = ExtResource("25_wv70j")
|
||||
metadata/_custom_type_script = "uid://couw105c3bde4"
|
||||
@ -350,6 +338,43 @@ script = ExtResource("27_34snm")
|
||||
[node name="Throwing" type="Node" parent="StateChart/Root/Actions"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="PowerReserve" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("Full")
|
||||
|
||||
[node name="ToExpired" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../Expired")
|
||||
event = &"expired"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Recharge" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../AtLeastOneCharge")
|
||||
event = &"recharge"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="ToFull" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../Full")
|
||||
event = &"fully_charged"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Expired" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="AtLeastOneCharge" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="Full" type="Node" parent="StateChart/Root/PowerReserve"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="PowerUsed" type="Node" parent="StateChart/Root/PowerReserve/Full"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../AtLeastOneCharge")
|
||||
event = &"power_used"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="WeaponState" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("InHand")
|
||||
|
@ -91,6 +91,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _actionHanging;
|
||||
private StateChartState _empowerOn;
|
||||
private StateChartState _empowerOff;
|
||||
private StateChartState _powerExpired;
|
||||
private StateChartState _powerRecharging;
|
||||
private StateChartState _powerFull;
|
||||
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _crouched;
|
||||
@ -114,9 +117,10 @@ public partial class PlayerController : CharacterBody3D
|
||||
// General use stuff
|
||||
TweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
||||
PlayerUi = GetNode<PlayerUi>("UI");
|
||||
DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
||||
// DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
||||
DashCooldownIndicator = GetNode<ColorRect>("%DashCooldownIndicator");
|
||||
DashCooldownIndicator.Visible = false;
|
||||
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
||||
|
||||
// Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
|
||||
|
||||
@ -165,6 +169,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||
_empowerOn = StateChartState.Of(GetNode("StateChart/Root/Empower/On"));
|
||||
_empowerOff = StateChartState.Of(GetNode("StateChart/Root/Empower/Off"));
|
||||
_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"));
|
||||
_standing = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded/Standing"));
|
||||
@ -251,42 +258,42 @@ public partial class PlayerController : CharacterBody3D
|
||||
_dashing.StatePhysicsProcessing += Dashing;
|
||||
// _weaponThrown.StateEntered += OnWeaponThrown;
|
||||
|
||||
_empowerOn.StateEntered += OnEmpowerStarted;
|
||||
_empowerOn.StateProcessing += HandleEmpower;
|
||||
_empowerTimeDownscale.Timeout += EmpowerTimerTimeout;
|
||||
_dashCooldownTimer.Timeout += ResetDashes;
|
||||
// _empowerOn.StateEntered += OnEmpowerStarted;
|
||||
// _empowerOn.StateProcessing += HandleEmpower;
|
||||
// _empowerOff.StateEntered += EmpowerStopped;
|
||||
// _empowerTimeDownscale.Timeout += EmpowerTimerTimeout;
|
||||
|
||||
_powerFull.StateExited += StartDashCooldown;
|
||||
_powerRecharging.StateEntered += StartDashCooldown;
|
||||
_powerFull.StateEntered += StopDashCooldown;
|
||||
_dashCooldownTimer.Timeout += DashCooldownExpired;
|
||||
_powerRecharging.StateProcessing += PowerRecharging;
|
||||
_powerExpired.StateProcessing += PowerRecharging;
|
||||
}
|
||||
|
||||
public void ResetDashes()
|
||||
public void PowerRecharging(float delta)
|
||||
{
|
||||
_isDashOnCooldown = false;
|
||||
var progress = (float) (_dashCooldownTimer.TimeLeft / _dashCooldownTimer.WaitTime);
|
||||
DashCooldownIndicator.SetSize(new Vector2(100 * progress, 10));
|
||||
}
|
||||
|
||||
public void StartDashCooldown()
|
||||
{
|
||||
_dashCooldownTimer.Start();
|
||||
DashCooldownIndicator.Visible = true;
|
||||
}
|
||||
|
||||
public void StopDashCooldown()
|
||||
{
|
||||
_dashCooldownTimer.Stop();
|
||||
DashCooldownIndicator.Visible = false;
|
||||
}
|
||||
|
||||
public void OnEmpowerStarted()
|
||||
public void DashCooldownExpired()
|
||||
{
|
||||
_empowerTimeDownscale.Start();
|
||||
}
|
||||
|
||||
public void HandleEmpower(float delta)
|
||||
{
|
||||
var progress = (float) (_empowerTimeDownscale.TimeLeft / _empowerTimeDownscale.WaitTime);
|
||||
|
||||
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * progress);
|
||||
DashIndicator.Visible = true;
|
||||
}
|
||||
|
||||
public void EmpowerTimerTimeout()
|
||||
{
|
||||
EmpowerStopped();
|
||||
_isDashOnCooldown = true;
|
||||
_dashCooldownTimer.Start();
|
||||
}
|
||||
|
||||
public void EmpowerStopped()
|
||||
{
|
||||
DashIndicator.Visible = false;
|
||||
_playerState.SendEvent("empower_released");
|
||||
EmpoweredActionsLeft += 1;
|
||||
var eventToSend = EmpoweredActionsLeft == MaxNumberOfDashActions ? "fully_charged" : "recharge";
|
||||
_playerState.SendEvent(eventToSend);
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
@ -418,25 +425,20 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
private void RestoreEmpoweredActions()
|
||||
{
|
||||
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
||||
// EmpoweredActionsLeft = MaxNumberOfDashActions;
|
||||
_isWallJumpAvailable = true;
|
||||
}
|
||||
|
||||
public bool CanPerformEmpoweredAction()
|
||||
{
|
||||
return !_isDashOnCooldown;
|
||||
return EmpoweredActionsLeft > 0;
|
||||
}
|
||||
|
||||
public void PerformEmpoweredAction()
|
||||
{
|
||||
_isWallJumpAvailable = true;
|
||||
|
||||
if (!_isActionPerfectlyTimed)
|
||||
{
|
||||
EmpoweredActionsLeft--;
|
||||
}
|
||||
_empowerTimeDownscale.Stop();
|
||||
EmpowerStopped();
|
||||
EmpoweredActionsLeft--;
|
||||
_playerState.SendEvent(EmpoweredActionsLeft <= 0 ? "expired" : "power_used");
|
||||
}
|
||||
|
||||
// Jumping
|
||||
@ -546,8 +548,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
public void OnDashEnded()
|
||||
{
|
||||
_playerState.SendEvent("empower_down");
|
||||
|
||||
// Regular dash
|
||||
if (WeaponSystem.InHandState.Active)
|
||||
{
|
||||
@ -805,13 +805,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (_isDashOnCooldown)
|
||||
{
|
||||
var progress = (float) (_dashCooldownTimer.TimeLeft / _dashCooldownTimer.WaitTime);
|
||||
DashCooldownIndicator.SetCustomMinimumSize(new Vector2(100 * progress, 10));
|
||||
DashCooldownIndicator.Visible = true;
|
||||
}
|
||||
|
||||
TweenQueueSystem.ProcessTweens();
|
||||
|
||||
LookAround();
|
||||
|
@ -189,7 +189,7 @@ axis = 5
|
||||
joy_index = -1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rvpjj"]
|
||||
script = ExtResource("15_g6bbx")
|
||||
script = ExtResource("15_fykw6")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s8kjn"]
|
||||
@ -201,6 +201,7 @@ display_category = ""
|
||||
input = SubResource("Resource_fykw6")
|
||||
modifiers = Array[ExtResource("5_0qat1")]([])
|
||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_rvpjj")])
|
||||
metadata/_guide_triggers_collapsed = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vibkn"]
|
||||
script = ExtResource("1_qmhk6")
|
||||
|
Reference in New Issue
Block a user