Exemplo n.º 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));
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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;
        }
    }
Exemplo n.º 4
0
        public void right_from_west_is_north()
        {
            var direction    = new West(_plateau);
            var newdirection = direction.TurnRight();

            Assert.That(newdirection, Is.TypeOf <North>());
        }
Exemplo n.º 5
0
        public void left_from_west_is_south()
        {
            var direction    = new West(_plateau);
            var newdirection = direction.TurnLeft();

            Assert.That(newdirection, Is.TypeOf <South>());
        }
Exemplo n.º 6
0
 public void UpdateAdjacentBlocks()
 {
     North.Update();
     South.Update();
     West.Update();
     East.Update();
 }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void GivenDirectionSouth_WhenTurnRight_ShouldDirectionWest()
        {
            var direction    = new South();
            var newdirection = direction.Right().ToString();
            var expected     = new West().ToString();

            Assert.Equal(expected, newdirection);
        }
Exemplo n.º 10
0
        public void GivenDirectionNorth_WhenTurnLeft_ShouldDirectionWest()
        {
            var direction    = new North();
            var newdirection = direction.Left().ToString();
            var expected     = new West().ToString();

            Assert.Equal(expected, newdirection);
        }
Exemplo n.º 11
0
        public void WestShouldBeNorthWhenTurnedClockWise()
        {
            IOrientation west = new West();

            var turnAntiClockWise = west.TurnClockWise();

            turnAntiClockWise.Should().BeOfType <North>();
        }
Exemplo n.º 12
0
        public void Test_West_TurnRight()
        {
            var direction = new West();

            var right = direction.TurnRight();

            Assert.AreEqual("0 1 N", right.GetDirectionAsString());
        }
Exemplo n.º 13
0
        public void When_West_And_Turn_Right_Direction_Should_Be_North()
        {
            var direction = new West(_landscape);

            var newDirection = direction.TurnRight();

            Assert.That(newDirection, Is.TypeOf <North>());
        }
Exemplo n.º 14
0
        public void When_West_And_Turn_Left_Direction_Should_Be_South()
        {
            var direction = new West(_landscape);

            var newDirection = direction.TurnLeft();

            Assert.That(newDirection, Is.TypeOf <South>());
        }
Exemplo n.º 15
0
        public void Test_West_TurnLeft()
        {
            var direction = new West();

            var left = direction.TurnLeft();

            Assert.AreEqual("0 -1 S", left.GetDirectionAsString());
        }
Exemplo n.º 16
0
        public void When_At_Start_And_Facing_West_And_Move_Do_Not_Pass_Boundary()
        {
            var direction = new West(_landscape);

            direction.Move();

            Assert.That(_landscape.CoordinateX, Is.EqualTo(0));
            Assert.That(_landscape.CoordinateY, Is.EqualTo(0));
        }
Exemplo n.º 17
0
        public void ReturnNorthWhenGetRightDirectionIsCalled()
        {
            West west = West.GetInstance();

            var result = west.GetRightDirection();

            Assert.NotNull(result);
            Assert.IsType <North>(result);
        }
Exemplo n.º 18
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));
 }
Exemplo n.º 19
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());
 }
Exemplo n.º 20
0
        public void GivenDirectionWest_WhenMove_ShouldXAxisDecremented()
        {
            var direction   = new West();
            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);
        }
Exemplo n.º 21
0
 public void Write(BinaryWriter writer)
 {
     writer.Write(Enabled);
     Position.Write(writer);
     North.Write(writer);
     East.Write(writer);
     South.Write(writer);
     West.Write(writer);
 }
Exemplo n.º 22
0
        public void MarsRover_CurrentDirectionIsWest_RotateRight_TurnsToNorth()
        {
            IDirection   direction = new West();
            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 <North>());
        }
Exemplo n.º 23
0
        public void ReturnSameInstanceWhenGetInstanceIsCalledMoreThanOnce()
        {
            West westFirst  = West.GetInstance();
            West westSecond = West.GetInstance();

            Assert.NotNull(westFirst);
            Assert.NotNull(westSecond);
            Assert.Same(westFirst, westSecond);
        }
Exemplo n.º 24
0
        public void moves_west()
        {
            var command = new West(11);

            var result = command.Move(StartingPosition);

            result.North.Should().Be(1);
            result.East.Should().Be(-10);
            result.Direction.Should().Be(Direction.E);
        }
Exemplo n.º 25
0
        public void West_MoveFromCurrentPosition_ReturnsNewCoordinate_WithXMovedBackward(
            int currentX, int currentY, int newX)
        {
            Coordinates currentPosition  = new Coordinates(currentX, currentY);
            IDirection  currentDirection = new West();
            Coordinates newCoordinates   = currentDirection.MoveFrom(currentPosition);

            Assert.AreEqual(newCoordinates.XCoordinate, newX);
            Assert.AreEqual(newCoordinates.YCoordinate, currentY);
        }
Exemplo n.º 26
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);
 }
Exemplo n.º 27
0
        public void GetTurtleDirection_West_ReturnWest()
        {
            // Arrange
            var west = new West();

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

            // Assert
            Assert.Equal(result.GetType(), west.GetType());
        }
Exemplo n.º 28
0
 private void FirstPosi()
 {
     North.SetActive(false);
     North_Open.SetActive(false);
     East.SetActive(false);
     South.SetActive(false);
     West.SetActive(false);
     Desk.gameObject.SetActive(false);
     Desk_Left.gameObject.SetActive(false);
     Desk_Right.gameObject.SetActive(false);
 }
Exemplo n.º 29
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = North.GetHashCode();
         hashCode = (hashCode * 397) ^ South.GetHashCode();
         hashCode = (hashCode * 367) ^ East.GetHashCode();
         hashCode = (hashCode * 347) ^ West.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 30
0
        public void Move_HeadedWest_ResultsInPositionToTheLeft()
        {
            const int startX = 10;
            const int startY = 12;

            Direction sut = new West();

            var moveResult = sut.Move(startX, startY);

            moveResult.x.Should().Be(startX - 1);
            moveResult.y.Should().Be(startY);
        }
Exemplo n.º 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;
        }