/// <summary> /// 开始新游戏 /// </summary> public static void StartNewGame() { AllShapes.AutoDown(false); if (State != GameStates.Stoped && MessageBox.Show("\n 确实要重新开始游戏吗? \n ", "重新开始", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { if (State != GameStates.Paused) { AllShapes.AutoDown(true); } return; } Ini(); CanOp = true; State = GameStates.Playing; AllShapes.MakeNewShape(); AllShapes.AutoDown(true); ClassMain.formMain.labelInfo.Text = "Playing...."; if (Globals.IsPlayBackMusic) { Sound.PlayMusic(Globals.PathOfBackMusic, true); } }
//升级时播放音乐 private static void LevelSound() { Sound.PlaySound(Application.StartupPath + @"\Sounds\Level.wav", IntPtr.Zero, 1); //升级音乐 AllShapes.AutoDown(false); CanOp = false; System.Threading.Thread.Sleep(7000); AllShapes.AutoDown(true); CanOp = true; }
/// <summary> /// 开始游戏,但不还原数据(要还原数据并开始新游戏,请使用StartNewGame()) /// </summary> public static void Start() { Globals.BasePoint = new GirdPoint(0, 0); CanOp = true; State = GameStates.Playing; AllShapes.MakeNewShape(); AllShapes.AutoDown(true); ClassMain.formMain.labelInfo.Text = "Playing...."; if (Globals.IsPlayBackMusic) { Sound.PlayMusic(Globals.PathOfBackMusic, true); } }
//删除指定行 private static void DelLine(int indexOfLine) { AllShapes.AutoDown(false); Game.CanOp = false; //熄灭该行上的背景块,表现为移出了该行上的块 for (int i = 0; i < Globals.CountOfTier; i++) { if (indexOfLine % 2 == 0) //偶数行从左向由消失 { Globals.BackBlocks[indexOfLine, i].BackColor = Globals.ColorOfBackBlock; //释放被占据的网格 Globals.GirdArray[indexOfLine, i] = 0; } else //奇数行从右向左消失 { Globals.BackBlocks[indexOfLine, Globals.CountOfTier - 1 - i].BackColor = Globals.ColorOfBackBlock; //释放被占据的网格 Globals.GirdArray[indexOfLine, Globals.CountOfTier - 1 - i] = 0; } //表现为从左向右逐个消失(原来的问题是当一直按住向下键时,没有效果,解决方法是建立新线程) System.Threading.Thread.Sleep(30); } //该行以上的所有行整体下落 for (int i = indexOfLine - 1; i >= 3; i--) { for (int j = 0; j < Globals.CountOfTier; j++) { if (Globals.GirdArray[i, j] == 1) { //此块熄灭,其正下方的块点亮,表现为下落了一格 Globals.GirdArray[i, j] = 0; Globals.BackBlocks[i, j].BackColor = Globals.ColorOfBackBlock; Globals.GirdArray[i + 1, j] = 1; Globals.BackBlocks[i + 1, j].BackColor = Globals.ColorOfFixedBlock; } } } AllShapes.AutoDown(false); Game.CanOp = true; }