示例#1
0
        public void WhenCompassIsBearingSouthAndIsRotatedLeftItBearsEast()
        {
            // Arrange
            var sut = new Compass();

            sut.Bearing = CardinalHeading.South;

            // Act
            sut.Rotate(Rotate.Left);

            // Assert
            Assert.AreEqual(CardinalHeading.East, sut.Bearing);
        }
示例#2
0
        public void WhenCompassIsBearingEastAndIsRotatedLeftItBearsNorth()
        {
            // Arrange
            var sut = new Compass();

            sut.Bearing = CardinalHeading.East;

            // Act
            sut.Rotate(Rotate.Left);

            // Assert
            Assert.AreEqual(CardinalHeading.North, sut.Bearing);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GlControl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            // Escape unchecks all buttons
            if (e.KeyCode == Keys.Escape)
            {
                UncheckButtons(null);
                CurrentSquare = null;
            }

            else if (e.KeyCode == Keys.Delete)
            {
                if (CurrentSquare != null)
                {
                    // Remove actor
                    if (CurrentSquare.Actor != null)
                    {
                        CurrentSquare.Actor = null;
                    }
                }
                //   if (ObjectPropertyBox.SelectedObject == null)
                //      return;

                //   //if (ObjectPropertyBox.SelectedObject is Monster)
                //   //{
                //   //   Monster monster = ObjectPropertyBox.SelectedObject as Monster;
                //   //   Maze.Monsters.Remove(monster);
                //   //}

                //   ObjectPropertyBox.SelectedObject = null;
            }
            else if (e.KeyCode == KeyboardScheme["TurnLeft"])
            {
                PreviewLoc.Direction = Compass.Rotate(PreviewLoc.Direction, CompassRotation.Rotate270);
            }

            // Turn right
            else if (e.KeyCode == KeyboardScheme["TurnRight"])
            {
                PreviewLoc.Direction = Compass.Rotate(PreviewLoc.Direction, CompassRotation.Rotate90);
            }


            // Move forward
            else if (e.KeyCode == KeyboardScheme["MoveForward"])
            {
                PreviewMove(0, -1);
            }


            // Move backward
            else if (e.KeyCode == KeyboardScheme["MoveBackward"])
            {
                PreviewMove(0, 1);
            }


            // Strafe left
            else if (e.KeyCode == KeyboardScheme["StrafeLeft"])
            {
                PreviewMove(-1, 0);
            }

            // Strafe right
            else if (e.KeyCode == KeyboardScheme["StrafeRight"])
            {
                PreviewMove(1, 0);
            }
        }
示例#4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TurnRightBox_Click(object sender, EventArgs e)
 {
     PreviewLoc.Direction = Compass.Rotate(PreviewLoc.Direction, CompassRotation.Rotate90);
 }