Exemplo n.º 1
0
    IEnumerator LaunchAttack()
    {
        //if (unit.enemy.transform.position.x - gameObject.transform.position.x > 0) {
        //    enemyDirection = Direction.right;
        //} else {
        //    enemyDirection = Direction.left;
        //}
        unit.launchingAttack = true;
        Vector2 current = gameObject.transform.position;
        //todo: get direction needs to be updated when chasing from behind
        Vector2 newPosition = unit.GetFaceDirection().normalized *attackDistance + current;

        if (gameObject != null)
        {
            PetUtility.Coroutine(PetUtility.LinearMove(current, newPosition, 0.15f, gameObject.transform));
        }
        yield return(new WaitForSeconds(0.15f));

        if (gameObject != null)
        {
            PetUtility.Coroutine(PetUtility.LinearMove(newPosition, current, 0.15f, gameObject.transform));
        }
        yield return(new WaitForSeconds(0.15f));

        yield return(null);
    }