Merge branch 'master' of ssh://teasanctuary.ru:222/TeaSanctuary/1bit-game-jam
This commit is contained in:
commit
69436e2799
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,17 @@ public partial class Player : CharacterBody2D
|
|||
public static Player Instance { get; private set; }
|
||||
|
||||
protected AnimatedSprite2D Sprite;
|
||||
protected AnimatedSprite2D SpriteSpaceBar;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
Sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||
SpriteSpaceBar = (AnimatedSprite2D)FindChild("AnimatedSprite2D2");
|
||||
SpriteSpaceBar.Play("default");
|
||||
SpriteSpaceBar.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
|
@ -69,4 +74,13 @@ public partial class Player : CharacterBody2D
|
|||
|
||||
DeathScreen.Instance.Killed(killer);
|
||||
}
|
||||
|
||||
public void FlashlightHelperOn()
|
||||
{
|
||||
SpriteSpaceBar.Visible = true;
|
||||
}
|
||||
public void FlashlightHelperOff()
|
||||
{
|
||||
SpriteSpaceBar.Visible = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue