// Use this for initialization

    void Start()
    {
        Init();

        _stageGenerator = GameManager.FindObjectOfType <stageGenerator>();
        this.Hearts     = AllLevels.Instance.pushStage().hearts;
        this.StageLong  = AllLevels.Instance.pushStage().stageLength;
    }
    public IEnumerator passLevelAnim(Image img, Text levelText)
    {
        IsLevelPass.SetActive(true);
        AllLevels.Instance.IncrementLevelIndex();
        levelText.text = AllLevels.Instance.lastGameIndex.ToString();
        // todo HALILU buraya saniyeyi ayarlamak için gelinebilir.
        yield return(new WaitForSeconds(1f));

        IsLevelPass.SetActive(false);
        stageGenerator stageGenerator = GameObject.Find("StageGenerator").GetComponent <stageGenerator>();
        Stage          _stage         = AllLevels.Instance.pushStage();

        stageGenerator.Init(false);
    }
    public IEnumerator restartStageAnim(Image img, int number)
    {
        switch (number)
        {
        case 1:
            Camera.main.backgroundColor = Color.black;
            IsRestartStage.SetActive(true);
            img.raycastTarget = true;
            img.sprite        = restartAnimSprites[0];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 2));
            break;

        case 2:
            img.sprite = restartAnimSprites[1];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 3));
            break;

        case 3:
            img.sprite = restartAnimSprites[2];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 4));
            break;

        case 4:
            img.sprite = restartAnimSprites[3];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 5));
            break;

        case 5:
            img.sprite = restartAnimSprites[4];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 6));
            break;

        case 6:
            img.sprite = restartAnimSprites[5];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 7));
            break;

        case 7:
            img.sprite = restartAnimSprites[6];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 8));
            break;

        case 8:
            img.sprite = restartAnimSprites[7];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 9));
            break;

        case 9:
            img.sprite = restartAnimSprites[8];
            yield return(new WaitForSeconds(1f));

            StartCoroutine(restartStageAnim(img, 10));
            break;

        case 10:
            img.sprite = restartAnimSprites[9];
            yield return(new WaitForSeconds(0.03f));

            StartCoroutine(restartStageAnim(img, 11));
            break;

        case 11:
            img.sprite = null;
            img.color  = Color.black;
            yield return(new WaitForSeconds(0.5f));

            img.color         = Color.white;
            img.raycastTarget = false;
            IsRestartStage.SetActive(false);
            Camera.main.backgroundColor = _currentColor;
            stageGenerator stageGenerator = GameObject.Find("StageGenerator").GetComponent <stageGenerator>();
            Stage          _stage         = AllLevels.Instance.pushStage();
            stageGenerator.Init(true);
            break;
        }
    }