Exemplo n.º 1
0
    /*
     * IEnumerator ExpulsionAlien()
     * {
     *  SetMovementState(AlienMovementState.Expulsion);
     *  currentClickableExpulsion = currentClickable;
     *  RectTransform rt = GetComponent<RectTransform>();
     *  Vector2 targetPosition = library.map.GetExpulsionTargetPosition(this, currentClickable);
     *  SetIgnoreWallClickable(currentClickable);
     *
     *  while (Vector2.Distance(rt.position, targetPosition) > 1f)
     *  {
     *      while (pauseInCupol || pauseInBlackHole)
     *          yield return null;
     *
     *      rt.position = Vector2.Lerp(rt.position, targetPosition, Time.deltaTime * 5);
     *
     *      yield return null;
     *  }
     *  currentClickableExpulsion = null;
     *  SetMovementState(AlienMovementState.Free);
     * }*/

    /*
     * IEnumerator PusherExpulsionAlienCoroutine()
     * {
     * SetMovementState(AlienMovementState.Expulsion);
     * currentClickableExpulsion = currentClickable;
     * currentFountainTarget = null;
     *
     * RectTransform rt = GetComponent<RectTransform>();
     * Vector2 targetPosition = library.map.GetPusherExpulsionTargetPosition(this, currentClickable);
     *
     * while (Vector2.Distance(rt.position, targetPosition) > 3f)
     * {
     *  while (pauseInCupol || pauseInBlackHole)
     *      yield return null;
     *
     *  rt.position = Vector2.Lerp(rt.position, targetPosition, Time.deltaTime * GameplayConstants.ExpulsionAlienSpeed);
     *
     *  yield return null;
     * }
     * currentClickableExpulsion = null;
     * SetMovementState(AlienMovementState.Free);
     * }*/

    /*
     * public void PusherExpulsionAlien()
     * {
     * if (currentMovableCoroutine != null)
     *  StopCoroutine(currentMovableCoroutine);
     *
     * if (currentWaitCoroutine != null)
     *  StopCoroutine(currentWaitCoroutine);
     *
     * StartCoroutine(PusherExpulsionAlienCoroutine());
     * }
     */

    IEnumerator MoveToCoroutine(Clickable clickable)
    {
        RectTransform rt = GetComponent <RectTransform>();
        //  RectTransform targetRt = null;

        //   targetRt = clickable.GetComponent<RectTransform>();

        bool isFinalTarget = false;

        if (wayQueue.Count == 0)
        {
            isFinalTarget = true;
            SetMovementState(AlienMovementState.MoveToPoint);
        }
        else
        {
            SetMovementState(AlienMovementState.MoveToJump);
        }
        Vector2 targetPosition = clickable.GetLocalPosition(isFinalTarget) /*- library.canvas.scaleFactor * new Vector3(0, DeltaHeight, 0)*/;


        while (Vector2.Distance(rt.anchoredPosition, targetPosition) > 1f)
        {
            while (pauseInCupol || pauseInBlackHole)
            {
                yield return(null);
            }

            Vector2 tempPosition = Vector2.MoveTowards(rt.anchoredPosition, targetPosition, Time.deltaTime * speed);

            /*
             * if (currentClickable.IsWall() && AlienInWall(tempPosition))
             * {
             *
             *  ////После столкновения со стеной на пару секунд надо забыть о фонтане.
             * //   SetLastTarget(currentClickable);
             *  SetIgnoreFountainClickable(currentFountainTarget);
             *  currentFountainTarget = null;
             * // isFoundFountain = false;
             *  currentMovementState = AlienMovementState.Free;
             *  StopAllCoroutines();
             * }
             * else*/
            rt.anchoredPosition = tempPosition;



            yield return(null);
        }
        //  rt.position = targetPosition;

        // SetLastTarget(clickable);

        if (currentMovementState.Equals(AlienMovementState.MoveToJump))
        {
            readyToJump = true;
        }

        MoveToTarget();
    }