reworking effects, turning them into their own scene for replicability
This commit is contained in:
58
Gameplay/Effects/TimeEffect.cs
Normal file
58
Gameplay/Effects/TimeEffect.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Runtime.InteropServices.Marshalling;
|
||||
|
||||
public partial class TimeEffect : Effect
|
||||
{
|
||||
public int _calls = 0, _maxCalls = 0;
|
||||
public float _timerSeconds;
|
||||
public Timer _timer;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_timer = GetNode<Timer>("Timer");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
if (_contact._button._phone._running)
|
||||
{
|
||||
_contact._button._progressBar.Value = Math.Round(_timer.TimeLeft / _timerSeconds * 100, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Fire()
|
||||
{
|
||||
base.Fire();
|
||||
if (_calls <= _maxCalls || _maxCalls == 0)
|
||||
{
|
||||
_calls++;
|
||||
_timer.Start(_timerSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
public override void End()
|
||||
{
|
||||
_contact._button._progressBar.Value = 0;
|
||||
}
|
||||
|
||||
public virtual void SetTimer(float SECONDS)
|
||||
{
|
||||
_timerSeconds = SECONDS;
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
_calls = 0;
|
||||
_timer.Start(_timerSeconds);
|
||||
}
|
||||
|
||||
private void OnTimerTimeout()
|
||||
{
|
||||
Fire();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user