private IEnumerator LiftTileInTheAir(RuneBehaviour tile)
    {
        float ratio = 0f;

        Transform trans       = tile.GetComponent <Transform>();
        Transform cameraTrans = Camera.main.GetComponent <Transform>();

        Vector3 startPos = trans.position;


        Quaternion startRot = trans.rotation;


        while (ratio < 1f)
        {
            // The camera might move, so we recalculate the end position every frame
            Vector3    endPos = cameraTrans.position + cameraTrans.forward * 10f;//trans.position + new Vector3(0f, 5f, 0f);
            Quaternion endRot = Quaternion.LookRotation(cameraTrans.forward);

            ratio += Time.deltaTime / 1.5f;

            trans.position = Vector3.Lerp(startPos, endPos, ratio);
            trans.rotation = Quaternion.Slerp(startRot, endRot, ratio);

            yield return(null);
        }

        yield return(new WaitForSeconds(0.5f));

        StartCoroutine(SendTileToUI(tile));
    }
    private IEnumerator SendTileToUI(RuneBehaviour tile)
    {
        Transform trans = tile.GetComponent <Transform>();

        Vector3 startPos = trans.position;

        Vector3 startScale = trans.localScale;
        Vector3 endScale   = Vector3.one * 0.03f;

        float ratio = 0f;

        while (ratio < 1f)
        {
            ratio += Time.deltaTime / 1f;

            float viewportX = 0.2f + playerId * 0.3f;

            Vector3 endPos = Camera.main.ViewportToWorldPoint(new Vector3(viewportX, 0.8f, Camera.main.nearClipPlane + 0.1f));

            trans.position   = Vector3.Lerp(startPos, endPos, ratio);
            trans.localScale = Vector3.Lerp(startScale, endScale, ratio);

            yield return(null);
        }

        bool gameWasWon = false;

        foreach (Player player in state.players)
        {
            if (player.hasWon())
            {
                gameWasWon = true;
                StartCoroutine(SendWinnerToTheSky(player));
            }
        }

        if (gameWasWon)
        {
            StartCoroutine(FadeToDark());
        }
        else
        {
            // At the end of it all, we re-enabled the controls
            for (int i = 0; i < 3; i++)
            {
                InputManager.Instance.PushActiveContext("Normal", i);
            }

            EnableKinematics(false);
            Destroy(tile.gameObject);
        }
    }
    private IEnumerator MoveSelectorToTile(RuneBehaviour tile)
    {
        for (int i = 0; i < 3; i++)
        {
            InputManager.Instance.PushActiveContext("CinematicEvent", i);
        }

        // We don't want the color to lerp back to white while we are moving to the rune
        tile.GetComponent <RuneBehaviour>().enabled = false;

        tile.GetComponent <CapsuleCollider>().enabled     = false;
        tile.GetComponent <SpriteRenderer>().sortingOrder = 100;
        tile.symbol.sortingOrder = 101;

        EnableKinematics(true);

        Transform trans = PhysicsContainer.GetComponent <Transform>();

        Vector3 startPos = trans.position;
        Vector3 endPos   = startPos + tile.GetComponent <Transform>().position - Selector.GetComponent <Transform>().position;;

        endPos.y = startPos.y;

        float ratio = 0f;

        while (ratio < 1f)
        {
            ratio += Time.deltaTime / 0.25f;

            trans.position = Vector3.Lerp(startPos, endPos, ratio);

            yield return(null);
        }

        StartCoroutine(LiftTileInTheAir(tile));
    }
    private IEnumerator SendTileToUI(RuneBehaviour tile)
    {
        Transform trans = tile.GetComponent<Transform>();

        Vector3 startPos = trans.position;

        Vector3 startScale = trans.localScale;
        Vector3 endScale = Vector3.one * 0.03f;

        float ratio = 0f;
        while (ratio < 1f)
        {
            ratio += Time.deltaTime / 1f;

            float viewportX = 0.2f + playerId * 0.3f;

            Vector3 endPos = Camera.main.ViewportToWorldPoint(new Vector3(viewportX, 0.8f, Camera.main.nearClipPlane + 0.1f));

            trans.position = Vector3.Lerp(startPos, endPos, ratio);
            trans.localScale = Vector3.Lerp(startScale, endScale, ratio);

            yield return null;
        }

		bool gameWasWon = false;

		foreach (Player player in state.players)
		{
			if (player.hasWon())
			{
				gameWasWon = true;
				StartCoroutine(SendWinnerToTheSky(player));
			}
		}

		if (gameWasWon)
		{
			StartCoroutine(FadeToDark());
		}
		else
		{
			// At the end of it all, we re-enabled the controls
			for (int i = 0; i < 3; i++)
			{
				InputManager.Instance.PushActiveContext("Normal", i);
			}

			EnableKinematics(false);
			Destroy(tile.gameObject);
		}
    }
    private IEnumerator LiftTileInTheAir(RuneBehaviour tile)
    {
        float ratio = 0f;

        Transform trans = tile.GetComponent<Transform>();
        Transform cameraTrans = Camera.main.GetComponent<Transform>();

        Vector3 startPos = trans.position;
        

        Quaternion startRot = trans.rotation;
        

        while (ratio < 1f)
        {
            // The camera might move, so we recalculate the end position every frame
            Vector3 endPos = cameraTrans.position + cameraTrans.forward * 10f;//trans.position + new Vector3(0f, 5f, 0f);
            Quaternion endRot = Quaternion.LookRotation(cameraTrans.forward);

            ratio += Time.deltaTime / 1.5f;

            trans.position = Vector3.Lerp(startPos, endPos, ratio);
            trans.rotation = Quaternion.Slerp(startRot, endRot, ratio);

            yield return null;
        }

        yield return new WaitForSeconds(0.5f);

        StartCoroutine(SendTileToUI(tile));
    }
    private IEnumerator MoveSelectorToTile(RuneBehaviour tile)
    {
        for (int i = 0; i < 3; i++)
		{
            InputManager.Instance.PushActiveContext("CinematicEvent", i);
		}

        // We don't want the color to lerp back to white while we are moving to the rune
        tile.GetComponent<RuneBehaviour>().enabled = false;

        tile.GetComponent<CapsuleCollider>().enabled = false;
        tile.GetComponent<SpriteRenderer>().sortingOrder = 100;
        tile.symbol.sortingOrder = 101;

        EnableKinematics(true);

        Transform trans = PhysicsContainer.GetComponent<Transform>();

        Vector3 startPos = trans.position;
        Vector3 endPos = startPos + tile.GetComponent<Transform>().position - Selector.GetComponent<Transform>().position; ;
        endPos.y = startPos.y;

        float ratio = 0f;

        while (ratio < 1f)
        {
            ratio += Time.deltaTime / 0.25f;

            trans.position = Vector3.Lerp(startPos, endPos, ratio);

            yield return null;
        }

        StartCoroutine(LiftTileInTheAir(tile));
    }