//Expand this region to see the methods related to collision events #region CollisionEvents private void OnTriggerEnter2D(Collider2D other) { switch (other.gameObject.tag) { case "Dust": if (isCleaning) { GameObject newTrash = Instantiate(trashBall, trashBallOffset.transform.position, Quaternion.identity); levelManager.AddToTrashToDestroy(newTrash); newTrash.GetComponent <Rigidbody2D>().mass = other.GetComponent <TrashManager>().trashValue; TrashManager trashScript = other.GetComponent <TrashManager>(); trashScript.PlayTrashClip(); // Destroy(other.gameObject); } break; case "Souvenir": Destroy(other.gameObject); levelManager.PickUpSouvenir(); break; default: break; } }
private void GrowTrashBall(GameObject toDestroy, int massScaleAmount) { float scaleF = massScaleAmount / 100f; transform.localScale += new Vector3(scaleF, scaleF, scaleF); rb.mass += massScaleAmount; if (toDestroy.CompareTag("Dust")) { TrashManager trashScript = toDestroy.GetComponent <TrashManager>(); trashScript.PlayTrashClip(); // Destroy(toDestroy.gameObject); } else { GetComponent <EatAndBeingEaten>().EatABall(toDestroy); } if (rb.mass >= 10) { transform.GetChild(0).gameObject.SetActive(true); massText.text = rb.mass + "kg"; } }