C
C#4mo ago
ElderToad

Towards the end of the bar being filled, I can click again. Does anyone know why?

c#
namespace FishingSharp
{
public partial class Main_Menu : Form
{
private System.Windows.Forms.Timer cooldownTimer;
private int cooldownDuration = 1000;
private int elapsedTime = 0;
private bool Fishing = false;

public Main_Menu()
{
InitializeComponent();
InitializeCooldownTimer();
}

private void InitializeCooldownTimer()
{
cooldownTimer = new System.Windows.Forms.Timer();
cooldownTimer.Interval = 20;
cooldownTimer.Tick += new EventHandler(CooldownTimer_Tick);
Cooldown.Maximum = cooldownDuration / cooldownTimer.Interval;
}

private void button1_Click(object sender, EventArgs e)
{
if (!Fishing)
{
elapsedTime = 0;
Cooldown.Value = 0;
Fishing = true;
cooldownTimer.Start();
}
}

private void CooldownTimer_Tick(object sender, EventArgs e)
{
elapsedTime += cooldownTimer.Interval ;
Cooldown.Value = elapsedTime / cooldownTimer.Interval;

if (elapsedTime >= cooldownDuration)
{
cooldownTimer.Stop();
Fishing = false;
Cooldown.Value = Cooldown.Maximum;
}
}
}
}
c#
namespace FishingSharp
{
public partial class Main_Menu : Form
{
private System.Windows.Forms.Timer cooldownTimer;
private int cooldownDuration = 1000;
private int elapsedTime = 0;
private bool Fishing = false;

public Main_Menu()
{
InitializeComponent();
InitializeCooldownTimer();
}

private void InitializeCooldownTimer()
{
cooldownTimer = new System.Windows.Forms.Timer();
cooldownTimer.Interval = 20;
cooldownTimer.Tick += new EventHandler(CooldownTimer_Tick);
Cooldown.Maximum = cooldownDuration / cooldownTimer.Interval;
}

private void button1_Click(object sender, EventArgs e)
{
if (!Fishing)
{
elapsedTime = 0;
Cooldown.Value = 0;
Fishing = true;
cooldownTimer.Start();
}
}

private void CooldownTimer_Tick(object sender, EventArgs e)
{
elapsedTime += cooldownTimer.Interval ;
Cooldown.Value = elapsedTime / cooldownTimer.Interval;

if (elapsedTime >= cooldownDuration)
{
cooldownTimer.Stop();
Fishing = false;
Cooldown.Value = Cooldown.Maximum;
}
}
}
}
1 Reply
Omnissiah
Omnissiah4mo ago
how much have you debugged this like printing elapsedTime and Fishing to debug every timer tick
Want results from more Discord servers?
Add your server