feat: time dilation and indicator
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=38 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
[gd_scene load_steps=41 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||
[ext_resource type="Curve" uid="uid://c2a8soliruf35" path="res://systems/dash/dash_time_dilation.tres" id="2_2q0ik"]
|
||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
|
||||
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="5_4u7i3"]
|
||||
@ -36,15 +37,20 @@
|
||||
[ext_resource type="PackedScene" uid="uid://ckm3d6k08a72u" path="res://systems/weapon/weapon.tscn" id="29_wv70j"]
|
||||
[ext_resource type="Script" uid="uid://bhuwv2nlcrunt" path="res://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://systems/dash/light-ring.jpg" id="32_lgpc8"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
|
||||
height = 1.7
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
|
||||
blend_mode = 1
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
script = ExtResource("1_poq2x")
|
||||
TimeScaleAimInAir = 0.15
|
||||
MaxJumpBoostAfterDashing = 0.7
|
||||
MaxNumberOfDashActions = 2
|
||||
DashTimeDilationCurve = ExtResource("2_2q0ik")
|
||||
|
||||
[node name="InputController" type="Node3D" parent="."]
|
||||
script = ExtResource("16_v31n3")
|
||||
@ -187,7 +193,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="."]
|
||||
@ -220,6 +225,25 @@ layout_mode = 2
|
||||
texture = ExtResource("30_h23go")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="UI"]
|
||||
custom_minimum_size = Vector2(1920, 1080)
|
||||
offset_right = 1919.0
|
||||
offset_bottom = 1080.0
|
||||
|
||||
[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"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("CanvasItemMaterial_2q0ik")
|
||||
layout_mode = 2
|
||||
texture = ExtResource("32_lgpc8")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="StateChart" type="Node" parent="."]
|
||||
script = ExtResource("25_wv70j")
|
||||
metadata/_custom_type_script = "uid://couw105c3bde4"
|
||||
|
@ -24,6 +24,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
public WeaponSystem WeaponSystem;
|
||||
public WallHugSystem WallHugSystem;
|
||||
public PlayerUi PlayerUi;
|
||||
public TextureRect DashIndicator;
|
||||
|
||||
private bool _movementEnabled = true;
|
||||
|
||||
@ -53,6 +54,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
[Export(PropertyHint.Range, "0,5,1,or_greater")]
|
||||
public int MaxNumberOfDashActions { get; set; } = 1;
|
||||
[Export(PropertyHint.Range, "0,200,1,or_greater")]
|
||||
public int DashIndicatorStartSize { get; set; } = 100;
|
||||
[Export(PropertyHint.Range, "0,1,0.01")]
|
||||
public float DashProgressAfterWhichToAct { get; set; } = 0.8f;
|
||||
|
||||
[Export]
|
||||
public Curve DashTimeDilationCurve { get; set; }
|
||||
|
||||
private int _dashActionsLeft;
|
||||
public int DashActionsLeft
|
||||
@ -98,6 +106,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
// General use stuff
|
||||
TweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
||||
PlayerUi = GetNode<PlayerUi>("UI");
|
||||
DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
||||
|
||||
// Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
|
||||
|
||||
// Camera stuff
|
||||
@ -209,6 +219,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
|
||||
DashSystem.DashEnded += OnDashEnded;
|
||||
DashSystem.DashProgress += OnDashProgress;
|
||||
|
||||
_weaponInHand.StateProcessing += HandleWeaponInHand;
|
||||
_aiming.StateProcessing += HandleAiming;
|
||||
@ -427,6 +438,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
_dashDirection = (DashSystem.PlannedPlayerLocation - GlobalPosition).Normalized();
|
||||
DashSystem.Dash();
|
||||
}
|
||||
|
||||
public void OnDashProgress(float progress)
|
||||
{
|
||||
Engine.SetTimeScale(DashTimeDilationCurve.Sample(progress));
|
||||
|
||||
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * (1 - progress));
|
||||
var indicatorColor = progress < DashProgressAfterWhichToAct ? new Color(1, 1, 1) : new Color(0, 1, 0);
|
||||
DashIndicator.SetModulate(indicatorColor);
|
||||
}
|
||||
public void OnDashEnded()
|
||||
{
|
||||
// _playerState.SendEvent("enable_double_jump"); // Allow for double jump after dash -- OP ?
|
||||
|
Reference in New Issue
Block a user