Beispiel #1
0
    void BlockGenerator()
    {
        //점수
        ScoreText.text = "현재점수 :" + (++score).ToString();
        if (PlayerPrefs.GetInt("BestScore", 0) < score)
        {
            PlayerPrefs.SetInt("BestScore", score);
            BestScoreText.text  = "최고기록 : " + PlayerPrefs.GetInt("BestScore").ToString();
            BestScoreText.color = greenColor;
            isNewRecord         = true;
        }

        //점수에 따른 블럭복사개수 정하기
        int count;
        int randBlock = Random.Range(0, 24);

        if (score <= 10)
        {
            count = randBlock < 16 ? 1 : 2;
        }
        else if (score <= 20)
        {
            count = randBlock < 8 ? 1 : (randBlock < 16 ? 2 : 3);
        }
        else if (score <= 40)
        {
            count = randBlock < 9 ? 2 : (randBlock < 18 ? 3 : 4);
        }
        else
        {
            count = randBlock < 8 ? 2 : (randBlock < 16 ? 3 : (randBlock < 20 ? 4 : 5));
        }

        // 스폰좌표에 블럭, 초록구 생성
        List <Vector3> SpawnList = new List <Vector3>();

        for (int i = 0; i < 6; i++)
        {
            SpawnList.Add(new Vector3(-46.7f + i * 18.68f, 51.2f, 0));
        }

        for (int i = 0; i < count; i++)
        {
            int rand = Random.Range(0, SpawnList.Count);

            Transform TR = Instantiate(P_Block, SpawnList[rand], QI).transform;
            TR.SetParent(BlockGroup);
            TR.GetChild(0).GetComponentInChildren <Text>().text = score.ToString();

            SpawnList.RemoveAt(rand);
        }
        Instantiate(P_GreenOrb, SpawnList[Random.Range(0, SpawnList.Count)], QI).transform.SetParent(BlockGroup);

        //블럭 내리기
        isBlockMoving = true;
        for (int i = 0; i < BlockGroup.childCount; i++)
        {
            StartCoroutine(BlockMoveDown(BlockGroup.GetChild(i)));
        }
    }
Beispiel #2
0
 public void BlockColorChange()
 {
     //블럭텍스트 / 스코어를 7등분해서 색을 칠함
     for (int i = 0; i < BlockGroup.childCount; i++)
     {
         if (BlockGroup.GetChild(i).CompareTag("Block"))
         {
             float per = int.Parse(BlockGroup.GetChild(i).GetChild(0).GetComponentInChildren <Text>().text) / (float)score;
             Color curColor;
             if (per <= 0.1428f)
             {
                 curColor = blockColor[6];
             }
             else if (per <= 0.2856f)
             {
                 curColor = blockColor[5];
             }
             else if (per <= 0.4284f)
             {
                 curColor = blockColor[4];
             }
             else if (per <= 0.5172f)
             {
                 curColor = blockColor[3];
             }
             else if (per <= 0.714f)
             {
                 curColor = blockColor[2];
             }
             else if (per <= 0.8568f)
             {
                 curColor = blockColor[1];
             }
             else
             {
                 curColor = blockColor[0];
             }
             BlockGroup.GetChild(i).GetComponent <SpriteRenderer>().color = curColor;
         }
     }
 }