Exemplo n.º 1
0
    // TODO add shake

    private IEnumerator SlideDown()
    {
        const float slideDuration = 0.6f;
        float       slideTimer    = 0f;

        const float topEndY      = 2.11f;
        const float bottomEndY   = -2.97f;
        float       topStartY    = _topDoor.position.y;
        float       bottomStartY = _bottomDoor.position.y;


        // TODO add pause
        while (slideTimer < slideDuration)
        {
            slideTimer += Time.deltaTime;
            float ratio      = Mathf.Clamp(slideTimer / slideDuration, 0f, 1f);
            float topPosY    = topStartY - (topStartY - topEndY) * Mathf.Pow(ratio, 7);
            float bottomPosY = bottomStartY - (bottomStartY - bottomEndY) * Mathf.Pow(ratio, 7);
            _topDoor.position    = new Vector2(_topDoor.position.x, topPosY);
            _bottomDoor.position = new Vector2(_bottomDoor.position.x, bottomPosY);
            yield return(null);
        }

        CameraEventListener.CameraShake();
        yield return(new WaitForSeconds(0.5f));

        CameraEventListener.StopCameraShake();
    }
Exemplo n.º 2
0
    private IEnumerator ShakeScreen(float time)
    {
        GetComponent <Rigidbody2D>().velocity = Vector2.up * 0.5f;    // Prevents the boss from falling through the floor
        CameraEventListener.CameraShake();
        yield return(StartCoroutine("WaitSeconds", time));

        CameraEventListener.StopCameraShake();
    }