Изменение логики работы фонарика

This commit is contained in:
Евгений Титаренко 2023-08-19 03:51:26 +03:00
parent b0caf99373
commit 7c9a71504c
3 changed files with 10 additions and 8 deletions

View file

@ -11,14 +11,14 @@
[ext_resource type="Script" path="res://scripts/GameCamera.cs" id="6_quua3"]
[ext_resource type="Script" path="res://scripts/PointLight2DWorkaround.cs" id="6_slohe"]
[ext_resource type="PackedScene" uid="uid://ccg3n7sobsvdw" path="res://prefabs/enemies/watcher.tscn" id="10_fsiss"]
[ext_resource type="PackedScene" path="res://prefabs/enemies/living_armor.tscn" id="11_x3ep3"]
[ext_resource type="PackedScene" uid="uid://bpusphyhhg074" path="res://prefabs/enemies/living_armor.tscn" id="11_x3ep3"]
[ext_resource type="PackedScene" uid="uid://bj1ixwjdpnooo" path="res://prefabs/entities/pressure_plate.tscn" id="12_ynt5e"]
[ext_resource type="PackedScene" uid="uid://dqx43vr727ft8" path="res://prefabs/entities/spikes.tscn" id="13_w1hk1"]
[ext_resource type="Script" path="res://scripts/DeathScreen.cs" id="15_12mhe"]
[sub_resource type="Curve" id="Curve_o5byr"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0824742, 0.273684), -10.2105, 0.0, 0, 0, Vector2(0.242268, 0.494737), -5.10526, 0.0, 0, 0, Vector2(0.396907, 0.736842), -7.6579, 0.0, 0, 0, Vector2(0.737113, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 6
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_wg1ao"]
light_mode = 2
@ -26,7 +26,7 @@ light_mode = 2
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
shader = ExtResource("5_64d71")
[sub_resource type="ViewportTexture" id="ViewportTexture_psi2l"]
[sub_resource type="ViewportTexture" id="ViewportTexture_slh0c"]
viewport_path = NodePath("FlashlightViewport")
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
@ -122,7 +122,7 @@ CameraBounds = Vector2(30, 20)
[node name="PointLight2D" type="PointLight2D" parent="PlayerCamera" node_paths=PackedStringArray("LightViewport")]
blend_mode = 2
range_item_cull_mask = 2
texture = SubResource("ViewportTexture_psi2l")
texture = SubResource("ViewportTexture_slh0c")
script = ExtResource("6_slohe")
LightViewport = NodePath("../../FlashlightViewport")

View file

@ -10,5 +10,6 @@ public static class Constants
public const float MaxFlashlightDistance = 96;
public const float MinFlashlightDistance = 16;
public const float MaxFlashlightEnergy = 100;
public const float FlashlightEnergyPerCharge = 5;
public const float FlashlightEnergyPerCharge = 40;
public const float FlashlightDischargeModifier = 10;
}

View file

@ -20,7 +20,7 @@ public partial class Flashlight : Node
[Export] public AudioStreamPlayer CrankSoundPlayer;
private float FlashlightRadius = Constants.MaxFlashlightRadius;
private float FlashlightEnergy = Constants.MaxFlashlightEnergy;
private float FlashlightEnergy = 0;
private float FlashlightChargeTimeout = 1;
public override void _Ready()
@ -86,7 +86,8 @@ public partial class Flashlight : Node
CrankSoundPlayer.Play();
}
FlashlightEnergy = Mathf.Clamp(FlashlightEnergy - (float)delta, 0, Constants.MaxFlashlightEnergy);
FlashlightEnergy = Mathf.Clamp(FlashlightEnergy - (float)delta * Constants.FlashlightDischargeModifier,
0, Constants.MaxFlashlightEnergy);
FlashlightGroup.Modulate =
new Color(BrightnessCurve.Sample(FlashlightEnergy / Constants.MaxFlashlightEnergy), 1, 1, 1);
CollisionCircle.Disabled = CollisionPlayerCircle.Disabled = CollisionPolygon.Disabled = FlashlightEnergy < 10;