// Destroy the coconut once it has collied with the catcher void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Coconut") { playAudio.PlayOneShot(dropper.letterSounds[dropper.getRand()]); // play the sound of the letter on collision currentLetter = other.gameObject.GetComponent <SpriteRenderer>().sprite.name.ToString(); /**** BEGIN IF STATEMENTS FOR RANDOM SPELLING ORDER ******/ if (gameType == 0) // (if random order of letter selection is allowed) { if (imageClass.Contains(imageObjects, currentLetter) == true) { imageClass.findWithLetter(currentLetter, imageObjects).setCheck(true); // find the object within the array that contains the matching letter, and set it to true (it has been caught) collected = collected + currentLetter; Debug.Log(collected.ToString()); } else if (collected.Contains(currentLetter)) { lives--; // decrement lives :( Debug.Log("You already collected this letter"); } else { lives--; // decrement lives } Destroy(other.gameObject); //Debug.Log ("I'm Colliding"); } /**** BEGIN IF STATEMENTS FOR CORRECT SPELLING ORDER ******/ else if (gameType == 1) //(if correct order of spelling is chosen) { if (imageClass.correctOrder(imageObjects, currentLetter) == true) { imageClass.findWithLetter(currentLetter, imageObjects).setCheck(true); // find the object within the array that contains the matching letter, and set it to true (it has been caught) collected = collected + currentLetter; Debug.Log(collected.ToString()); } else if (collected.Contains(currentLetter)) { lives--; // decrement lives :( Debug.Log("You already collected this letter"); } else { lives--; // decrement lives } Destroy(other.gameObject); //Debug.Log ("I'm Colliding"); } } }