Пример #1
0
 public ControllableModel(Game game, Model model, Entity entity, MoveMode style, Vector3 forward)
     : base(game, model, entity)
 {
     this.forward = forward;
     this.forward.Y = 0f;
     this.forward.Normalize();
     this.moveMode = style;
     if (this.moveMode == MoveMode.Directional)
     {
        this.camera.fixate(this, 15.0f);
     }
 }
Пример #2
0
        /// <summary>
        /// Zeigt den Dialog an
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public DialogResult ShowDialog(MoveMode mode)
        {
            InternalMoveMode=mode;

            if (InternalMoveMode==MoveMode.enCategory)
            {
                Text="Kategorie verschieben...";
            }
            else if (InternalMoveMode==MoveMode.enDocument)
            {
                Text="Dokument in andere Kategorie verschieben...";
            }

            return base.ShowDialog();
        }
Пример #3
0
        protected void FinalPoint()
        {
            var yc = 0.0;
            try
            {
            yc = Y - _moveY;
            }
            catch (Exception)
            {
            }

            var xc = 0.0;
            try
            {
            xc = _moveX - X;
            }
            catch (Exception)
            {
            }

            if (Math.Sqrt(yc*yc + xc*xc) < Size/3)
            _moveMode = MoveMode.False;

            var acc = true;

            switch (_moveMode)
            {
            case MoveMode.To:
                HeadTo(RobotMath.ToDeg(Math.Atan2(yc, xc)));
                break;
            case MoveMode.Away:
                HeadTo(RobotMath.ToDeg(Math.Atan2(yc, xc)) + 180);
                break;
            case MoveMode.SideA:
                HeadTo(RobotMath.ToDeg(Math.Atan2(yc, xc)) + 60);
                break;
            case MoveMode.SideB:
                HeadTo(RobotMath.ToDeg(Math.Atan2(yc, xc)) - 60);
                break;
            case MoveMode.False:
                acc = false;
                break;
            default:
                throw new Exception("Unknown move mode!");
            }

            if (acc) Accelerate(8);
        }
Пример #4
0
        protected override bool MoveProcess(IAxis Axis, MoveMode Mode, int Speed, int Steps)
        {
            bool ret  = false;
            var  axis = Axis as IrixiM12Axis;

            int stepToMove = 0;

            if (axis.IsHomed == false)
            {
                axis.LastError = "the axis is not homed";
                return(false);
            }

            if (axis.Lock())
            {
                try
                {
                    // calculate how many steps to move to the target position, this is based on the
                    // mode of moving. The RELATIVE STEPS are accepted by the M12.
                    if (Mode == MoveMode.ABS)
                    {
                        stepToMove = Math.Abs(Steps) - axis.AbsPosition;
                    }
                    else
                    {
                        stepToMove = Steps;
                    }

                    // Move the the target position
                    if (axis.CheckSoftLimitation(axis.AbsPosition + stepToMove))
                    {
                        try
                        {
                            // limit the speed to the maximum value defined in the config file.
                            Speed = Speed * axis.MaxSpeed / 100;

                            _m12.Move(axis.ID, stepToMove, (byte)Speed);
                            ret = true;
                        }
                        catch (Exception ex)
                        {
                            if (ex is UnitErrorException && ((UnitErrorException)ex).Error == Errors.ERR_USER_STOPPED)
                            {
                                // ignore the `user stop` error.
                                ret = true;
                            }
                            else
                            {
                                axis.LastError = $"sdk reported error code {ex.Message}";
                                ret            = false;
                            }
                        }
                    }
                    else
                    {
                        axis.LastError = "target position exceeds the limitation.";

                        ret = false;
                    }
                }
                catch (Exception ex)
                {
                    axis.LastError = ex.Message;
                    ret            = false;
                }
            }
            else
            {
                axis.LastError = "the axis is locked.";
                ret            = false;
            }

            return(ret);
        }
 public void MoveTo(Vec3 pos, MoveMode mode)
 {
     FCE_ObjectSelection_MoveTo(this.m_selPtr, pos.X, pos.Y, pos.Z, mode);
 }
Пример #6
0
 public void StopMovingPlayerShip(MoveMode moveMode)
 {
     PlayerShip.StopMoving(moveMode);
 }
Пример #7
0
        public Vector2 TryToMove(Vector2 wantsToMoveAmount, Vector2 deltaPosition = default, MoveMode mode = MoveMode.HorizontalFirst)
        {
            Vector2 movedAmount = deltaPosition;

            foreach (MoveUnit moveUnit in mode.GetMoveUnits(wantsToMoveAmount))
            {
                if (!RaycastHelpers.IsValidDistance(moveUnit.distance))
                {
                    continue;
                }

                movedAmount[moveUnit.axis] = moveUnit.dir * TryToMove(moveUnit.distance, moveUnit.dir, deltaPosition);
            }
            return(movedAmount - deltaPosition);
        }
