Солуянова Семестровая Марио. Введение в ии
![]()
|
| lbl_Level.Text = "Level " + (LevelManager.Instance.CurrentLevelIndex + 1).ToString() + " (" + LevelManager.Instance.CurrentLevelName + ")"; | |||||
| lbl_numCoins.Text = lev?.MarioObject?.NumberOfCollectedCoins.ToString(); | |||||
| lbl_numLives.Text = LevelManager.Instance.MarioLives.ToString(); | |||||
| } | |||||
| | |||||
| private void MainForm_KeyDown(object sender, KeyEventArgs e) | |||||
| { | |||||
| Boolean KeyRight = false; | |||||
| Boolean KeyLeft = false; | |||||
| | |||||
| int state = Convert.ToInt32(GetAsyncKeyState(Keys.Right).ToString()); | |||||
| KeyRight = (state == -32767); | |||||
| state = Convert.ToInt32(GetAsyncKeyState(Keys.Left).ToString()); | |||||
| KeyLeft = (state == -32767); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Up) | |||||
| lev.MarioObject.StartJump(false,0); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Right || KeyRight) | |||||
| lev.MarioObject.MarioMove(Mario.MarioMoveState.J_Right); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Left || KeyLeft) | |||||
| lev.MarioObject.MarioMove(Mario.MarioMoveState.J_Left); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Space) | |||||
| lev.MarioObject.MarioFireBall(); | |||||
| | |||||
| | |||||
| if(e.KeyValue == (int)Keys.Enter) | |||||
| lev.MarioObject.EnterPressed = true; | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Escape) | |||||
| this.Close(); | |||||
| | |||||
| | |||||
| //if (e.KeyValue == (int)Keys.Down) | |||||
| // BM.newy += 2; | |||||
| } | |||||
| | |||||
| private void frmMain_KeyUp(object sender, KeyEventArgs e) | |||||
| { | |||||
| if (e.KeyValue == (int)Keys.ControlKey) | |||||
| lev.MarioObject.StopJump(); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Right) | |||||
| lev.MarioObject.StopMove(); | |||||
| | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Left) | |||||
| lev.MarioObject.StopMove(); | |||||
| | |||||
| if (e.KeyValue == (int)Keys.Up) | |||||
| lev.MarioObject.UpPressed = false; | |||||
| } | |||||
| | |||||
| | |||||
| public void Load_Level(LevelManagerLoadTypes levelLoadType) | |||||
| { | |||||
| TimerGenerator.RemoveAllTimerEvents(); | |||||
| | |||||
| Init_Properties(); | |||||
| | |||||
| lev = LevelManager.Instance.LoadLevel(levelLoadType); | |||||
| | |||||
| lev.MarioObject.OnLevelCompleted += (() => Load_Level(LevelManagerLoadTypes.NEXT)); | |||||
| lev.MarioObject.OnMarioDied += (() => Load_Level(LevelManagerLoadTypes.RELOAD)); | |||||
| | |||||
| lev.MarioObject.x = 20; | |||||
| lev.MarioObject.y = LevelGenerator.LevelHeight - 16 * 1 - lev.MarioObject.height; | |||||
| LevelGenerator.CurrentLevel.Update_ScreensX(); | |||||
| LevelGenerator.CurrentLevel.Update_ScreensY(); | |||||
| | |||||
| LevelBeginTime = DateTime.Now; | |||||
| | |||||
| Invalidate(); | |||||
| } | |||||
| | |||||
| private void frmMain_MouseDown(object sender, MouseEventArgs e) | |||||
| { | |||||
| if (e.Button == MouseButtons.Left) | |||||
| { | |||||
| ReleaseCapture(); | |||||
| SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); | |||||
| } | |||||
| } | |||||
| | |||||
| private void pMain_MouseDown(object sender, MouseEventArgs e) | |||||
| { | |||||
| frmMain_MouseDown(sender, e); | |||||
| } | |||||
| | |||||
| private void pMain_Paint(object sender, PaintEventArgs e) | |||||
| { | |||||
| Graphics xGraph = e.Graphics; | |||||
| |