示例#1
0
        private IEnumerable <Vector3> CalculatePath(Vector3 point)
        {
            yield return(point);

            while (true)
            {
                //проверка на взлёт
                if (BoardModel.CheckForEmpty(point + Vector3.up))
                {
                    point += Vector3.up;
                }

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

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

                else
                {
                    break;
                }

                point = UtilityFunctions.Leveling(point);
                yield return(point);
            }
        }
示例#2
0
        private IEnumerable <Vector3> CalculatePath(Vector3 point)
        {
            yield return(point);

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

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

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

                else
                {
                    break;
                }

                point = UtilityFunctions.Leveling(point);
                yield return(point);
            }
        }
示例#3
0
        /// <summary>
        /// Сдвинуться в следующий тайл
        /// </summary>
        /// <param name="direction">Направление движения. True если вперед.</param>
        /// <returns>Сопрограмма</returns>
        public IEnumerator Move(bool direction)
        {
            if (direction)
            {
                yield return(StartCoroutine(MoveForward()));
            }
            else
            {
                yield return(StartCoroutine(MoveBackward()));
            }

            UtilityFunctions.Leveling(_transform);
        }
示例#4
0
        /// <summary>
        /// Передвинуть
        /// </summary>
        /// <param name="direction">Направление движения</param>
        /// <returns>Сопрограмма</returns>
        public IEnumerator MoveTo(Vector3 direction)
        {
            if (BoardModel.CheckForEmpty(_transform.position + direction))
            {
                _source.PlayOneShot(moveClip);

                float   t   = 0;
                Vector3 pos = _transform.position;

                while (t <= MovingSpeed)
                {
                    _transform.position = Vector3.Lerp(pos, pos + direction, t / MovingSpeed);
                    t += Time.deltaTime;
                    yield return(null);
                }

                UtilityFunctions.Leveling(_transform);
            }
        }