Example #1
0
    IEnumerator BallCountTextShow(int greenBallCount)
    {
        //초록공 합쳐지기 전후 공 개수 보여주기
        BallCountTextObj.transform.position = new Vector3(Mathf.Clamp(veryFirstPos.x, -49.9f, 49.9f), -65, 0);
        BallCountText.text = "x" + BallGroup.childCount.ToString();

        yield return(new WaitForSeconds(0.17f));

        if (BallGroup.childCount > score)
        {
            Destroy(BallGroup.GetChild(BallGroup.childCount - 1).gameObject);
        }
        BallCountText.text = "x" + BallGroup.childCount.ToString();

        // 바닥에 떨어진 초록공 +로 표시하기
        if (greenBallCount != 0)
        {
            BallPlusTextObj.SetActive(true);
            BallPlusTextObj.transform.position = new Vector3(Mathf.Clamp(veryFirstPos.x, -49.9f, 49.9f), -47, 0);
            BallPlusText.text = "+" + greenBallCount.ToString();
            S_Plus.Play();

            yield return(new WaitForSeconds(0.5f));

            BallPlusTextObj.SetActive(false);
        }
    }
Example #2
0
    IEnumerator BallCountTextShow(int greenBallCount)
    {
        BallCountTextObj.transform.position = new Vector3(Mathf.Clamp(veryFirstPos.x, -49.9f, 49.9f), -65, 0);
        BallCountText.text = "x" + BallGroup.childCount.ToString();

        yield return(new WaitForSeconds(0.17f));

        if (greenBallCount != 0)
        {
            BallPlusTextObj.SetActive(true);
            BallPlusTextObj.transform.position = new Vector3(Mathf.Clamp(veryFirstPos.x, -49.9f, 49.9f), -47, 0);
            BallPlusText.text = "+" + greenBallCount.ToString();
            S_Plus.Play();

            yield return(new WaitForSeconds(0.5f));

            BallPlusTextObj.SetActive(false);
        }
    }
Example #3
0
    IEnumerator BlockMoveDown(Transform TR)
    {
        yield return(new WaitForSeconds(0.2f));

        Vector3 targetPos = TR.position + new Vector3(0, -12.8f, 0);

        BlockColorChange();

        // 마지막 줄이면 게임오버 트리거, 콜라이더 비활성화
        if (targetPos.y < -50)
        {
            if (TR.CompareTag("Block"))
            {
                isDie = true;
            }
            for (int i = 0; i < BallGroup.childCount; i++)
            {
                BallGroup.GetChild(i).GetComponent <CircleCollider2D>().enabled = false;
            }
        }

        // 0.3 초간 블럭 이동
        float TT = 1.5f;

        while (true)
        {
            yield return(null); TT -= Time.deltaTime * 1.5f;
            TR.position             = Vector3.MoveTowards(TR.position, targetPos + new Vector3(0, -6, 0), TT);
            if (TR.position == targetPos + new Vector3(0, -6, 0))
            {
                break;
            }
        }
        TT = 0.9f;
        while (true)
        {
            yield return(null); TT -= Time.deltaTime;
            TR.position             = Vector3.MoveTowards(TR.position, targetPos, TT);
            if (TR.position == targetPos)
            {
                break;
            }
        }
        isBlockMoving = false;

        // 이동되고 난 후 마지막줄이면 & 블럭이면 게임오버, 초록구면 파괴
        if (targetPos.y < -50)
        {
            if (TR.CompareTag("Block"))
            {
                for (int i = 0; i < BallGroup.childCount; i++)
                {
                    Destroy(BallGroup.GetChild(i).gameObject);
                }
                Destroy(Instantiate(P_ParticleBlue, veryFirstPos, QI), 1);

                BallCountTextObj.SetActive(false);
                BallPlusTextObj.SetActive(false);
                BestScoreText.gameObject.SetActive(false);
                ScoreText.gameObject.SetActive(false);

                GameOverPanel.SetActive(true);
                FinalScoreText.text = "최종점수 : " + score.ToString();
                if (isNewRecord)
                {
                    NewRecordText.gameObject.SetActive(true);
                }

                Camera.main.GetComponent <Animator>().SetTrigger("shake");
                S_GameOver.Play();
            }
            else
            {
                Destroy(TR.gameObject);
                Destroy(Instantiate(P_ParticleGreen, TR.position, QI), 1);

                for (int i = 0; i < BallGroup.childCount; i++)
                {
                    BallGroup.GetChild(i).GetComponent <CircleCollider2D>().enabled = true;
                }
            }
        }
    }