示例#1
0
 void OnTriggerEnter2D(Collider2D col)
 {
     /*if(col.tag == manualChanger)
      * {
      *  spriteRenderer.color = colors.manualColor;
      *  Destroy(col.gameObject);
      *  return;
      * }*/
     if (col.tag == colorChanger)
     {
         audioManager.GetComponent <AudioManager>().Play("colorswitch");
         SetRandomColor();
         Destroy(col.gameObject);
         return;
     }
     if (col.tag != manualChanger && col.tag != "Star" && col.tag != colorSet.ToString())
     {
         //Debug.LogFormat("Current color: {0}", currentColor);
         //Debug.LogFormat("ColorSet value: {0}", colorSet);
         //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         //Reset();
         gameManager.GetComponent <GameManager>().ExplodePlayer(gameObject.transform);
         gameObject.SetActive(false);
         return;
     }
     if (col.tag == "Star")
     {
         audioManager.GetComponent <AudioManager>().Play("star");
         currentStar = col.gameObject;
         //Vector2 pos = UnityEngine.Random.insideUnitCircle;
         //Debug.Log(int.Parse(GetComponent<TMPro.TextMeshProUGUI>().text));
         score = int.Parse(Score.GetComponent <TMPro.TextMeshProUGUI>().text) + 1;
         Score.GetComponent <TMPro.TextMeshProUGUI>().text = score.ToString();
         GameManager obj = gameManager.GetComponent <GameManager>();
         obj.starsCollected++;
         obj.StartCoroutine(obj.SpawnStars(col.transform));
         obj.StartCoroutine(obj.SpawnPlusOne(col.gameObject));
         obj.StartCoroutine(obj.AnimatePlusOne());
         if (col.gameObject.name == "BaseStar1" || col.gameObject.name == "BaseStar2")
         {
             col.gameObject.SetActive(false);
         }
         else
         {
             Destroy(col.gameObject);
         }
         //Instantiate(smallStar, UnityEngine.Random.insideUnitCircle * 1/2f, Quaternion.identity);
     }
 }