Пример #1
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Star"))
     {
         cristals.score++;
         cristals.SetValue();
     }
     if (collision.gameObject.CompareTag("DarkStar"))
     {
         cristals.score = cristals.score - 10;
         if (cristals.score < 0)
         {
             cristals.score = 0;
         }
         cristals.SetValue();
     }
     if (collision.gameObject.CompareTag("YellowStar"))
     {
         int YellowRandom = Random.Range(0, 2);
         if (YellowRandom == 0)
         {
             ball.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
         }
         if (YellowRandom == 1)
         {
             ball.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
         }
         if (YellowRandom == 1)
         {
             ball.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
         }
     }
     if (collision.gameObject.CompareTag("BlueStar"))
     {
         int BlueRandom = Random.Range(0, 2);
         if (BlueRandom == 0)
         {
             transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
         }
         if (BlueRandom == 1)
         {
             transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
         }
         if (BlueRandom == 2)
         {
             transform.localScale = new Vector3(1f, 1f, 1f);
         }
     }
     Destroy(collision.gameObject);
 }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         cristals       = FindObjectOfType <Cristals>();
         cristals.score = cristals.score + postiveEffect[positiveRandom];
         cristals.SetValue();
         Instantiate(VisualEffect, transform.position, Quaternion.identity);
         Destroy(gameObject);
     }
 }