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;
}
}
}
}