Пример #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag.Contains("Item"))
     {
         int    pts = other.gameObject.GetComponent <Item> ().points;
         string tag = other.gameObject.tag;
         if (tag == "PointItem")
         {
             worldSpaceCanvas.AddText(other.transform.position, "+" + pts.ToString());
             pickupSound.Play();
             GameManager.instance.addPoints(pts);
             Destroy(other.gameObject);
         }
         else if (tag == "BadItem")
         {
             worldSpaceCanvas.AddText(other.transform.position, "-" + pts.ToString());
             GameManager.instance.losePoints(pts);
             Destroy(other.gameObject);
         }
         else
         {
             Debug.Log("UNKNOWN TAG: " + tag);
         }
     }
 }
Пример #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "PointItem")
     {
         GameManager.instance.losePoints(other.gameObject.GetComponent <Item>().points);
         Destroy(other.gameObject);
         Destroy(this.gameObject);
     }
     else if (other.tag == "BadItem")
     {
         Instantiate(explosion, other.transform.position, Quaternion.Euler(0.0f, 0.0f, Random.Range(0.0f, 360.0f)));
         int pts = other.gameObject.GetComponent <Item>().points;
         worldSpaceCanvas.AddText(other.transform.position, "+" + pts.ToString());
         GameManager.instance.addPoints(pts);
         Destroy(other.gameObject);
         Destroy(this.gameObject);
     }
 }