Exemplo n.º 1
0
        private IEnumerator MoveBackward()
        {
            //проверка на падение
            if (BoardModel.CheckForEmpty(_transform.position + Vector3.down))
            {
                yield return(StartCoroutine(MakeStepDown()));
            }

            //проверка на прыжок
            else if (BoardModel.CheckForEmpty(_transform.position + Vector3.left) &&
                     BoardModel.CheckForEmptyOrPlatform(_transform.position + 2 * Vector3.left) &&
                     BoardModel.CheckForEmpty(_transform.position + new Vector3(-1, -1, 0)))
            {
                yield return(StartCoroutine(MakeLeftJump()));
            }

            //проверка на шаг влево
            else if (BoardModel.CheckForEmptyOrPlatform(_transform.position + Vector3.left))
            {
                yield return(StartCoroutine(MakeStepLeft()));
            }

            else if (BoardModel.CheckForPlatform(_transform.position))
            {
                _robot.OnReturnAction();
            }

            else
            {
                _robot.OnStoppageAction();
            }
        }
Exemplo n.º 2
0
        private IEnumerator MoveForward()
        {
            //проверка на падение
            if (BoardModel.CheckForEmpty(_transform.position + Vector3.down))
            {
                yield return(StartCoroutine(MakeStepDown()));
            }

            //проверка на прыжок
            else if (BoardModel.CheckForEmpty(_transform.position + Vector3.right) &&
                     BoardModel.CheckForEmptyOrPlatform(_transform.position + 2 * Vector3.right) &&
                     BoardModel.CheckForEmpty(_transform.position + new Vector3(1, -1, 0)))
            {
                yield return(StartCoroutine(MakeRightJump()));
            }

            //проверка на шаг вправо
            else if (BoardModel.CheckForEmptyOrPlatform(_transform.position + Vector3.right))
            {
                yield return(StartCoroutine(MakeStepRight()));
            }

            else
            {
                _robot.ForwardFlag = false;
            }
        }
Exemplo n.º 3
0
        private IEnumerable <Vector3> CalculatePath(Vector3 point)
        {
            yield return(point);

            while (true)
            {
                //проверка на падение
                if (BoardModel.CheckForEmpty(point + Vector3.down))
                {
                    point += Vector3.down;
                }

                //проверка на шаг вправо
                else if (BoardModel.CheckForEmptyOrPlatform(point + Vector3.right))
                {
                    point += Vector3.right;
                }

                //проверка на шаг по диагонали
                else if (BoardModel.CheckForEmptyOrPlatform(point + Vector3.up) &&
                         BoardModel.CheckForEmptyOrPlatform(point + new Vector3(1, 1, 0)))
                {
                    yield return(point += new Vector3(1, 1, 0));
                }

                else
                {
                    break;
                }

                point = UtilityFunctions.Leveling(point);
                yield return(point);
            }
        }