private IEnumerator MoveForward() { //проверка на взлёт if (BoardModel.CheckForEmpty(_transform.position + Vector3.up)) { yield return(StartCoroutine(MakeStepUp())); } //проверка на шаг вправо else if (BoardModel.CheckForEmptyOrPlatform(_transform.position + Vector3.right)) { yield return(StartCoroutine(MakeStepRight())); } //проверка на шаг по диагонали else if (BoardModel.CheckForEmpty(_transform.position + Vector3.up) && BoardModel.CheckForEmptyOrPlatform(_transform.position + new Vector3(1, -1, 0))) { yield return(StartCoroutine(MakeStepRightDown())); } else { _robot.ForwardFlag = false; } }
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); } }
private IEnumerator MoveBackward() { //проверка на взлёт if (BoardModel.CheckForEmpty(_transform.position + Vector3.up)) { yield return(StartCoroutine(MakeStepUp())); } //проверка на шаг влево else if (BoardModel.CheckForEmptyOrPlatform(_transform.position + Vector3.left)) { yield return(StartCoroutine(MakeStepLeft())); } //проверка на шаг по диагонали else if (BoardModel.CheckForEmpty(_transform.position + Vector3.down) && BoardModel.CheckForEmptyOrPlatform(_transform.position + new Vector3(-1, -1, 0))) { yield return(StartCoroutine(MakeStepLeftDown())); } else if (BoardModel.CheckForPlatform(_transform.position)) { _robot.OnReturnAction(); } else { _robot.OnStoppageAction(); } }
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); } }
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; } }
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(); } }
/// <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); } }
/// <summary> /// Проверяет находится ли робот в полёте или падении /// </summary> /// <returns>true если падаем</returns> public bool CheckForFly() { return(BoardModel.CheckForEmpty(_transform.position + Vector3.up)); }