protected void GameClear() { if (!run) { return; } gameTimer.Stop(); itemTimer.Stop(); itemConTimer.Stop(); MessageBox.Show("스테이지 클리어!"); if (Convert.ToInt32(mapId) >= 15) { MessageBox.Show("마지막 스테이지입니다!"); // hide main form this.Hide(); // show other form SelectStage selectStage = new SelectStage(); selectStage.Location = this.Location; selectStage.ShowDialog(); // close application this.Close(); } else { DialogResult result = MessageBox.Show("다음 스테이지로 넘어가시겠습니까?", "GameClear", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { // hide main form this.Hide(); // show other form StageMode stageMode = new StageMode(); StageMode.formName = "StageMode"; StageMode.mapId = (Convert.ToInt32(mapId) + 1).ToString(); stageMode.Location = this.Location; stageMode.ShowDialog(); // close application //this.Close(); } else { // hide main form this.Hide(); // show other form SelectStage selectStage = new SelectStage(); selectStage.Location = this.Location; selectStage.ShowDialog(); // close application this.Close(); } } }
private void btnStage_Click(object sender, EventArgs e) { // hide main form this.Hide(); // show other form SelectStage selectStage = new SelectStage(); selectStage.Location = this.Location; selectStage.ShowDialog(); // close application this.Close(); }
public void timer1_Tick(object sender, EventArgs e) { Rectangle rc = this.ClientRectangle; //새로고침 범위 최소화하기 위한 ocircle Rectangle ocircle = new Rectangle(ball.Location, ball.Size); //볼 이동 ball.Offset(ball_x, ball_y); //공 튕기기 if (ball.Bottom > rc.Bottom) { gameTimer.Stop(); MessageBox.Show("패배!"); if (Form1.formName == "StageMode") { // hide main form this.Hide(); // show other form SelectStage selectStage = new SelectStage(); selectStage.ShowDialog(); selectStage.Location = this.Location; // close application this.Close(); } else { // hide main form this.Hide(); // show other form ChallengeMode challengeMode = new ChallengeMode(); challengeMode.ShowDialog(); challengeMode.Location = this.Location; // close application this.Close(); } } else if ((ball.Left <= rc.Left || ball.Right >= rc.Right) || IsBumpedX(bar)) { ball_x = -ball_x; } else if (ball.Top < rc.Top) { ball_y = -ball_y; } else if (IsBumpedY(bar)) //공 바에 튕길 때 각도 조절 { int ballc = ball.Right - (ball.Width / 2); switch ((ballc - bar.Left) / (bar.Width / 8) + 1) { case 1: case 2: if (ball_y < 0) { ball_y = 2; } else { ball_y = -3; } if (ball_x < 0) { ball_x = -5; } else if (ball_x > 0) { ball_x = 5; } break; case 7: case 8: if (ball_y > 0) { ball_y = -2; } else { ball_y = 3; } if (ball_x < 0) { ball_x = -5; } else if (ball_x > 0) { ball_x = 5; } break; case 3: case 6: if (ball_y < 0) { ball_y = 3; } else if (ball_y > 0) { ball_y = -3; } if (ball_x < 0) { ball_x = -5; } else if (ball_x > 0) { ball_x = 5; } break; case 4: case 5: if (ball_y < 0) { ball_y = 4; } else if (ball_y > 0) { ball_y = -4; } if (ball_x < 0) { ball_x = -4; } else if (ball_x > 0) { ball_x = 4; } break; default: ball_y = -ball_y; break; } //ball_y = -ball_y; if (item1_on >= 0) { ball_x = ball_x * 3 / 2; ball_y = ball_y * 3 / 2; } } int blockNum = 0; if (item4_on >= 0) { //벽돌 맞을 경우 foreach (Control ctrl in this.Controls) { if (ctrl is PictureBox) { blockNum++; if (IsBumpedX((PictureBox)ctrl)) { this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); } else if (IsBumpedY((PictureBox)ctrl)) { this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); } } if (ctrl is Button) { if (IsBumpedX((Button)ctrl) || IsBumpedY((Button)ctrl)) { int itemId = Convert.ToInt32(ctrl.Tag.ToString()); switch (itemId) { case 1: //공 빨라짐 this.Controls.Remove(ctrl); if (item1_on < 0) { Item1(); } break; case 2: //바 짧아짐 this.Controls.Remove(ctrl); if (item2_on < 0) { Item2(); } break; case 3: //바 길어짐 this.Controls.Remove(ctrl); if (item3_on < 0) { Item3(); } break; case 4: //공 무적 this.Controls.Remove(ctrl); if (item4_on < 0) { Item4(); } break; default: break; } } } } } else { //벽돌 맞을 경우 foreach (Control ctrl in this.Controls) { if (ctrl is PictureBox) { blockNum++; if (IsBumpedX((PictureBox)ctrl)) { int iblockTag = Convert.ToInt32(ctrl.Tag.ToString()); switch (iblockTag) { case 1: //일반 벽돌 ball_x = -ball_x; this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; case 2: //돌벽돌 ball_x = -ball_x; ctrl.BackgroundImage = new Bitmap("res/block_stone2.png"); ctrl.Tag = "21"; break; case 21: //한번 맞았던 돌벽돌 ball_x = -ball_x; this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; case 3: //철벽돌 ball_x = -ball_x; break; case 4: //유리 벽돌 this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; default: break; } } else if (IsBumpedY((PictureBox)ctrl)) { int iblockTag = Convert.ToInt32(ctrl.Tag.ToString()); switch (iblockTag) { case 1: //일반 벽돌 ball_y = -ball_y; this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; case 2: //돌벽돌 ball_y = -ball_y; ctrl.BackgroundImage = new Bitmap("res/block_stone2.png"); ctrl.Tag = "21"; break; case 21: //한번 맞았던 돌벽돌 ball_y = -ball_y; this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; case 3: //철벽돌 ball_y = -ball_y; break; case 4: //유리 벽돌 this.Controls.Remove(ctrl); ItemDrop(ctrl.Left, ctrl.Right, ctrl.Bottom, ctrl.Top); break; default: break; } } } if (ctrl is Button) { if (IsBumpedX((Button)ctrl) || IsBumpedY((Button)ctrl)) { int itemId = Convert.ToInt32(ctrl.Tag.ToString()); switch (itemId) { case 1: //공 빨라짐 this.Controls.Remove(ctrl); if (item1_on < 0) { Item1(); } break; case 2: //바 짧아짐 this.Controls.Remove(ctrl); if (item2_on < 0) { Item2(); } break; case 3: //바 길어짐 this.Controls.Remove(ctrl); if (item3_on < 0) { Item3(); } break; case 4: //공 무적 this.Controls.Remove(ctrl); if (item4_on < 0) { Item4(); } break; default: break; } } } } } if (blockNum <= 0) { GameClear(); } //최소 범위만 새로고침 if (ocircle != ball) { int left = Math.Min(ocircle.Left, ball.Left); int top = Math.Min(ocircle.Top, ball.Top); int right = Math.Max(ocircle.Right, ball.Right); int bottom = Math.Max(ocircle.Bottom, ball.Bottom); this.Invalidate(new Rectangle(left, top, right - left + 1, bottom - top + 1)); } }