private void OnCollisionEnter2D(Collision2D collision) { Blobby b = collision.gameObject.GetComponent <Blobby>(); if (b == null) { return; } TrappedBlobby trapped = Instantiate(trappedPrefab); trapped.color = b.color; trapped.worth = b.chonk; trapped.gameObject.transform.position = transform.position; shop.MakeMoney((int)b.GetBlobWorth()); data.blobbiesSacrificed += 1; sound.PlayTrapClip(); Destroy(gameObject); Destroy(b.gameObject); Destroy(trapped.gameObject, 10); }
void CompleteGame() { GameObject[] blobs = GameObject.FindGameObjectsWithTag("Blobby"); gameData.blobbiesKeptAlive = blobs.Length; foreach (GameObject go in blobs) { Blobby blob = go.GetComponent <Blobby>(); gameData.finalScore += (int)(blob.GetBlobWorth() * 2) + shop.coins; } SceneManager.LoadScene("GameComplete"); }