示例#1
0
        public void VeerLeft()
        {
            HexDirection dir  = HexDirection.DownLeft;
            var          dir2 = dir.VeerLeft();

            Assert.AreEqual(HexDirection.Down, dir2);
        }
示例#2
0
        public void VeerLeftBorderCondition()
        {
            HexDirection dir  = HexDirection.UpRight;
            var          dir2 = dir.VeerLeft();

            Assert.AreEqual(HexDirection.Up, dir2);
        }
示例#3
0
        public void Move(Movements m)
        {
            switch (m)
            {
            case Movements.Stay:
                break;

            case Movements.ChangeHeadingPort:
            {
                Heading = Heading.VeerLeft();
                break;
            }

            case Movements.ChangeHeadingStarboard:
            {
                Heading = Heading.VeerRight();
                break;
            }

            case Movements.MoveForwardHalf:
            {
                var neighbor = Hex.GetNeighborAtDirection(Heading);
                Position = Position.Add(neighbor);
                break;
            }

            case Movements.MoveForwardFull:
            {
                var neighbor = Hex.GetNeighborAtDirection(Heading);
                Position = Position.Add(neighbor.Multiply(2));
                break;
            }

            case Movements.MoveForwardChangeHeadingPort:
            {
                Position = Position.Add(Hex.GetNeighborAtDirection(Heading));
                Heading  = Heading.VeerLeft();
                break;
            }

            case Movements.MoveForwardChangeHeadingStarboard:
            {
                Position = Position.Add(Hex.GetNeighborAtDirection(Heading));
                Heading  = Heading.VeerRight();
                break;
            }

            case Movements.SideslipPort:
            {
                var sideStepDirection = Hex.GetNeighborAtDirection(Heading.VeerLeft());
                var sideStep          = sideStepDirection.Add(Position);
                Position = sideStep.Add(Hex.GetNeighborAtDirection(Heading));
                break;
            }

            case Movements.SideslipStarboard:
            {
                var sideStepDirection = Hex.GetNeighborAtDirection(Heading.VeerRight());
                var sideStep          = sideStepDirection.Add(Position);
                Position = sideStep.Add(Hex.GetNeighborAtDirection(Heading));
                break;
            }
            }
        }