//小鸟移动动画Timer private void timerBirdmove_Tick(object sender, EventArgs e) { //判断是否结束 if (_bird.isGameOver(_bird.BirdStartPosition, _pipe[0].PipePosition, 45) || _bird.isGameOver(_bird.BirdStartPosition, _pipe[1].PipePosition, 45) || _bird.isGameOver(_bird.BirdStartPosition, _pipe[2].PipePosition, 45) || _pipe[0].isBlock(_pipe[0].PipePosition, _bird.BirdStartPosition) == false || _pipe[1].isBlock(_pipe[1].PipePosition, _bird.BirdStartPosition) == false || _pipe[2].isBlock(_pipe[2].PipePosition, _bird.BirdStartPosition) == false) { //播放声音文件 PlaySound("sound/crash.wav"); //停止计时器 timerRoadMove.Stop(); _pipe[0].TimerPipeMove.Stop(); _pipe[1].TimerPipeMove.Stop(); _pipe[2].TimerPipeMove.Stop(); //停止计分 score.timerRefresh.Enabled = false; //改变小鸟当前状态 _bird.NowState = State.end; //使鼠标点击事件失效 pictureBoxGame.Enabled = false; //禁用暂停按钮 buttonPauseStart.Enabled = false; //小鸟掉落动画 _bird.BirdMove(_bird.NowState); pictureBoxGame.Refresh();//刷新游戏区 if (_bird.BirdStartPosition.Y > 405) { timerBirdmove.Stop(); //与最高分比较,写入成绩 if (_nowSc > _first) { _third = _second; _second = _first; _first = _nowSc; } else if (_nowSc > _second && _nowSc < _first) { _third = _second; _second = _nowSc; } else if (_nowSc > _third && _nowSc < _second) { _third = _nowSc; } //写入ini iniWirte(); //打开最终计分板 ScoreBoard scboard = new ScoreBoard(); scboard._BestSc = _first; scboard._Score = _nowSc; scboard.ShowDialog(); if (scboard.OpenFlag == false) { //重新初始化游戏内容 timerRoadMove.Enabled = true; pictureBoxGame.Visible = false; buttonStart.Enabled = true; buttonScore.Enabled = true; buttonSkin.Enabled = true; buttonExit.Enabled = true; buttonPauseStart.Visible = false; _bird.BirdStartPosition = new Point(80, 200); _bird.NowState = State.formal; _bird.Speed = 0; score.Visible = false; score._Score = 0; _nowSc = 0; score.scoreNum(0); } } } else { //计算分数 for (int i = 0; i < 3; i++) { if (_pipe[i]._canScore == true && _bird.BirdStartPosition.X > _pipe[i].PipePosition.X) { _pipe[i]._canScore = false; _nowSc++; PlaySound("sound/score.wav"); } } //改变计分器数字 score._Score = _nowSc; _bird.BirdMove(_bird.NowState); pictureBoxGame.Refresh();//刷新游戏区 //如果大于7分,管子开始移动,进入困难模式 if (_nowSc > 5) { for (int i = 0; i < 3; i++) { _pipe[i]._HardFlag = true; } } } }