//обработка движения
 protected override void ProcessHandling(MovementSystem movementSystem)
 {
     movementSystem.LongitudinalMovement(Time.deltaTime);                            //по оси Y
     // по оси X
     if (_isMovingRight)                                                             // вправо
     {
         if ((transform.position - _initialPosition).x < _horizontalMovementRange.y) // проверка на достижение левой границы
         {
             movementSystem.LateralMovement(Time.deltaTime * Vector3.left.x);
         }
         else
         {
             _isMovingRight = false;
         }
     }
     else //влево
     {
         if ((transform.position - _initialPosition).x > _horizontalMovementRange.x) // проверка на достижение правой границы
         {
             movementSystem.LateralMovement(Time.deltaTime * Vector3.right.x);
         }
         else
         {
             _isMovingRight = true;
         }
     }
 }
 protected override void ProcessHandling(MovementSystem movementSystem)
 {
     if (mouseControl == false)
     {
         movementSystem.LateralMovement(Input.GetAxis("Horizontal") * Time.deltaTime);
     }
     else
     {
         movementSystem.LateralMovement(Input.GetAxis("Mouse X") * Time.deltaTime);
     }
 }
Beispiel #3
0
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
#if UNITY_EDITOR
            movementSystem.LateralMovement(Input.GetAxis("Horizontal") * Time.deltaTime);
            movementSystem.LongitudinalMovement(Input.GetAxis("Vertical") * Time.deltaTime);
#endif
            movementSystem.LateralMovement(Joystick.Horizontal / 5f * Time.deltaTime);
            movementSystem.LongitudinalMovement(Joystick.Vertical / 5f * Time.deltaTime);
            //bounds
            var pos = Camera.main.WorldToViewportPoint(transform.position);
            pos.x = Mathf.Clamp(pos.x, _minXBound, _maxXBound);
            pos.y = Mathf.Clamp(pos.y, _minYBound, _maxYBound);
            transform.position = Camera.main.ViewportToWorldPoint(pos);
        }
Beispiel #4
0
    protected override void ProcessHandling(MovementSystem movementSystem)
    {
        movementSystem.LongitudinalMovement(Time.deltaTime);

        // Меняем направление движения противника.

        if (MoveRight)
        {
            movementSystem.LateralMovement(Time.deltaTime);
        }
        if (MoveLeft)
        {
            movementSystem.LateralMovement(Time.deltaTime * -1);
        }
    }
Beispiel #5
0
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            Vector3 transformPosition = transform.position;
            float   positionX         = 0;

            if (_rightBound > transformPosition.x && !_rightScreenBoundFlag)
            {
                positionX = Time.deltaTime * -1;
                float bound = _rightBound - 2;

                if (bound < transformPosition.x)
                {
                    _rightScreenBoundFlag = true;
                }
            }
            else if (_leftBound < transformPosition.x && _rightScreenBoundFlag)
            {
                positionX = Time.deltaTime;
                float bound = _leftBound + 2;

                if (bound > transformPosition.x)
                {
                    _rightScreenBoundFlag = false;
                }
            }

            if (GameAreaHelper.RestrictLateralMovement(ref transformPosition, positionX, _bounds, _camera))
            {
                movementSystem.LateralMovement(positionX);
            }
            else
            {
                transform.position = transformPosition;
            }
        }
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            Vector3 transformPosition = transform.position;
            float   positionX         = 0;

            if (_playerPositionX < transformPosition.x)
            {
                positionX = Time.deltaTime;
            }
            else
            {
                positionX = Time.deltaTime * -1;
            }

            if (GameAreaHelper.RestrictLateralMovement(ref transformPosition, positionX, _representation.bounds, Camera.main))
            {
                movementSystem.LateralMovement(positionX);
            }
            else
            {
                transform.position = transformPosition;
            }

            if (!_find)
            {
                return;
            }

            StartCoroutine(FindPlayerPosition());
        }
Beispiel #7
0
        //добавление движения корабля по синусоиде влево-вправо
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            base.ProcessHandling(movementSystem);
            float lateralMove = Mathf.Sin(Time.time);

            movementSystem.LateralMovement(lateralMove * 0.001f * _rangeOfMotion);
        }
Beispiel #8
0
 protected override void ProcessHandling(MovementSystem movementSystem)
 {
     movementSystem.LongitudinalMovement(Time.deltaTime);
     if (newTimer != 0)
     {
         HorizontalMove();
         movementSystem.LateralMovement(direction * Time.deltaTime / 5);
     }
 }
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            var direction = Input.GetAxis("Horizontal");

            if (GameAreaHelper.IsPlayerAllowedToMove(transform, _sprite.bounds, direction)) // проверка на возможность двигаться по оси X
            {
                movementSystem.LateralMovement(direction * Time.deltaTime);
            }
        }
        protected override void ProcessMove(MovementSystem movementSystem)
        {
            var delta = Input.GetAxis("Horizontal");

            Time.timeScale = delta == 0 ?
                             0.3f :
                             Mathf.Lerp(Time.timeScale, 1, 0.5f);

            movementSystem.LateralMovement(delta * Time.deltaTime);
        }
        //вызываем каждый раз в Update, если нажаты Left/Right arrow или A/D - двигаем корабль
        //если корабль достигает края экрана, то движение за экран не производим
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            float movement = Input.GetAxis("Horizontal");

            if (GameAreaHelper
                .IsAvailableForLateralMovement(this.transform, _representation.bounds, movement))
            {
                movementSystem.LateralMovement(movement * Time.deltaTime);
            }
        }
