Подсказка по управлению фонарем
This commit is contained in:
parent
4d3ac1e4fb
commit
e8f5c3de80
6 changed files with 95 additions and 1 deletions
|
@ -3,6 +3,11 @@ using Godot;
|
|||
|
||||
public partial class Flashlight : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void EnergyOutEventHandler();
|
||||
[Signal]
|
||||
public delegate void ChargedEventHandler();
|
||||
|
||||
[Export] public Player Player;
|
||||
[Export] public GameCamera Camera;
|
||||
|
||||
|
@ -22,6 +27,7 @@ public partial class Flashlight : Node
|
|||
private float FlashlightRadius = Constants.MaxFlashlightRadius;
|
||||
private float FlashlightEnergy = 0;
|
||||
private float FlashlightChargeTimeout = 1;
|
||||
private bool _isDischarged = true;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
@ -79,6 +85,8 @@ public partial class Flashlight : Node
|
|||
FlashlightChargeTimeout = Mathf.Clamp(FlashlightChargeTimeout - (float)delta, 0, 1);
|
||||
if (Input.IsActionJustPressed("flashlight_charge") && FlashlightChargeTimeout <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.Charged);
|
||||
_isDischarged = false;
|
||||
FlashlightChargeTimeout = 1;
|
||||
FlashlightEnergy += Constants.FlashlightEnergyPerCharge;
|
||||
var rng = new RandomNumberGenerator();
|
||||
|
@ -91,5 +99,11 @@ public partial class Flashlight : Node
|
|||
FlashlightGroup.Modulate =
|
||||
new Color(BrightnessCurve.Sample(FlashlightEnergy / Constants.MaxFlashlightEnergy), 1, 1, 1);
|
||||
CollisionCircle.Disabled = CollisionPlayerCircle.Disabled = CollisionPolygon.Disabled = FlashlightEnergy < 10;
|
||||
|
||||
if (!_isDischarged && FlashlightEnergy < 5)
|
||||
{
|
||||
EmitSignal(SignalName.EnergyOut);
|
||||
_isDischarged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue