예제 #1
0
 //////
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == (Keys.A))//west
     {
         West.PerformClick();
     }
     if (keyData == (Keys.W))//north
     {
         North.PerformClick();
     }
     if (keyData == (Keys.D))//east
     {
         East.PerformClick();
     }
     if (keyData == (Keys.S))//south
     {
         South.PerformClick();
     }
     if (keyData == (Keys.R)) //rest
     {
         Restandsleep.PerformClick();
     }
     if (keyData == (Keys.Q))
     {
         Attack.PerformClick();
     }
     if (keyData == (Keys.I))
     {
         Inventor.PerformClick();
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
예제 #2
0
        private Direction GetInstanceOfDirection(string directionString)
        {
            Direction direction = null;

            switch (directionString)
            {
            case "E":
                direction = new East();
                break;

            case "W":
                direction = new West();
                break;

            case "N":
                direction = new North();
                break;

            case "S":
                direction = new South();
                break;
            }

            return(direction);
        }
예제 #3
0
        public void right_from_east_is_south()
        {
            var direction    = new East(_plateau);
            var newdirection = direction.TurnRight();

            Assert.That(newdirection, Is.TypeOf <South>());
        }
예제 #4
0
    //コンパスを確認して向きを変えたい
    private void CompassCheck()
    {
        FirstPosi();
        switch (compass)
        {
        case 0:
            North.SetActive(true);
            Desk.gameObject.SetActive(true);
            Desk_Left.gameObject.SetActive(true);
            Desk_Right.gameObject.SetActive(true);
            deskscreen = 0;
            itemgetcs.North_Item();
            break;

        case 1:
            East.SetActive(true);
            itemgetcs.East_Item();
            break;

        case 2:
            South.SetActive(true);
            itemgetcs.South_Item();
            break;

        case 3:
            West.SetActive(true);
            itemgetcs.West_Item();
            break;
        }
    }
예제 #5
0
        public void left_from_east_is_north()
        {
            var direction    = new East(_plateau);
            var newdirection = direction.TurnLeft();

            Assert.That(newdirection, Is.TypeOf <North>());
        }
예제 #6
0
        protected Direction ParseDirection(string strDirection)
        {
            Direction direction;

            switch (strDirection.ToLower())
            {
            case "north":
                direction = new North();
                break;

            case "south":
                direction = new South();
                break;

            case "east":
                direction = new East();
                break;

            case "west":
                direction = new West();
                break;

            default:
                direction = new North();
                break;
            }
            return(direction);
        }
예제 #7
0
 public void UpdateAdjacentBlocks()
 {
     North.Update();
     South.Update();
     West.Update();
     East.Update();
 }
예제 #8
0
        public void When_East_And_Turn_Right_Direction_Should_Be_South()
        {
            var direction    = new East();
            var newdirection = direction.TurnRight();

            Assert.That(newdirection, Is.TypeOf <South>());
        }
예제 #9
0
        public XmlNode ToXml(XmlNode parent)
        {
            XmlNode result = parent.OwnerDocument.CreateNode(XmlNodeType.Element, "LatLoBox", string.Empty);
            // child nodes
            XmlNode nodNorth = result.OwnerDocument.CreateNode(XmlNodeType.Element, "north", string.Empty);

            nodNorth.InnerText = North.ToString();
            result.AppendChild(nodNorth);

            XmlNode nodSouth = result.OwnerDocument.CreateNode(XmlNodeType.Element, "south", string.Empty);

            nodSouth.InnerText = South.ToString();
            result.AppendChild(nodSouth);

            XmlNode nodEast = result.OwnerDocument.CreateNode(XmlNodeType.Element, "east", string.Empty);

            nodEast.InnerText = East.ToString();
            result.AppendChild(nodEast);

            XmlNode nodWest = result.OwnerDocument.CreateNode(XmlNodeType.Element, "west", string.Empty);

            nodWest.InnerText = West.ToString();
            result.AppendChild(nodWest);

            XmlNode nodRotation = result.OwnerDocument.CreateNode(XmlNodeType.Element, "rotation", string.Empty);

            nodRotation.InnerText = Rotation.ToString();
            result.AppendChild(nodRotation);

            return(result);
        }
예제 #10
0
        public void When_East_And_Turn_Left_Direction_Should_Be_North()
        {
            var direction = new East(_landscape);

            var newDirection = direction.TurnLeft();

            Assert.That(newDirection, Is.TypeOf <North>());
        }
예제 #11
0
        public void GivenDirectionSouth_WhenTurnLeft_ShouldDirectionEast()
        {
            var direction    = new South();
            var newdirection = direction.Left().ToString();
            var expected     = new East().ToString();

            Assert.Equal(expected, newdirection);
        }
예제 #12
0
        public void GivenDirectionNorth_WhenTurnRight_ShouldDirectionEast()
        {
            var direction    = new North();
            var newdirection = direction.Right().ToString();
            var expected     = new East().ToString();

            Assert.Equal(expected, newdirection);
        }
예제 #13
0
        public void EastShouldBeSouthWhenTurnedClockWise()
        {
            IOrientation east = new East();

            var turnAntiClockWise = east.TurnClockWise();

            turnAntiClockWise.Should().BeOfType <South>();
        }
예제 #14
0
        public void When_Rover_At_3_2_East_And_Move_Should_Be_4_2()
        {
            var direction      = new East();
            var newCoordinates = direction.MoveForward(new Coordinates(3, 2));

            Assert.That(newCoordinates.XCoordinate, Is.EqualTo(4));
            Assert.That(newCoordinates.YCoordinate, Is.EqualTo(2));
        }
예제 #15
0
        public void MarsRover_initialized_HasCorrectDirection()
        {
            IDirection   direction = new East();
            Mock <IGrid> grid      = new Mock <IGrid>();
            MarsRover    marsRover = new MarsRover(direction, new Coordinates(0, 0), grid.Object);

            Assert.That(marsRover.CurrentDirection == direction);
        }
예제 #16
0
        public void Test_East_TurnLeft()
        {
            var direction = new East();

            var left = direction.TurnLeft();

            Assert.AreEqual("0 1 N", left.GetDirectionAsString());
        }
예제 #17
0
        public void Test_East_TurnRight()
        {
            var direction = new East();

            var right = direction.TurnRight();

            Assert.AreEqual("0 -1 S", right.GetDirectionAsString());
        }
예제 #18
0
        public void MarsRover_initialized_HasCorrectCoordinates()
        {
            IDirection   direction        = new East();
            Mock <IGrid> grid             = new Mock <IGrid>();
            Coordinates  startCoordinates = new Coordinates(2, 3);
            MarsRover    marsRover        = new MarsRover(direction, startCoordinates, grid.Object);

            Assert.That(marsRover.CurrentPosition == startCoordinates);
        }
예제 #19
0
        public void MarsRover_CurrentDirectionIsEast_RotateRight_TurnsToSouth()
        {
            IDirection   direction = new East();
            Mock <IGrid> grid      = new Mock <IGrid>();
            MarsRover    marsRover = new MarsRover(direction, new Coordinates(0, 0), grid.Object);

            marsRover.RotateRight();
            Assert.That(marsRover.CurrentDirection, Is.TypeOf <South>());
        }
예제 #20
0
        public void ReturnSameInstanceWhenGetInstanceIsCalledMoreThanOnce()
        {
            East eastFirst  = East.GetInstance();
            East eastSecond = East.GetInstance();

            Assert.NotNull(eastFirst);
            Assert.NotNull(eastSecond);
            Assert.Same(eastFirst, eastSecond);
        }
예제 #21
0
        public void ReturnSouthWhenGetRightDirectionIsCalled()
        {
            East east = East.GetInstance();

            var result = east.GetRightDirection();

            Assert.NotNull(result);
            Assert.IsType <South>(result);
        }
예제 #22
0
 /// <inheritdoc />
 public bool Equals(GeoBoundingBox other)
 {
     return(West.Equals(other.West) &&
            South.Equals(other.South) &&
            East.Equals(other.East) &&
            North.Equals(other.North) &&
            Nullable.Equals(MinAltitude, other.MinAltitude) &&
            Nullable.Equals(MaxAltitude, other.MaxAltitude));
 }
예제 #23
0
        public void GivenDirectionEast_WhenMove_ShouldDirectionEastAndXAxisIncremented()
        {
            var direction   = new East();
            var oldPosition = new Core.ValueObject.RoverPosition(3, 3, direction.Direction);
            var position    = direction.Move(oldPosition);

            Assert.Equal(position.X, oldPosition.X + 1);
            Assert.Equal(position.Y, oldPosition.Y);
        }
예제 #24
0
 public override void WriteLayerProperties(System.Xml.XmlTextWriter xmlWriter)
 {
     xmlWriter.WriteAttributeString("North", North.ToString());
     xmlWriter.WriteAttributeString("South", South.ToString());
     xmlWriter.WriteAttributeString("East", East.ToString());
     xmlWriter.WriteAttributeString("West", West.ToString());
     xmlWriter.WriteAttributeString("Rotation", Rotation.ToString());
     xmlWriter.WriteAttributeString("Altitude", Altitude.ToString());
 }
예제 #25
0
 public void Write(BinaryWriter writer)
 {
     writer.Write(Enabled);
     Position.Write(writer);
     North.Write(writer);
     East.Write(writer);
     South.Write(writer);
     West.Write(writer);
 }
예제 #26
0
        public void When_Moving_East_At_X_Border_Should_Not_Go_Outside_Plateau()
        {
            IDirection  direction       = new East();
            Coordinates initialPosition = new Coordinates(5, 2);
            MarsRover   rover           = new MarsRover(plateau, initialPosition, direction);

            rover.ExecuteCommands("MMMMM");
            Assert.That(rover.CurrentCoordinates.XCoordinate, Is.EqualTo(5));
            Assert.That(rover.CurrentCoordinates.YCoordinate, Is.EqualTo(2));
        }
예제 #27
0
        public void East_MoveFromCurrentPosition_ReturnsNewCoordinate_WithXMovedForward(
            int currentX, int currentY, int newX)
        {
            Coordinates currentPosition  = new Coordinates(currentX, currentY);
            IDirection  currentDirection = new East();
            Coordinates newCoordinates   = currentDirection.MoveFrom(currentPosition);

            Assert.AreEqual(newCoordinates.XCoordinate, newX);
            Assert.AreEqual(newCoordinates.YCoordinate, currentY);
        }
예제 #28
0
 // Start is called before the first frame update
 void Start()
 {
     //ボタンの有効・無効設定
     North.SetActive(true);
     East.SetActive(false);
     South.SetActive(false);
     West.SetActive(false);
     //ボタンを押したときの動作
     Left.onClick.AddListener(Left_Click);
     Right.onClick.AddListener(Right_Click);
 }
예제 #29
0
        public void When_Direction_Is_East_And_Turn_Right_Direction_Should_Be_South()
        {
            //Arrange
            var directionPoint = new East(_grid);

            //Act
            var actualResult = directionPoint.TurnRight();

            //Assert
            Assert.That(actualResult, Is.TypeOf <South>());
        }
예제 #30
0
        public void GetTurtleDirection_East_ReturnEast()
        {
            // Arrange
            var east = new East();

            // Act
            var result = Settings.GetTurtleDirection("E");

            // Assert
            Assert.Equal(result.GetType(), east.GetType());
        }
예제 #31
0
        /// <summary>
        /// Good place for IoC
        /// </summary>
        /// <returns></returns>
        public Direction InitializeAllCardinalPoints()
        {
            var north = new North { Name = "N" };
            var south = new South { Name = "S" };
            var west = new West { Name = "W" };
            var east = new East { Name = "E" };

            north.Left = west;
            north.Right = east;

            south.Left = east;
            south.Right = west;

            return north;
        }
예제 #32
0
        public void AsARoverIShouldReceiveMyInitialPositionAndAdjustAccordingly()
        {
            var east = new East();
            var rover = new Rover(east, new Coordinate("1 1"), _terrain);

            Assert.AreEqual("1 1 E", rover.Position);
        }