Beispiel #12
0
    protected override void ProcessHandling(MovementSystem movementSystem)
    {
        switch (_movementBehaviour)
        {
        case MovementBehaviour.Linear:
            movementSystem.LongitudinalMovement(Time.deltaTime);
            break;

        case MovementBehaviour.Sinusoid:
            movementSystem.LongitudinalMovement(Time.deltaTime);
            movementSystem.LateralMovement((float)Mathf.Sin(transform.position.y));
            break;

        case MovementBehaviour.Random:
            movementSystem.LongitudinalMovement(Time.deltaTime);
            movementSystem.LateralMovement(Random.Range(-1, 2) * Time.deltaTime);
            break;
        }
    }
        //Кастомное движение объекта
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            if (!GameAreaHelper.IsAllObjectInGameplayArea(gameObject.transform, _collider2D.bounds))
            {
                _isShipTouchedBorder = !_isShipTouchedBorder;
            }

            movementSystem.LongitudinalMovement(Time.deltaTime);
            movementSystem.LateralMovement(Time.deltaTime, _isShipTouchedBorder);
        }
Beispiel #14
0
        //обработка горизонтального движения
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            Vector3 oldPosition = gameObject.transform.position;

            movementSystem.LateralMovement(Input.GetAxis("Horizontal") * Time.deltaTime * _playerSpaceship.CurrentSpeed);

            if (!GameAreaHelper.IsAllObjectInGameplayArea(transform, _objectCollider.bounds))
            {
                gameObject.transform.position = oldPosition;
            }
        }
        private bool _canMoveLeft  = true;      // может ли корабль игрока двигаться влево

        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            float direction = Input.GetAxis("Horizontal");

            if (TryMoveTo(direction))   // выйти из метода, если движение пользователя в заданном направлении не разрешено
            {
                return;
            }

            movementSystem.LateralMovement(direction * Time.deltaTime);
        }
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            movementSystem.LateralMovement(Input.GetAxis("Horizontal") * Time.deltaTime);

            if (transform.position.x < movementSystem.limitLeft) // ограничение движения player left
            {
                transform.position = new Vector3(movementSystem.limitLeft, transform.position.y, transform.position.z);
            }
            if (transform.position.x > movementSystem.limitRight) // ограничение движения player right
            {
                transform.position = new Vector3(movementSystem.limitRight, transform.position.y, transform.position.z);
            }
        }
    private void ProcessLateralMovement(MovementSystem movementSystem)
    {
        float direction = 1f;                   // направление бокового движения (по умолчанию вправо)

        if (_elapsedTimeLaterialMovement < 0)   // изменение направления движения корабля (влево)
        {
            direction = -1f;
        }

        movementSystem.LateralMovement(direction * Time.deltaTime * 0.1f);

        _elapsedTimeLaterialMovement -= Time.deltaTime;                 // отсчёт прошедшего времени бокового движения
        if (_elapsedTimeLaterialMovement < -_periodLaterialMovement)    // если мы вышли за рамки периода,
        {
            _elapsedTimeLaterialMovement = _periodLaterialMovement;     // снова устанавливаем "секундомер" на заданный период
        }
    }
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            var move = new Vector3(inputStrategy.GetHorizontalMove(Camera.main.WorldToScreenPoint(transform.position).x) * Time.deltaTime, 0, 0);

            if (GameAreaHelper.IsInGameplayAreaFull(transform, _representation.bounds))
            {
                lastPosition = transform.position;
                movementSystem.LateralMovement(move.x);
            }
            else
            {
                transform.position = lastPosition;
            }

            if (inputStrategy.IsStrategySwitchedPressed(out InputStrategy newStrategy))
            {
                inputStrategy = newStrategy;
            }
        }
Beispiel #19
0
        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            if (_userControl == null)
            {
                return;
            }

            float   positionX         = _userControl.X * Time.deltaTime;
            Vector3 transformPosition = transform.position;

            if (GameAreaHelper.RestrictLateralMovement(ref transformPosition, positionX, _representation.bounds, Camera.main))
            {
                movementSystem.LateralMovement(positionX);
            }
            else
            {
                transform.position = transformPosition;
            }
        }
Beispiel #20
0
 // Passes player input to movement system
 protected override void ProcessHandling(MovementSystem movementSystem)
 {
     movementSystem.LateralMovement(Input.GetAxis(_horizontalMovement) * Time.deltaTime);
 }
 // Both longitudinal and lateral movements
 protected override void ProcessHandling(MovementSystem movementSystem)
 {
     movementSystem.LongitudinalMovement(Time.deltaTime);
     movementSystem.LateralMovement(Time.deltaTime * _evasionDirection);
 }
        bool rocketReadyToFire = true;          //Готовность ракет

        protected override void ProcessHandling(MovementSystem movementSystem)
        {
            movementSystem.LateralMovement(Input.GetAxis("Mouse X") * Time.deltaTime);
            movementSystem.LongitudinalMovement(Input.GetAxis("Mouse Y") * Time.deltaTime);
        }