Exemple #1
0
    IEnumerator StairAnimation()
    {
        // Freezes player Movement
        player.FreezePlayer();

        // Instantiate the next room
        Room          nextRoom         = stair.GetNextRoom(currentRoom.GetCurrentRoom());
        RoomGenerator newRoomGenerator =
            FindObjectOfType <DungeonDisplay>().InstantiateRoom(nextRoom);

        // Initially Disables all Stair Animations
        newRoomGenerator.EnableStairAnimations(false);
        // Moves player to the center of the stairs.
        Coroutine a = StartCoroutine(player.MovePlayerToPoint(
                                         (Vector2)this.transform.position,
                                         player.GetSpeed()));

        yield return(a);

        // Fades the camera to black
        Coroutine b = StartCoroutine(
            fader.FadeCanvasGroupDistinct(alphaValuesFadeBlack, timeToFade));

        yield return(b);

        // Moves the camera and player to the next room.
        player.transform.position =
            stair.GetStairWorldPosition(nextRoom);
        mainCamera.SetCameraToNewRoom(nextRoom);

        // Updates the current room
        currentRoom.SetCurrentRoom(nextRoom);

        // Defades the camera
        Coroutine c = StartCoroutine(
            fader.FadeCanvasGroupDistinct(alphaValuesFadeReturn, timeToFade));

        yield return(c);

        // Enables stair animations
        newRoomGenerator.EnableStairAnimations(true);

        // Destroys current room generator
        Destroy(GetComponentInParent <RoomGenerator>().gameObject);

        // Unfreezes the player
        player.UnfreezePlayer();
    }
    private IEnumerator ChaliceAnimation()
    {
        CurrentRoom currentRoom    = FindObjectOfType <CurrentRoom>();
        Vector2     currentRoomPos =
            currentRoom.GetCurrentRoomCoordinate().GetRoomWorldPosition();
        GameObject curtainsGameObject =
            Instantiate(curtains.gameObject,
                        currentRoomPos,
                        Quaternion.identity);

        player = FindObjectOfType <Player>();
        player.FreezePlayer();
        player.transform.position =
            FindObjectOfType <CurrentRoom>().
            GetCurrentRoomCoordinate().
            GetRoomWorldPosition();
        player.GetComponent <SpriteRenderer>().sortingLayerID = SortingLayer.NameToID("AboveAll");
        Animator playerAnimator = player.GetComponent <Animator>();

        playerAnimator.SetTrigger("chalice");
        // Moves Chalice above player
        this.transform.position =
            (Vector2)player.transform.position + new Vector2(0, 1f);
        this.GetComponent <SpriteRenderer>().sortingLayerID = SortingLayer.NameToID("AboveAll");
        whiteFader = GameObject.Find("FaderWhite").GetComponent <UIFader>();
        yield return(new WaitForSeconds(.5f));

        Coroutine a = StartCoroutine(whiteFader.FadeCanvasGroupDistinct(whiteShineAlpha, shineTime));

        yield return(a);

        yield return(new WaitForSeconds(2f));

        Coroutine b = StartCoroutine(curtainsGameObject.GetComponent <Curtains>().CloseCurtains());
    }