Пример #8
0
        protected override bool MoveProcess(Interfaces.IAxis Axis, MoveMode Mode, int Speed, int Distance)
        {
            LuminosAxis axis = Axis as LuminosAxis;

            bool ret        = false;
            int  target_pos = 0;

            if (axis.IsHomed == false)
            {
                axis.LastError = "the axis is not homed";
                return(false);
            }

            // lock the axis
            if (axis.Lock())
            {
                // Set the move speed
                if (Mode == MoveMode.ABS)
                {
                    target_pos = Math.Abs(Distance);
                }
                else
                {
                    target_pos = axis.AbsPosition + Distance;
                }

                // Move the the target position
                if (axis.CheckSoftLimitation(target_pos))
                {
                    try
                    {
                        DeviceMessage zaber_msg = axis.ZaberConversation.Request(Command.MoveAbsolute, target_pos);

                        if (zaber_msg.HasFault == false)
                        {
                            ret = true;
                        }
                        else
                        {
                            axis.LastError = string.Format("sdk reported error code {0}", zaber_msg.Text);

                            ret = false;
                        }
                    }
                    catch (RequestReplacedException ex)
                    {
                        DeviceMessage actualResp = ex.ReplacementResponse;
                        if (actualResp.Command == Command.Stop)
                        {
                            // if STOP was send while moving
                            axis.AbsPosition = (int)actualResp.Data;
                            ret = true;
                        }
                        else
                        {
                            axis.LastError = ex.Message;
                            ret            = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        axis.LastError = ex.Message;
                        ret            = false;
                    }
                }
                else
                {
                    axis.LastError = "target position exceeds the limitation.";

                    ret = false;
                }

                axis.Unlock();
            }
            else
            {
                axis.LastError = "the axis is locked.";
                ret            = false;
            }

            return(ret);
        }
Пример #9
0
    private void UnSnap(float angle, MoveMode newMode)
    {
        SetAniamation("fly", true);
        var sqrtTolerance = 1.5f;
        var sqrtDistance = 0f;

        if (State.SlopeShiftMovement != Vector3.zero)
        {
            if (State.SlopeShiftMovement != Vector3.zero)
            {
                _transform.position = Vector3.Lerp(transform.position, State.SlopeShiftMovement, Time.deltaTime * 9);

                sqrtDistance = (transform.position - State.SlopeShiftMovement).sqrMagnitude;
                var maxDistance = 0.01f;
                if (sqrtDistance < maxDistance * maxDistance)
                {
                    _transform.position = State.SlopeShiftMovement;
                    State.SlopeShiftMovement = Vector3.zero;
                }
            }
        }

        if (sqrtDistance < sqrtTolerance)
        {
            if (!isRotationEnds)
            {
                var _rotationTime =  Mathf.Clamp(Mathf.Abs(angle)/270.0f, 0.4f, 0.7f);
                RotateWhileSnapping (angle, _rotationTime);
            }
        }

        if (isRotationEnds && State.SlopeShiftMovement == Vector3.zero)
        {
            State.MovingMode = newMode;
            transform.eulerAngles = new Vector3(0, 0, 0);
            isRotationEnds = false;
        }
    }
Пример #10
0
        /// <summary>
        /// Moves a node with the given path.
        /// </summary>
        /// <param name="ringMaster">The ringmaster handler to operate on</param>
        /// <param name="pathSrc">Node Path to move</param>
        /// <param name="version">Version of the source node</param>
        /// <param name="pathDst">Node Path to be parent of the moved node</param>
        /// <param name="moveMode">Modifiers for the move operation</param>
        /// <returns>Task that will resolve on success to the path to the newly created node</returns>
        public static async Task <string> Move(this IRingMasterRequestHandler ringMaster, string pathSrc, int version, string pathDst, MoveMode moveMode)
        {
            RequestResponse response = await ringMaster.Request(
                new RequestMove(
                    pathSrc,
                    version,
                    pathDst,
                    moveMode));

            ThrowIfError(response);
            return((string)response.Content);
        }
Пример #11
0
        /// <summary>
        /// Move the specified axis synchronously
        /// </summary>
        /// <param name="AxisIndex"></param>
        /// <param name="Velocity"></param>
        /// <param name="Position"></param>
        /// <param name="Mode"></param>
        /// <returns></returns>
        public bool Move(int AxisIndex, int Velocity, int Position, MoveMode Mode)
        {
            int _curr_pos      = this.Report.AxisStateCollection[AxisIndex].AbsPosition; // Get current ABS position
            int _pos_aftermove = 0;

            if (AxisIndex >= this.TotalAxes)
            {
                this.LastError = string.Format("The param of axis index if error.");
                return(false);
            }
            // if the controller is not connected, return
            else if (!this.IsConnected)
            {
                this.LastError = string.Format("The controller is not connected.");
                return(false);
            }

            // If the axis is not homed, return.
            if (this.Report.AxisStateCollection[AxisIndex].IsHomed == false)
            {
                this.LastError = string.Format("Axis {0} is not homed.", AxisIndex);
                return(false);
            }

            // If the axis is busy, return.
            if (this.Report.AxisStateCollection[AxisIndex].IsRunning)
            {
                this.LastError = string.Format("Axis {0} is busy.", AxisIndex);
                return(false);
            }

            if (Velocity < 1 || Velocity > 100)
            {
                this.LastError = string.Format("The velocity should be 1 ~ 100.");
                return(false);
            }

            //
            // Validate the parameters restricted in the config file
            //
            // MaxDistance > 0
            if (this.AxisCollection[AxisIndex].MaxSteps == 0)
            {
                this.LastError = string.Format("The value of the Max Distance has not been set.");
                return(false);
            }


            // SoftCWLS > SoftCCWLS
            if (this.AxisCollection[AxisIndex].SoftCWLS <= this.AxisCollection[AxisIndex].SoftCCWLS)
            {
                this.LastError = string.Format("The value of the SoftCWLS should be greater than the value of the SoftCCWLS.");
                return(false);
            }

            // SoftCWLS >= MaxDistance
            if (this.AxisCollection[AxisIndex].SoftCWLS < this.AxisCollection[AxisIndex].MaxSteps)
            {
                this.LastError = string.Format("The value of the SoftCWLS should be greater than the value of the Max Distance.");
                return(false);
            }

            // SoftCCWLS <= PosAfterHome <= SoftCWLS
            if ((this.AxisCollection[AxisIndex].SoftCCWLS > this.AxisCollection[AxisIndex].PosAfterHome) ||
                (this.AxisCollection[AxisIndex].PosAfterHome > this.AxisCollection[AxisIndex].SoftCWLS))
            {
                this.LastError = string.Format("The value of the PosAfterHome exceeds the soft limitaion.");
                return(false);
            }


            //
            // Validate the position after moving,
            // if the position exceeds the soft limitation, do not move
            //
            if (Mode == MoveMode.ABS)
            {
                if (Position < this.AxisCollection[AxisIndex].SoftCCWLS || Position > this.AxisCollection[AxisIndex].SoftCWLS)
                {
                    this.LastError = string.Format("The target position is out of range.");
                    return(false);
                }
                else
                {
                    _pos_aftermove = Position;

                    Position = Position - _curr_pos;
                }
            }
            else // rel positioning
            {
                _pos_aftermove = (int)(_curr_pos + Position);

                if (Position > 0) // CW
                {
                    // if (_pos_aftermove > this.AxisCollection[AxisIndex].SoftCWLS)
                    if (_pos_aftermove > this.AxisCollection[AxisIndex].MaxSteps)
                    {
                        this.LastError = string.Format("The position you are going to move exceeds the soft CW limitation.");
                        return(false);
                    }
                }
                else // CCW
                {
                    // if (_pos_aftermove < this.AxisCollection[AxisIndex].SoftCCWLS)
                    if (_pos_aftermove < 0)
                    {
                        this.LastError = string.Format("The position you are going to move exceeds the soft CCW limitation.");
                        return(false);
                    }
                }
            }

            try
            {
                // No need to move
                if (Position == 0)
                {
                    return(true);
                }

                // write the 'move' command to the controller
                CommandStruct cmd = new CommandStruct()
                {
                    Command       = EnumCommand.MOVE,
                    AxisIndex     = AxisIndex,
                    AccSteps      = this.AxisCollection[AxisIndex].AccelerationSteps,
                    DriveVelocity = Velocity * this.AxisCollection[AxisIndex].MaxSpeed / 100,
                    TotalSteps    = Position
                };
                _hid_device.Write(cmd.ToBytes());

                // wait for the next hid report
                uint _report_counter = this.Report.Counter + 1;
                do
                {
                    Thread.Sleep(2);
                } while (this.Report.Counter <= _report_counter);

                // the TRUE value of the IsRunning property indicates that the axis is running
                // wait until the running process is done
                while (this.Report.AxisStateCollection[AxisIndex].IsRunning)
                {
                    Thread.Sleep(2);
                }

                if (Report.AxisStateCollection[AxisIndex].Error != 0)
                {
                    this.LastError = string.Format("error code {0:d}", Report.AxisStateCollection[AxisIndex].Error);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                this.LastError = ex.Message;
                return(false);
            }
        }
Пример #12
0
 public static void OnMoving(MoveMode movingState, float velocity)
 {
     if (onPlayerMove != null)
     {
         onPlayerMove(movingState, velocity);
     }
 }
Пример #13
0
 /// <summary>
 /// Changes the view depending on the supplied parameter.
 /// </summary>
 /// <param name="moveMode">The move mode.</param>
 internal void ChangeView(MoveMode moveMode)
 {
     this.Send(string.Format("/layerApi.aspx?cmd=move&move={0}", moveMode));
 }
Пример #14
0
 private void finishStateChange(IEnumerable<RigidBody> bodies)
 {
     moveMode = MoveMode.None;
     if (stateInChange != null)
     {
         stateInChange.After = bodies;
         states.saveState(stateInChange);
         stateInChange = null;
     }
     //if (selectedButNotMoving.Count != 0)
     //{
     //    selected.Add(selectedButNotMoving);
     //    selectedButNotMoving = Selection.Empty;
     //}
 }
Пример #15
0
        public void whileMouseOver(GameTime gameTime, InputManager input,
            RigidBody _hitBody, Ray _hitNormal, float _hitDistance)
        {
            mouseOverRanSinceLastLeftMousePress = true;
            bool leftPressed =
                 input.Mouse_WasButtonPressed(MouseButton.Left) &&
                !input.Mouse_IsButtonDown(MouseButton.Right);
            bool rightPressed =
                 input.Mouse_WasButtonPressed(MouseButton.Right) &&
                !input.Mouse_IsButtonDown(MouseButton.Left);

            if (leftPressed || rightPressed)
            {
                bool shiftDown = input.Keyboard_IsKeyDown(Keys.LeftShift);
                bool ctrlDown = input.Keyboard_IsKeyDown(Keys.LeftControl);
                bool altDown = input.Keyboard_IsKeyDown(Keys.LeftAlt);

                Paused = true; //must be done before much, if not everything, else

                if (leftPressed)
                {
                    if (ctrlDown) //expand (or reduce) selection
                    {
                        moveMode = MoveMode.None;
                        selected.toggleSelection(_hitBody);
                        return;
                    }
                    else
                    {
                        moveMode = MoveMode.CameraRelative;
                    }
                }
                else //rightPressed
                {
                    if (shiftDown)
                    {
                        moveMode = MoveMode.LineRelative;
                    }
                    else
                    {
                        moveMode = MoveMode.PlaneRelative;
                    }
                }

                if (!selected.Contains(_hitBody))
                {
                    selected.Clear();
                }
                selected.Add(_hitBody);

                if (altDown) //copy and move
                {
                    //if (ctrlDown)
                    //{
                    //    selectedButNotMoving = selected;
                    //}
                    selected = selected.copy(true);
                    startStateChange(null);
                }
                else //just move
                {
                    startStateChange(selected);
                }

                moveOffset = _hitNormal.Position - selected.Position;

                switch (moveMode)
                {
                    case MoveMode.CameraRelative:
                        hitDistance = _hitDistance;
                        break;
                    case MoveMode.LineRelative:
                        hitNormal = _hitNormal;
                        break;
                    case MoveMode.PlaneRelative:
                        plane = new MyPlane(_hitNormal);
                        break;
                }
            }
        }
Пример #16
0
        public void Input(GameTime gameTime, InputManager input)
        {
            if (!Active)
                return;
            if (input.Keyboard_WasKeyPressed(Keys.S) &&
                input.Keyboard_IsKeyDown(Keys.LeftControl))
            {
                StorageManager.Save(Engine.Map);
            }
            if (input.Keyboard_WasKeyPressed(Keys.O) &&
                input.Keyboard_IsKeyDown(Keys.LeftControl))
            {
                startStateChange(null);
                Map newMap = StorageManager.Load(Engine);
                Engine.Map = newMap;
                finishStateChange(newMap.Bodies);
            }
            if (input.Keyboard_WasKeyPressed(Keys.Space))
            {
                Paused = !Paused;
            }
            if (input.Keyboard_WasKeyPressed(Keys.Delete))
            {
                startStateChange(selected);
                finishStateChange(null);
                selected.Clear();
                selected.Active = false;
            }

            if (input.Mouse_WasButtonPressed(MouseButton.Left))
            {
                mouseOverRanSinceLastLeftMousePress = false;
            }
            if (!mouseOverRanSinceLastLeftMousePress &&
                input.Mouse_WasButtonReleased(MouseButton.Left))
            {
                mouseOverRanSinceLastLeftMousePress = true;
                selected.Clear();
            }

            bool shift = input.Keyboard_IsKeyDown(Keys.LeftShift);
            bool ctrl = input.Keyboard_IsKeyDown(Keys.LeftControl);
            bool keyZ = input.Keyboard_WasKeyPressed(Keys.Z);
            bool keyY = input.Keyboard_WasKeyPressed(Keys.Y);
            if (ctrl)
            {
                if (keyY || keyZ && shift)  redo();
                else if (keyZ)              undo();
                if (input.Keyboard_WasKeyPressed(Keys.C))
                {
                    //copy, don't set :: moveMode = MoveMode.None;
                }
                if (input.Keyboard_WasKeyPressed(Keys.Delete))
                {
                    moveMode = MoveMode.None;
                }
                if (input.Keyboard_WasKeyPressed(Keys.V))
                {
                    //paste, don't set :: moveMode = MoveMode.None;
                }
            }

            if (moveMode == MoveMode.None)
                return;

            //if mouse buttons were released
            if (input.Mouse_WasButtonReleased(MouseButton.Left) &&
                !input.Mouse_IsButtonDown(MouseButton.Right) ||
                input.Mouse_WasButtonReleased(MouseButton.Right) &&
                !input.Mouse_IsButtonDown(MouseButton.Left))
            {
                finishStateChange(selected);
                return;
            }

            //Update the body's position
            switch (moveMode)
            {
                case MoveMode.CameraRelative:
                    hitDistance += input.MouseScroll * 0.02f;
                    selected.Position = input.MouseRay.Position -
                        moveOffset +
                        input.MouseRay.Direction * hitDistance;
                    break;
                case MoveMode.LineRelative: //The point on hitNormal closest to the mouseRay
                    //Guard against parallel or almost paralell lines.
                    if (Vector3.Dot(Vector3.Normalize(input.MouseRay.Direction),
                                    Vector3.Normalize(hitNormal.Direction)) > 0.99f)
                    {
                        break;
                    }
                    Vector3 between = input.MouseRay.Position - hitNormal.Position;
                    Vector3 normal = Vector3.Cross(input.MouseRay.Direction, hitNormal.Direction);
                    Vector3 R = Vector3.Divide(Vector3.Cross(between, normal), normal.LengthSquared());
                    Vector3 P = hitNormal.Position + hitNormal.Direction * Vector3.Dot(R, input.MouseRay.Direction);
                    selected.Position = P - moveOffset;
                    break;
                case MoveMode.PlaneRelative:
                    float? _mouseRayPlaneIntersectionDistance = input.MouseRay.Intersects(plane.Plane);
                    if (!_mouseRayPlaneIntersectionDistance.HasValue || _mouseRayPlaneIntersectionDistance.Value > 500)
                    {
                        _mouseRayPlaneIntersectionDistance = 500;
                    }
                    float mouseRayPlaneIntersectionDistance = (float)_mouseRayPlaneIntersectionDistance;
                    selected.Position = input.MouseRay.Position -
                        moveOffset +
                        input.MouseRay.Direction * mouseRayPlaneIntersectionDistance;
                    break;
            }
        }
Пример #17
0
 public void MoveTo(Vector3 position)
 {
     _mode           = MoveMode.GO_TO;
     _targetPosition = position;
 }
Пример #18
0
 public void SetPlayMode(MoveMode mode)
 {
     Play = mode;
 }
Пример #19
0
 public void Stop()
 {
     Character.Body.SetDesiredVelocity(Vector2.zero);
     _mode = MoveMode.NONE;
 }
Пример #20
0
        void Move(float distance, MoveMode mode)
        {
            Vector2    touch; // Controller touch position
            Quaternion rot;   // Controller rotation
            Vector3    dir;   // Move direction (unit vector i.e. dir.magnitude = 1)

            switch (mode)
            {
            case MoveMode.ControllerTrue:
                touch = GvrControllerInput.TouchPosCentered;
                rot   = GvrControllerInput.Orientation;
                dir   = rot * new Vector3(touch.x, 0, touch.y);
                cc.Move(dir * distance);
                break;

            case MoveMode.ControllerFBRL:
                touch = GvrControllerInput.TouchPosCentered;
                rot   = GvrControllerInput.Orientation;
                Dir touchDir = TouchToDir(touch);
                switch (touchDir)
                {
                case Dir.Right:
                    dir = rot * Vector3.right;
                    break;

                case Dir.Left:
                    dir = rot * Vector3.left;
                    break;

                case Dir.Up:
                    dir = rot * Vector3.forward;
                    break;

                case Dir.Down:
                    dir = rot * Vector3.back;
                    break;

                default:
                    dir = Vector3.zero;
                    break;
                }
                cc.Move(dir * distance);
                break;

            case MoveMode.ControllerFB:
                touch = GvrControllerInput.TouchPosCentered;
                rot   = GvrControllerInput.Orientation;
                if (touch.y > 0)
                {
                    dir = rot * Vector3.forward;
                }
                else
                {
                    dir = rot * Vector3.back;
                }
                cc.Move(dir * distance);
                break;

            case MoveMode.Camera:
                touch = GvrControllerInput.TouchPosCentered;
                if (touch.y > 0)
                {
                    dir = Camera.main.transform.TransformDirection(Vector3.forward);
                }
                else
                {
                    dir = Camera.main.transform.TransformDirection(Vector3.back);
                }
                cc.Move(dir * distance);
                break;

            case MoveMode.Points:
                int n     = movePoints.Count;
                int i     = currentMovePoint;
                int new_i = i + 1 < n ? i + 1 : 0;
                currentMovePoint = new_i;
                cc.gameObject.transform.position = movePoints[currentMovePoint];
                break;

            default:
                break;
            }
        }
Пример #21
0
 public bool MoveWithInnerADC(IAxis Axis, MoveMode Mode, int Speed, int Distance, int Interval, int Channel)
 {
     throw new NotImplementedException();
 }
Пример #22
0
 public void SetEndPosition(Transform End)
 {
     this.End      = End;
     this.moveMode = MoveMode.Move;
 }
Пример #23
0
 // Use this for initialization
 void Start()
 {
     mode = MoveMode.Rotate;
     if(!Settings.debug)
     {
         enabled = false;
     }
 }
Пример #24
0
 public void SetReturn()
 {
     this.moveMode = MoveMode.Return;
 }
Пример #25
0
        protected override bool MoveProcess(IAxis Axis, MoveMode Mode, int Speed, int Steps)
        {
            bool      ret  = false;
            IrixiAxis axis = Axis as IrixiAxis;

            int target_pos = 0;

            if (axis.IsHomed == false)
            {
                axis.LastError = "the axis is not homed";
                return(false);
            }

            if (axis.Lock())
            {
                try
                {
                    // Set the move speed
                    if (Mode == MoveMode.ABS)
                    {
                        target_pos = Math.Abs(Steps);
                    }
                    else
                    {
                        target_pos = axis.AbsPosition + Steps;
                    }

                    // Move the the target position
                    if (axis.CheckSoftLimitation(target_pos))
                    {
                        ret = _controller.Move(axis.OnBoardCH, Speed, target_pos, IrixiStepperControllerHelper.MoveMode.ABS);

                        if (!ret)
                        {
                            if (_controller.LastError.EndsWith("31"))
                            {
                                // ignore the error 31 which indicates that uesr interrupted the movement
                                ret = true;
                            }
                            else
                            {
                                axis.LastError = string.Format("sdk reported error code {0}", _controller.LastError);
                                ret            = false;
                            }
                        }
                    }
                    else
                    {
                        axis.LastError = "target position exceeds the limitation.";

                        ret = false;
                    }
                }
                catch (Exception ex)
                {
                    axis.LastError = ex.Message;
                    ret            = false;
                }

                finally
                {
                    // release the axis
                    //_axis.Unlock();
                }
            }
            else
            {
                axis.LastError = "the axis is locked.";
                ret            = false;
            }

            return(ret);
        }
Пример #26
0
 public void MoveStateSet()
 {
     MoveState = MoveMode.Follow;
 }
 public static T SetMoveMode <T>(this T entity, MoveMode value)
     where T : FeatureDefinitionMoveMode
 {
     entity.SetField("moveMode", value);
     return(entity);
 }
Пример #28
0
 /// <summary>
 /// 減速を行うか否かの既定値を取得する。
 /// </summary>
 /// <param name="moveMode">移動モード。</param>
 /// <returns>既定で減速を行うならば true 。そうでなければ false 。</returns>
 public static bool IsDefaultDecelerating(this MoveMode moveMode) =>
 moveMode == MoveMode.Acceleration;
Пример #29
0
        public Vector2 GetAllowedMovement(Vector2 wantsToMoveAmount, Vector2 deltaPosition = default, MoveMode mode = MoveMode.HorizontalFirst)
        {
            Vector2 movedAmount = Vector2.zero;

            foreach (MoveUnit moveUnit in mode.GetMoveUnits(wantsToMoveAmount))
            {
                movedAmount[moveUnit.axis] = moveUnit.dir * GetAllowedMovementAt(moveUnit.distance, moveUnit.dir, deltaPosition);
            }
            return(movedAmount);
        }
Пример #30
0
 /// <summary>
 /// 移動フレーム間隔の既定値を取得する。
 /// </summary>
 /// <param name="moveMode">移動モード。</param>
 /// <returns>移動フレーム間隔の既定値。</returns>
 public static int GetDefaultInterval(this MoveMode moveMode) =>
 (moveMode == MoveMode.Rotation) ? 100 : 0;
Пример #31
0
        /// <summary>
        /// 移動モードの文字列表現値のパースを試みる。
        /// </summary>
        /// <param name="value">文字列表現値。</param>
        /// <param name="moveMode">移動モードの設定先。</param>
        /// <param name="accelerating">加速を行うか否かの設定先。</param>
        /// <param name="decelerating">減速を行うか否かの設定先。</param>
        /// <returns>パースに成功したならば true 。そうでなければ false 。</returns>
        private static bool TryParseMoveMode(
            string value,
            out MoveMode moveMode,
            out bool accelerating,
            out bool decelerating)
        {
            Debug.Assert(value != null);

            moveMode     = MoveMode.None;
            accelerating = false;
            decelerating = false;

            var idStr       = value;
            var extra       = "";
            var nonDigitPos =
                value
                .Select((c, index) => new { c, index })
                .Skip(1)
                .FirstOrDefault(v => !char.IsDigit(v.c))?
                .index;

            if (nonDigitPos.HasValue)
            {
                idStr = value.Substring(0, nonDigitPos.Value);
                extra = value.Substring(nonDigitPos.Value);
            }

            if (!int.TryParse(idStr, out int id))
            {
                return(false);
            }

            if (id >= 64)
            {
                accelerating = true;
                id          -= 64;
            }
            if (id >= 32)
            {
                decelerating = true;
                id          -= 32;
            }

            if (id == MoveMode.None.GetId())
            {
                // None を文字列表現することはできない
                return(false);
            }

            var foundType =
                (Enum.GetValues(typeof(MoveMode)) as MoveMode[])
                .Cast <MoveMode?>()
                .FirstOrDefault(t => t?.GetId() == id && t?.GetExtraId() == extra);

            if (!foundType.HasValue)
            {
                return(false);
            }
            moveMode = foundType.Value;

            return(true);
        }
    }//E N D  M E T H O D Update

    #endregion

    #region <------ H E L P E R  M E T H O D S  ------>
    private MoveMode moveModeFromInput(Vector2 input)
    {
        MoveMode returnMode = MoveMode.normal;

        if (Input.GetButton(Sprint))
        {
            if (actions.blocking && Time.time > lastDodgePress + dodgeCooldown && currentMoveMode == MoveMode.guard &&
                Time.time > lastSprintPress + sprintCooldown && Mathf.Abs(inputDirection.x) + Mathf.Abs(inputDirection.y) / 2 > 0.5)
            {
                returnMode     = MoveMode.dodge;
                lastDodgePress = Time.time;
            }
            else if (Mathf.Abs(inputDirection.x) + Mathf.Abs(inputDirection.y) / 2 < 0.5 && Time.time > lastDodgePress &&
                     currentMoveMode == MoveMode.guard)
            {
                returnMode     = MoveMode.normal;
                lastActionTime = 0;
                lastDodgePress = Time.time;
            }
            else if (actions.ActionInProgress)
            {
                returnMode = MoveMode.slowdown;
            }
            else if (!actions.blocking)
            {
                returnMode      = MoveMode.sprint;
                lastSprintPress = Time.time;
            }
            else
            {
                returnMode = MoveMode.guard;
            }                                      //if you're pressing sprint and blocking at the same time, you're just waiting to do the next dodge.
        }
        else if (lastSprintPress != 0 && Time.time < lastSprintPress + sprintCooldown && (currentVelocity.magnitude > sprintSpeed / 2))
        {
            returnMode = MoveMode.slowdown;
        }
        else if (lastActionTime != 0 && (Time.time < lastActionTime + timeToStopGuard))
        {
            returnMode = MoveMode.guard;
        }
        if (currentMoveMode == MoveMode.sprint || currentMoveMode == MoveMode.slide)
        {
            if (Mathf.Abs(input.y - (currentVelocity.z) / sprintSpeed) > slideThreshold ||
                Mathf.Abs(input.x - (currentVelocity.x) / sprintSpeed) > slideThreshold)
            {
                returnMode = MoveMode.slide;
            }
        }
        if (currentMoveMode == MoveMode.dodge && Time.time < lastDodgePress + dodgeLength)
        {
            returnMode = MoveMode.dodge;
        }
        else
        {
            dodgeVector = Vector3.zero;
        }
        if (currentMoveMode == MoveMode.stagger && Time.time < staggerTime + staggerLength)
        {
            returnMode = MoveMode.stagger;
        }
        Debug.Log(returnMode + this.name);
        return(returnMode);
    }//E N D  M E T H O D MoveModeFromInput
 private static extern void FCE_ObjectSelection_MoveTo(IntPtr ptr, float x, float y, float z, MoveMode mode);
Пример #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestMove"/> class.
 /// </summary>
 /// <param name="path">Path to the node</param>
 /// <param name="context">Context associated with the request</param>
 /// <param name="version">Expected version of the node</param>
 /// <param name="pathDst">Path to the node tha twill become the new parent of the moved node</param>
 /// <param name="callback">Callback to invoke when the request is completed</param>
 /// <param name="movemode">Specifies how the node must be moved</param>
 /// <param name="uid">Unique id to assign to the request</param>
 public RequestMove(string path, object context, int version, string pathDst, StringCallbackDelegate callback, MoveMode movemode = MoveMode.None, ulong uid = 0)
     : this(new RequestDefinitions.RequestMove(path, version, pathDst, movemode, MakeUid(uid)), context, callback)
 {
 }
Пример #35
0
 public void Follow(Transform transform, float distance)
 {
     _mode            = MoveMode.FOLLOW;
     _targetTransform = transform;
     _targetDistance  = distance;
 }
Пример #36
0
 void Update()
 {
     AnimRefresh(animator, move, action, speed);
     action = GetActionMode(action, action);
     move   = GetMoveMode(speed, action);
 }
Пример #37
0
 public void Flee(Transform transform)
 {
     _mode            = MoveMode.FLEE;
     _targetTransform = transform;
 }
Пример #38
0
 public Rocket(string vendorID, string productID, MoveMode moveMode = MoveMode.Continuous)
 {
     _vendorId = vendorID;
     _moveMode = moveMode;
     _device   = new USBInterface(_vendorId, productID);
 }
Пример #39
0
        private short PlaySomeOpponentManyTimes(MoveMode mode, short gameCount)
        {
            short wins = 0;
            var results = new List<GameResults>();

            Parallel.For(0, gameCount, i =>
                {
                    Player you = new Player("Test", new MyBot());
                    var accessor = new MyBot_Accessor();
                    accessor.Mode = mode;
                    Player opponent = new Player("Opponent", accessor);

                    Game game = new Game(GameRules.Default);
                    GameResults result = game.Play(you, opponent);

                    if (result.Winner.TeamName.Equals("Test")) wins++;
                    results.Add(result);
                });

            VerifyResults(results, String.Format("against {0}", mode));
            return wins;
        }
Пример #40
0
 public void Go(float x, float y, float z, float r = 0.0F, MoveMode mode = MoveMode.MODE_PTP_MOVJ_ANGLE)
 {
     SetPtpCmd(x, y, z, r, mode);
 }
Пример #41
0
 /// <summary>
 /// Customized process to move
 /// </summary>
 /// <param name="Axis">The axis to move</param>
 /// <param name="Mode">Rel/Abs</param>
 /// <param name="Speed">0 ~ 100 in percent</param>
 /// <param name="Distance">The distance to move in steps</param>
 /// <returns></returns>
 protected virtual bool MoveProcess(IAxis Axis, MoveMode Mode, int Speed, int Distance)
 {
     throw new NotImplementedException();
 }
Пример #42
0
 protected void Halt()
 {
     _moveMode = MoveMode.False;
 }
Пример #43
0
    void Movement()
    {
        //Handle the various modifiers.
        if(Input.GetKey(KeyCode.LeftShift))
        {
            mode = MoveMode.XY;
        }
        else if(Input.GetKey(KeyCode.LeftControl))
        {
            mode = MoveMode.XZ;
        }
        else if(Input.GetKey(KeyCode.R))
        {
            mode = MoveMode.Roll;
        }
        else
        {
            mode = MoveMode.Rotate;
            Vector3 angle = transform.eulerAngles;
            angle.z = 0f;
            transform.eulerAngles = angle;
        }

        //Handle the various modes.
        if(mode == MoveMode.Rotate)
        {
            //transform.Rotate(new Vector3(0f,Input.GetAxis("Mouse X"),0f));
            transform.Rotate(new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"),0f));
        }
        else if(mode == MoveMode.Roll)
        {
            transform.Rotate(new Vector3(0f, 0f, -Input.GetAxis("Mouse X")));
        }
        else if(mode == MoveMode.XY)
        {
            transform.Translate (new Vector3(Input.GetAxis("Mouse X")*0.25f,0f,0f));
            transform.Translate (new Vector3(0f,Input.GetAxis("Mouse Y")*0.25f,0f));
        }
        else if(mode == MoveMode.XZ)
        {
            transform.Translate (new Vector3(Input.GetAxis("Mouse X")*0.25f,0f,0f));
            transform.Translate (new Vector3(0f,0f,Input.GetAxis("Mouse Y")*0.25f));
        }

        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - Input.GetAxis("Mouse ScrollWheel"));

        //This is just to keep the wand's z angle component from changing (used to stabilize its rotation)
        /*Vector3 angle = transform.eulerAngles;
        angle.z = 0f;
        transform.eulerAngles = angle;*/
    }
Пример #44
0
    private void UnSnap(float angle, MoveMode newMode)
    {
        var tolerance = 1.5f;
        var distance = 0f;
        var maxDistance = 0.21f;

        var shiftMovement = new Vector2(State.SlopeShiftMovement.x, State.SlopeShiftMovement.y);
        if (shiftMovement != Vector2.zero)
        {
            tempJumpShift = Vector2.Lerp(tempJumpShift, shiftMovement, Time.deltaTime * Parameters.SpeedAccelerationInAir * 2);
            distance = shiftMovement.magnitude;
            if (distance < maxDistance)
            {
                shiftMovement = Vector2.zero;
                tempJumpShift = Vector2.zero;
            }
            else
            {
                //Debug.Log(tempJumpShift.y);
                //Debug.Log(distance);
                shiftMovement -= tempJumpShift;
                _transform.Translate(tempJumpShift, Space.World);
            }

            State.SlopeShiftMovement = new Vector3(shiftMovement.x, shiftMovement.y, 0);
        }

        if (distance < tolerance)
        {
            if (!isRotationEnds)
            {
                var _rotationTime = Mathf.Clamp(Mathf.Abs(angle) / 270.0f, 0.1f, 0.3f);
                RotateWhileSnapping(angle, true, _rotationTime);
            }
        }

        if (isRotationEnds && State.SlopeShiftMovement == Vector3.zero)
        {
            State.MovingMode = newMode;
            transform.eulerAngles = new Vector3(0, 0, 0);
            isRotationEnds = false;
        }
    }
Пример #45
0
 // Use this for initialization
 void Start()
 {
     NowMoveMode = MoveMode.ToCamera;
     Anima       = GetComponent <Animator>();
 }
Пример #46
0
    private void Snap(float angle, MoveMode newMode)
    {
        if (State.SlopeShiftMovement == Vector3.zero && isRotationEnds)
        {
            isRotationEnds = false;
            State.MovingMode = newMode;
            return;

        }

        ShiftWhileSnapping ();
        if (!isRotationEnds)
        {
            var _rotationTime = Mathf.Clamp(Mathf.Abs(angle)/180.0f, 0.1f, 0.2f);
            RotateWhileSnapping (angle, _rotationTime);
        }
    }
Пример #47
0
        /// <summary>
        /// Update move type
        /// </summary>
        /// <param name="moveType">new move type</param>
        public void updateMoveType(byte moveType)
        {
            predictionTime = DateTime.Now;

            /*
             * NV: Would be nice to have all other possible values filled out for this at some point... *Looks at Suiv*
             * More specifically, 10, 13 and 22 - 10 and 13 seem to be tied to spinning with mouse. 22 seems random (ping mabe?)
             * Also TODO: Tie this with CurrentMovementMode stat and persistance (ie, log off walking, log back on and still walking)
             * Values of CurrentMovementMode and their effects:
                0: slow moving feet not animating
                1: rooted cant sit
                2: walk
                3: run
                4: swim
                5: crawl
                6: sneak
                7: flying
                8: sitting
                9: rooted can sit
                10: same as 0
                11: sleeping
                12: lounging
                13: same as 0
                14: same as 0
                15: same as 0
                16: same as 0
             */
            switch (moveType)
            {
                case 1: // Forward Start
                    moveDirection = MoveDirection.Forwards;
                    break;
                case 2: // Forward Stop
                    moveDirection = MoveDirection.None;
                    break;

                case 3: // Reverse Start
                    moveDirection = MoveDirection.Backwards;
                    break;
                case 4: // Reverse Stop
                    moveDirection = MoveDirection.None;
                    break;

                case 5: // Strafe Right Start
                    strafeDirection = SpinOrStrafeDirection.Right;
                    break;
                case 6: // Strafe Stop (Right)
                    strafeDirection = SpinOrStrafeDirection.None;
                    break;

                case 7: // Strafe Left Start
                    strafeDirection = SpinOrStrafeDirection.Left;
                    break;
                case 8: // Strafe Stop (Left)
                    strafeDirection = SpinOrStrafeDirection.None;
                    break;

                case 9: // Turn Right Start
                    spinDirection = SpinOrStrafeDirection.Right;
                    break;
                case 10: // Mouse Turn Right Start
                    break;
                case 11: // Turn Stop (Right)
                    spinDirection = SpinOrStrafeDirection.None;
                    break;

                case 12: // Turn Left Start
                    spinDirection = SpinOrStrafeDirection.Left;
                    break;
                case 13: // Mouse Turn Left Start
                    break;
                case 14: // Turn Stop (Left)
                    spinDirection = SpinOrStrafeDirection.None;
                    break;

                case 15: // Jump Start
                    // NV: TODO: This!
                    break;
                case 16: // Jump Stop
                    break;

                case 17: // Elevate Up Start
                    break;
                case 18: // Elevate Up Stop
                    break;

                case 19: // ? 19 = 20 = 22 = 31 = 32
                    break;
                case 20: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 21: // Full Stop
                    break;

                case 22: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 23: // Switch To Frozen Mode
                    break;
                case 24: // Switch To Walk Mode
                    moveMode = MoveMode.Walk;
                    break;
                case 25: // Switch To Run Mode
                    moveMode = MoveMode.Run;
                    break;
                case 26: // Switch To Swim Mode
                    break;
                case 27: // Switch To Crawl Mode
                    prevMoveMode = moveMode;
                    moveMode = MoveMode.Crawl;
                    break;
                case 28: // Switch To Sneak Mode
                    prevMoveMode = moveMode;
                    moveMode = MoveMode.Sneak;
                    break;
                case 29: // Switch To Fly Mode
                    break;
                case 30: // Switch To Sit Ground Mode
                    prevMoveMode = moveMode;
                    moveMode = MoveMode.Sit;
                    Stats.NanoDelta.CalcTrickle();
                    Stats.HealDelta.CalcTrickle();
                    Stats.NanoInterval.CalcTrickle();
                    Stats.HealInterval.CalcTrickle();
                    break;

                case 31: // ? 19 = 20 = 22 = 31 = 32
                    break;
                case 32: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 33: // Switch To Sleep Mode
                    moveMode = MoveMode.Sleep;
                    break;
                case 34: // Switch To Lounge Mode
                    moveMode = MoveMode.Lounge;
                    break;

                case 35: // Leave Swim Mode
                    break;
                case 36: // Leave Sneak Mode
                    moveMode = prevMoveMode;
                    break;
                case 37: // Leave Sit Mode
                    moveMode = prevMoveMode;
                    Stats.NanoDelta.CalcTrickle();
                    Stats.HealDelta.CalcTrickle();
                    Stats.NanoInterval.CalcTrickle();
                    Stats.HealInterval.CalcTrickle();
                    break;
                case 38: // Leave Frozen Mode
                    break;
                case 39: // Leave Fly Mode
                    break;
                case 40: // Leave Crawl Mode
                    moveMode = prevMoveMode;
                    break;
                case 41: // Leave Sleep Mode
                    break;
                case 42: // Leave Lounge Mode
                    break;
                default:
                    //Console.WriteLine("Unknown MoveType: " + moveType);
                    break;
            }

            //Console.WriteLine((moveDirection != 0 ? moveMode.ToString() : "Stand") + "ing in the direction " + moveDirection.ToString() + (spinDirection != 0 ? " while spinning " + spinDirection.ToString() : "") + (strafeDirection != 0 ? " and strafing " + strafeDirection.ToString() : ""));
        }
Пример #48
0
 public Rocket(string vendorID, string productID, MoveMode moveMode = MoveMode.Continuous)
 {
     _vendorId = vendorID;
     _moveMode = moveMode;
     _device = new USBInterface(_vendorId, productID);
 }