Beispiel #1
0
        /// <summary>
        /// Used when a keyboard key is pressed,
        /// and moves the player accordingly
        /// </summary>
        /// <param name="sender">keyboard</param>
        /// <param name="e">key pressed</param>
        private void Board_KeyDown(object sender, KeyEventArgs e)
        {
            int check;
            Key k = e.Key;

            //Moves player
            check = Board.MovePlayer(k);
            //Player arrived at goal
            if (check == 3)
            {
                FinishWindow fw = new FinishWindow();
                fw.ShowDialog();
                fw.sPlayer.Stop();
                BackToMain();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Moving player by pressed key
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Board_KeyDown(object sender, KeyEventArgs e)
        {
            int check;
            Key k = e.Key;

            check = Board.MovePlayer(k);
            Position       pos;
            MultiMazeModel tempModel = myVM.MyModel as MultiMazeModel;

            switch (k)
            {
            case Key.Left:
                tempModel.MovePlayer("Left");
                break;

            case Key.Right:
                tempModel.MovePlayer("Right");
                break;

            case Key.Up:
                tempModel.MovePlayer("Up");
                break;

            case Key.Down:
                tempModel.MovePlayer("Down");
                break;
            }
            //checks whether player won the game
            if (check == 3)
            {
                FinishWindow fw = new FinishWindow();
                fw.ShowDialog();
                myVM.MyModel.CloseGame();
                fw.sPlayer.Stop();
                BackToMain();
                fw.Close();
            }
        }