예제 #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (GameManager.instance.gameState == GameManager.GameState.PLAY)
        {
            ObstacleScroll obstacleScroll = col.gameObject.GetComponent <ObstacleScroll>();

            Debug.Log("트리거 작동?");

            if (obstacleScroll != null)
            {
                if (!obstacleScroll.GetIsHit())
                {
                    if (GameManager.instance.feverState == 0)
                    {
                        if (col.tag == "Snowman")
                        {
                            Debug.Log("Snowman과 충돌");
                            GameObject particle = Instantiate(snowmanParticle, col.transform.position, Quaternion.identity);
                            Destroy(particle, 2f);
                            obstacleScroll.HitByPlayer();
                            SetScale(ballScale + snowManScale);
                            Destroy(col.gameObject);
                            GameManager.instance.AddScore(1000);
                        }
                        else if (col.tag == "Rock" || col.tag == "Tree")
                        {
                            Debug.Log("장애물과 충돌");
                            GameObject particle = Instantiate(SnowParticle, col.transform.position, Quaternion.identity);
                            particle.transform.localScale = particle.transform.localScale * ballScale / 4;
                            Destroy(particle, 2f);
                            obstacleScroll.HitByPlayer();
                            SetScale(ballScale - obstacleScale);
                        }
                    }
                    if (GameManager.instance.feverState == 2)
                    {
                        obstacleScroll.HitAtFever();
                        GameObject particle;
                        if (col.tag == "Rock")
                        {
                            particle = Instantiate(rockParticle, col.transform.position, Quaternion.identity);
                        }
                        else if (col.tag == "Tree")
                        {
                            particle = Instantiate(treeParticle, col.transform.position, Quaternion.identity);
                        }
                        else// if (col.tag == "Snowman")
                        {
                            particle = Instantiate(snowmanParticle, col.transform.position, Quaternion.identity);
                        }
                        particle.transform.localScale = particle.transform.localScale * 1.5f;
                        Destroy(particle, 2f);
                        GameManager.instance.AddScore(2000);    // 2000점
                    }
                }
            }
        }
    }
예제 #2
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (GameManager.instance.gameState == GameManager.GameState.PLAYING)
     {
         ObstacleScroll os = col.gameObject.GetComponent <ObstacleScroll>();
         if (os != null)
         {
             if (os.GetIsHit() == false)
             {
                 if (GameManager.instance.feverState == 0)
                 {
                     if (col.tag == "Snowman")
                     {
                         SoundManager.instance.RandomizeSfx(colliSnow1, colliSnow2, colliSnow3);
                         GameObject p = Instantiate(snowmanParticle, col.transform.position, Quaternion.identity);
                         Destroy(p, 2f);
                         os.HitByPlayer();
                         SetScale(ballScale + snowManScale);
                         Destroy(col.gameObject);
                         GameManager.instance.AddScore(1000);    // 1000점
                     }
                     else if (col.tag == "Wall" || col.tag == "Tree")
                     {
                         SoundManager.instance.RandomizeSfx(colliWall1, colliWall2, colliWall3);
                         GameObject p = Instantiate(SnowParticle, col.transform.position, Quaternion.identity);
                         p.transform.localScale = p.transform.localScale * ballScale / 4;
                         Destroy(p, 2f);
                         os.HitByPlayer();
                         SetScale(ballScale - obstacleScale);
                     }
                 }
                 if (GameManager.instance.feverState == 2)
                 {
                     SoundManager.instance.RandomizeSfx(colliFever);
                     os.HitAtFever();
                     GameObject p;
                     if (col.tag == "Wall")
                     {
                         p = Instantiate(rockParticle, col.transform.position, Quaternion.identity);
                     }
                     else if (col.tag == "Tree")
                     {
                         p = Instantiate(treeParticle, col.transform.position, Quaternion.identity);
                     }
                     else// if (col.tag == "Snowman")
                     {
                         p = Instantiate(snowmanParticle, col.transform.position, Quaternion.identity);
                     }
                     p.transform.localScale = p.transform.localScale * 1.5f;
                     Destroy(p, 2f);
                     GameManager.instance.AddScore(2000);    // 2000점
                 }
             }
         }
     }
 }