Sun scoring and zombie hat impulse
This commit is contained in:
parent
0e5dee50f7
commit
6608fb8389
9 changed files with 62 additions and 7 deletions
|
|
@ -6,27 +6,44 @@ namespace Newlon;
|
|||
|
||||
public partial class Sun : Area2D
|
||||
{
|
||||
public static Control Counter;
|
||||
|
||||
[Export] public int amount = 25;
|
||||
[Export] private Timer _deathTimer;
|
||||
[Export] private AnimationPlayer _rotation;
|
||||
[Export] private AnimationPlayer _fade;
|
||||
|
||||
private bool scoring;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_rotation.SpeedScale = 1.0f + GD.Randf() / 2.0f;
|
||||
}
|
||||
public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx)
|
||||
{
|
||||
if (scoring) return;
|
||||
|
||||
if (@event.IsActionPressed("primary_action"))
|
||||
{
|
||||
RuntimeLevelData.Instance.AddSun(amount);
|
||||
QueueFree();
|
||||
|
||||
_fade.Stop();
|
||||
scoring = true;
|
||||
|
||||
var tween = CreateTween();
|
||||
tween.TweenInterval(0.1);
|
||||
tween.TweenProperty(this, "global_position", GetCanvasTransform().AffineInverse() * (Counter.GlobalPosition + Counter.PivotOffset), 0.5).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
|
||||
tween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
RuntimeLevelData.Instance.AddSun(amount);
|
||||
QueueFree();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_deathTimer.TimeLeft/_deathTimer.WaitTime <= 0.25)
|
||||
if (scoring) return;
|
||||
if (_deathTimer.TimeLeft / _deathTimer.WaitTime <= 0.25)
|
||||
{
|
||||
_fade.Play("main");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue