예제 #1
0
    // 현재 오브젝트 좌표의 (-0.55, -0.35) 좌표까지 이동.
    IEnumerator StairDownMove()
    {
        characterAnimator.SetBool("IsWalk", true);

        float   nowLerp = 0.0f;
        Vector3 nowPlayerCoord;
        Vector3 startPlayerCoord = gameObject.transform.position;
        Vector3 endPlayerCoord   = startPlayerCoord;

        endPlayerCoord.x -= 0.55f;
        endPlayerCoord.y -= 0.35f;

        StartCoroutine(FadeOutRoutine());

        while (true)
        {
            nowPlayerCoord = Vector3.Lerp(startPlayerCoord, endPlayerCoord, nowLerp);
            TeleportCharacter.transform.position = nowPlayerCoord;
            TeleportCharacter.GetComponent <SpriteRenderer>().color =
                new Color(1, 1, 1, 1 - nowLerp);

            cameraSystem.camState = CameraSystem.CameraState.STOP;

            if (nowLerp < 1.0f)
            {
                nowLerp += Time.deltaTime / 1.0f;
            }
            else
            {
                characterAnimator.SetBool("IsWalk", false);

                Teleport();
                cameraSystem.changeViewport();

                TeleportCharacter.GetComponent <SpriteRenderer>().color =
                    new Color(1, 1, 1, 1);

                cameraSystem.camState = CameraSystem.CameraState.IDLE;
                yield return(StartCoroutine(FadeInRoutine()));


                yield break;
            }

            yield return(null);
        }

        yield break;
    }
    IEnumerator CamWaitTeleport2()
    {
        while (true)
        {
            if (cameraSystem.camState == CameraSystem.CameraState.IDLE)
            {
                TeleportCharacter.GetComponent <SpriteRenderer>().enabled = true;
                Teleport2();
                characterMover.moveType = CharacterMover.MoveType.COMMANDMOVE;
                Debug.Log("계단 다중입력 체크용 로그입니다...");
                yield break;
            }

            yield return(null);
        }
    }
    IEnumerator ToiletDoorRoutine()
    {
        // 캐릭터를 커멘드 입력 불가상태로 세팅한다.
        characterMover.moveType = CharacterMover.MoveType.LOCK;

        yield return(StartCoroutine("MoveCenter"));

        yield return(StartCoroutine("DoorOpen"));

        // ////////////////////////////////////////
        // 문 Scale 반대방향으로 자동이동
        // ////////////////////////////////////////

        // 이동 애니메이션 설정
        Animator animator = TeleportCharacter.GetComponent <Animator>();

        animator.SetBool("IsWalk", true);

        // 걸어갈 방향 설정
        float direction = -DoorCover.transform.localScale.x;

        // 도착지 설정
        Vector2 AfterMoveCoord = new Vector2(Destination.transform.position.x + (1.0f * direction),
                                             TeleportCharacter.transform.position.y);

        // 이동방향으로 캐릭터 방향 교정
        TeleportCharacter.transform.localScale = new Vector3(-direction, 1, 1);

        yield return(new WaitForSeconds(0.3f));

        // 좌표이동
        while (true)
        {
            TeleportCharacter.transform.position =
                Vector2.MoveTowards(TeleportCharacter.transform.position, AfterMoveCoord, 0.7f * Time.deltaTime);

            if (TeleportCharacter.transform.position.x == AfterMoveCoord.x)
            {
                animator.SetBool("IsWalk", false);
                break;
            }
            yield return(null);
        }

        characterMover.moveType = CharacterMover.MoveType.COMMANDMOVE;
        yield break;
    }
예제 #4
0
    // 미닫이 문열기 동작 루틴
    public IEnumerator DoorSlide()
    {
        float nowLerp = 0.0f;
        float nowDoorXPos;
        float startDoorXPos = DoorCover.transform.position.x;
        float endDoorXPos   = startDoorXPos + (-DoorCover.transform.localScale.x * 0.8f);
        float moveTime      = 1.0f;

        nowDoorXPos = Mathf.Lerp(startDoorXPos, endDoorXPos, nowLerp);

        // 애니메이터 뒷모습으로 전환
        Animator animator = TeleportCharacter.GetComponent <Animator>();

        animator.SetBool("IsBack", true);
        yield return(new WaitForSeconds(0.5f));

        StartCoroutine(FadeOutRoutine());

        while (true)
        {
            nowDoorXPos = Mathf.Lerp(startDoorXPos, endDoorXPos, nowLerp);
            DoorCover.transform.position = new Vector3(nowDoorXPos, DoorCover.transform.position.y, DoorCover.transform.position.z);

            if (nowLerp < 1.0f) // 보간수치가 1 이하면 상승, 넘어가면 이동완료
            {
                nowLerp += Time.deltaTime / moveTime;
            }
            else
            {
                Teleport();
                cameraSystem.changeViewport();
                animator.SetBool("IsBack", false);
                DoorCover.transform.position = new Vector3(startDoorXPos, DoorCover.transform.position.y, DoorCover.transform.position.z);

                yield return(StartCoroutine(FadeInRoutine()));

                yield break;
            }

            yield return(null);
        }
    }
예제 #5
0
    // 계단 이동시 시행될 전체 업데이트
    private IEnumerator StairMoveTeleport()
    {
        Animator animator = TeleportCharacter.GetComponent <Animator>();

        // 캐릭터 애니메이터 걷기 세팅
        animator.SetBool("IsWalk", true);
        Vector2 desCoord;

        desCoord.x = this.transform.position.x;
        desCoord.y = TeleportCharacter.transform.position.y;

        // 캐릭터 방향 설정
        Vector3 dirVec;

        if (TeleportCharacter.transform.position.x < this.transform.position.x)
        {
            dirVec = new Vector3(-1, 1, 1);
        }
        else
        {
            dirVec = new Vector3(1, 1, 1);
        }

        while (true)
        {
            // 캐릭터 좌표 이동. 1.0f의 속도로.
            TeleportCharacter.transform.position = Vector2.MoveTowards(TeleportCharacter.transform.position, desCoord, 0.5f * Time.deltaTime);


            TeleportCharacter.transform.localScale   = dirVec;
            characterMover.Icon.transform.localScale = new Vector3(dirVec.x, 1, 1);

            // 도착시
            if (TeleportCharacter.transform.position.x == this.transform.position.x)
            {
                // 애니메이터 뒷모습으로 전환
                animator.SetBool("IsWalk", false);
                animator.SetBool("IsDoorIn", true);

                // 1.5초 뒤 이동, 이동타입 회복, 뷰포트전환
                yield return(new WaitForSeconds(1.0f));

                //TeleportCharacter.SetActive(false); // ★
                TeleportCharacter.GetComponent <SpriteRenderer>().enabled = false;
                yield return(new WaitForSeconds(0.5f));


                // 카메라슬로우 무브 상태로 세팅한 후
                cameraSystem.SetSlowMove(Destination.transform.position.x, Destination.transform.position.y);

                PlaceInfoUI placeUI = FindObjectOfType <PlaceInfoUI>();
                placeUI.TextOn(InfoText);
                yield return(StartCoroutine(placeUI.TextFadeInRoutine()));

                // 코루틴 내부의 코루틴 생명주기 파악 필요함
                yield return(StartCoroutine("CamWaitTeleport"));

                // 애니메이터 IDLE로 회복
                animator.SetBool("IsDoorIn", false);
                animator.SetBool("IsWalk", true);

                yield return(new WaitForSeconds(1.0f));

                yield return(StartCoroutine(placeUI.TextFadeOutRoutine()));

                //yield return StartCoroutine(FindObjectOfType<PlaceInfoUI>().TextFadeRoutine(InfoText));

                yield break;
            }
            yield return(null);
        }
    }