private void Timer1_Tick(object sender, EventArgs e) { if (cot > 1) { cot--; mapString.Text = "\r\n " + cot.ToString(); return; } Snack.setdirc(input); next = snack.Walk(); snackLength.Text = "Length: " + snack.getLenth(); if (next == false) { timer.Stop(); Pause.Enabled = false; Score t = new Score(); t.setLength(snack.getlength()); t.setPlayerName(playerName.Text); if (scores.add(t)) { mapString.Text += "\r\nYou Break The Record!"; } else { mapString.Text += "\r\nYou Fail!"; } SerializeObj("PlayerRecords", scores); } else { showString(); } int tt = snack.getReach(); if (tt != -1) { reach.Text = tt + " blocks\r\nwithin reach"; // + snack.getReach(); } else { reach.Text = ""; } }
private void Run(int mode) { Pause.Enabled = true; cot = 3; if (mode == 1) //手动操控蛇 { snack = new Snack(); } else { snack = new RobortSnack(); playerName.Text = "RobortSnack"; timer.Interval = 50; } timer.Interval = interval; mapString.Font = new Font(mapString.Font.FontFamily.Name, 60); mapString.Text = "\r\n 3"; timer.Start(); }