Ejemplo n.º 1
0
        public bool Home(IAxis Axis)
        {
            bool ret = false;

            if (!this.IsEnabled) // the controller is configured to be disabled in the config file
            {
                Axis.LastError = "the controller is disabled";
            }
            else if (!this.IsInitialized)   // the controller is not initialized
            {
                Axis.LastError = "the controller is not initialized";
            }
            else if (!Axis.IsEnabled)   // the axis moved is disabled in the config file
            {
                Axis.LastError = "the axis is disabled";
            }
            else
            {
                if (BusyAxesCount <= 0)
                {
                    OnMoveBegin?.Invoke(this, new EventArgs());
                }

                IncreaceBusyAxesCount();
                ret = HomeProcess(Axis);
                DecreaceBusyAxesCount();

                if (BusyAxesCount <= 0)
                {
                    OnMoveEnd?.Invoke(this, new EventArgs());
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
 public async void NotifyMoveEnd(Event e)
 {
     try
     {
         await UpdateBounds();
     }
     catch (Exception ex)
     {
         NotifyBackgroundExceptionOccurred(ex);
     }
     finally
     {
         OnMoveEnd?.Invoke(this, e);
     }
 }
Ejemplo n.º 3
0
        private void Update()
        {
            if (!_isMoving)
            {
                return;
            }

            if (Input.GetMouseButton(1))
            {
                OnMove?.Invoke(this, (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition) - _initialPosition);
            }
            else
            {
                _isMoving = false;
                OnMoveEnd?.Invoke(this, Camera.main.ScreenToWorldPoint(Input.mousePosition));
            }
        }
Ejemplo n.º 4
0
    private IEnumerator JoystickUpdate()
    {
        while (enabled)
        {
            yield return(new WaitUntil(() => Input.GetMouseButtonDown(0)));

            OnMoveBegin?.Invoke();

            var startPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            startPos.z = 0;

            while (Input.GetMouseButton(0))
            {
                var endPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                endPos.z = 0;

                var direction = endPos - startPos;
                direction = Vector3.ClampMagnitude(direction * sensitivity, maxSpeed);

                var temp = transform.position + (direction * Time.deltaTime);

                if (temp.x < MAX_WIDTH || temp.x > MIN_WIDTH)
                {
                    direction.x = 0;
                }
                if (temp.y < MAX_HEIGHT || temp.y > MIN_HEIGHT)
                {
                    direction.y = 0;
                }

                transform.up = direction;

                transform.position += direction * Time.deltaTime;

                OnMove?.Invoke(transform.position + direction);

                yield return(new WaitForFixedUpdate());
            }

            OnMoveEnd?.Invoke();
        }
    }
Ejemplo n.º 5
0
        protected IEnumerator SmoothMovement(Vector3 end)
        {
            IsMoving = true;
            {
                float sqrRemainingDistance = (transform.position - end).sqrMagnitude;
                while (sqrRemainingDistance > Mathf.Epsilon)
                {
                    Vector3 newPostion = Vector3.MoveTowards(_rb2D.position, end,
                                                             _inverseMoveTime * _unityService.GetDeltaTime());

                    _rb2D.MovePosition(newPostion);
                    sqrRemainingDistance = (transform.position - end).sqrMagnitude;
                    yield return(null);
                }

                _rb2D.MovePosition(end);
            }
            IsMoving = false;
            OnMoveEnd?.Invoke(this, null);
        }
Ejemplo n.º 6
0
        public bool Move(IAxis Axis, MoveMode Mode, int Speed, int Distance)
        {
            bool ret = false;

            if (!this.IsEnabled)
            {
                Axis.LastError = "the controller is disabled";
            }
            if (!this.IsInitialized)
            {
                Axis.LastError = "the controller is not initialized";
            }
            else if (!Axis.IsEnabled)
            {
                Axis.LastError = "the axis is disabled";
            }
            else if (!Axis.IsHomed)
            {
                Axis.LastError = "the axis is not homed";
            }
            else
            {
                if (BusyAxesCount <= 0)
                {
                    OnMoveBegin?.Invoke(this, new EventArgs());
                }

                IncreaceBusyAxesCount();

                ret = MoveProcess(Axis, Mode, Speed, Distance);

                DecreaceBusyAxesCount();

                if (BusyAxesCount <= 0)
                {
                    OnMoveEnd?.Invoke(this, new EventArgs());
                }
            }

            return(ret);
        }
Ejemplo n.º 7
0
 public void NotifyMoveEnd(Event eventArgs)
 {
     OnMoveEnd?.Invoke(this, eventArgs);
 }
Ejemplo n.º 8
0
 private void ForceMoveEndEvent()
 {
     OnMoveEnd?.Invoke(new OnMoveEndEventArgs(currentPlayer, isFirstStage, players));
 }
Ejemplo n.º 9
0
 public void NotifyMoveEnd(Event e) => OnMoveEnd?.Invoke(this, e);