Пример #1
0
        private void HandleMovement(Orientation orientation)
        {
            Vector3Int targetDirection = new Vector3Int();

            switch (orientation)
            {
            case Orientation.Forward:
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    targetDirection = Vector3Int.right;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    targetDirection = Vector3Int.left;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    targetDirection = targetDirection.Forward();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    targetDirection = targetDirection.Back();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                break;

            case Orientation.Right:
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    targetDirection = targetDirection.Back();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    targetDirection = targetDirection.Forward();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    targetDirection = Vector3Int.right;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    targetDirection = Vector3Int.left;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                break;

            case Orientation.Back:
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    targetDirection = Vector3Int.left;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    targetDirection = Vector3Int.right;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    targetDirection = targetDirection.Back();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    targetDirection = targetDirection.Forward();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                break;

            case Orientation.Left:
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    targetDirection = targetDirection.Forward();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    targetDirection = targetDirection.Back();
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    targetDirection = Vector3Int.left;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    targetDirection = Vector3Int.right;
                    if (!IsInBounds(targetDirection))
                    {
                        return;
                    }
                }

                break;
            }

            activePiece.transform.DOBlendableMoveBy(targetDirection, 0.1f);
            piecePosition += targetDirection;
        }