예제 #1
0
        public Ship(Ship prevShip, Action action)
        {
            Pos = prevShip.Pos;
            Dir = prevShip.Dir;

            switch (action.Kind)
            {
            case ActionKind.North: Pos += North * action.Value; break;

            case ActionKind.South: Pos += South * action.Value; break;

            case ActionKind.East: Pos += East * action.Value; break;

            case ActionKind.West: Pos += West * action.Value; break;

            case ActionKind.Left: Dir = Dir.Rotate90(-action.Value); break;

            case ActionKind.Right: Dir = Dir.Rotate90(+action.Value); break;

            case ActionKind.Forward: Pos += Dir * action.Value; break;

            default: throw new NotImplementedException();
            }
        }
예제 #2
0
        public WaypointShip(WaypointShip prevShip, Action action)
        {
            ShipPos = prevShip.ShipPos;
            WpPos   = prevShip.WpPos;

            switch (action.Kind)
            {
            case ActionKind.North: WpPos += North * action.Value; break;

            case ActionKind.South: WpPos += South * action.Value; break;

            case ActionKind.East: WpPos += East * action.Value; break;

            case ActionKind.West: WpPos += West * action.Value; break;

            case ActionKind.Left: WpPos = WpPos.Rotate90(-action.Value); break;

            case ActionKind.Right: WpPos = WpPos.Rotate90(+action.Value); break;

            case ActionKind.Forward: ShipPos += WpPos * action.Value; break;

            default: throw new NotImplementedException();
            }
        }