//click Play Again private void PicPlayAgain_Click(object sender, EventArgs e) { _snake.RemoveSnake(); PanelEnd.Visible = false; _score = 0; Lblscore.Text = string.Empty; if (_flag) { TimerShiftFood.Stop(); TimerSpeed.Stop(); } _snake = new CSnake(ref _Frm_Main, Keys.D); _fLx = _food._location.X; _fLy = _food._location.Y; _Frm_Main.Visible = false; new Frm_Setting(ref _Frm_Main).ShowDialog(); _Frm_Main.Visible = true; TimerSpeed.Interval = 1010 - ((_Speed - 1) * 50); if (_ShiftFood != 0) { TimerShiftFood.Interval = 10000 - ((_ShiftFood - 1) * 400); _flag = true; } else { _flag = false; } }
public void SetSpeed(TimerSpeed newSpeed) { switch (newSpeed) { case TimerSpeed.Normal: speed = 1.0f; break; case TimerSpeed.Fast: speed = 2.0f; break; case TimerSpeed.Fastest: speed = 3.0f; break; default: speed = 1.0f; break; } OnTimerSpeedChanged?.Invoke(); }