private void tappedHandler(object sender, EventArgs e) { if (popSound) { AudioSource.PlayClipAtPoint(popSound, transform.position); } var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = true; Destroy(gameObject); gsscript.popped = gsscript.popped + 1; }
private void tappedHandler(object sender, EventArgs e) { gsscript.popped = gsscript.popped + 1; if (popSound) { AudioSource.PlayClipAtPoint(popSound, transform.position); } var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); //get the component for this ps.good = true; // right now it is good or bad bool, but we can make it into an integer if we want varying score results Destroy(gameObject); }
void OnCollisionEnter2D(Collision2D target) { // safeguard: check if the audio clip is assigned if (target.gameObject.tag == "Wall") { //print ("Test"); gsscript.liters = gsscript.liters + 1; //purple gets liter added Vector3 temp = new Vector3(0, 0.2f, 0); water.transform.position += temp; // purple water level goes up var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = false; Destroy(this.gameObject); // // // } if (target.gameObject.tag == "Ball") { this.GetComponent <Rigidbody2D>().AddForce(0.1f * Random.insideUnitCircle); } if (target.gameObject.tag == "Fish") { //gsscript2.lostbubbles = gsscript2.lostbubbles + 1; gsscript.liters = gsscript.liters + 0.25f; //purple gets slight penatly with .25 liters added Vector3 temp = new Vector3(0, -0.2f, 0); water.transform.position += temp; //purple water level goes up var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = true; Destroy(this.gameObject); } if (target.gameObject.tag == "BlueFish") { //gsscript2.liters = gsscript2.liters - 1; //blue recovers bubble gsscript.liters = gsscript.liters + 1; //purple water level goes up Vector3 temp = new Vector3(0, 0.2f, 0); //Vector3 temp2 = new Vector3(0,-0.2f,0); //water2.transform.position += temp2; // blue water goes down water.transform.position += temp; //purple water goes up var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = false; Destroy(this.gameObject); } if (target.gameObject.tag == "Sponge") { gsscript.liters = gsscript.liters - 1; //purple water level goes down Vector3 temp = new Vector3(0, 0.2f, 0); //Vector3 temp2 = new Vector3 (0, -0.2f, 0); water.transform.position -= temp; //purple goes down var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = true; Destroy(this.gameObject); } if (collisionSound) { // simple audio clip playback AudioSource.PlayClipAtPoint(collisionSound, transform.position); } }
// Collision handling: make a bouncing sound when hit a wall void OnCollisionEnter2D(Collision2D target) { // safeguard: check if the audio clip is assigned if (target.gameObject.tag == "Wall") { //print ("Test"); lit += 1; //blue team gets a liter added Vector3 temp = new Vector3(0, 0.2f, 0); water.transform.position += temp; //blue water level moves up var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); ps.good = false; Destroy(this.gameObject); } if (target.gameObject.tag == "BlueFish") { lit += 0.25f; //blue team gets slight penalty of .25 liters Vector3 temp = new Vector3(0, -0.2f, 0); water.transform.position += temp; //blue water level goes down var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); //get the component for this ps.good = true; // right now it is good or bad bool, but we can make it into an integer if we want varying score results Destroy(this.gameObject); } if (target.gameObject.tag == "Fish") { lit += 1; //blue gets a liter added Vector3 temp = new Vector3(0, 0.2f, 0); water.transform.position += temp; //blue goes up var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); //get the component for this ps.good = false; // right now it is good or bad bool, but we can make it into an integer if we want varying score results Destroy(this.gameObject); } if (target.gameObject.tag == "Sponge") { lit -= 1; //blue gets a liter added //gsscript2.lostbubbles = gsscript2.lostbubbles - 1; //purple recovers a bubble Vector3 temp = new Vector3(0, 0.2f, 0); //Vector3 temp2 = new Vector3 (0, -0.2f, 0); water.transform.position -= temp; //blue goes down //water2.transform.position += temp2; //purple goes down var obj2 = Instantiate(pointss) as Transform; obj2.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0); ps = obj2.GetComponent <popstuff>(); //get the component for this ps.good = true; // right now it is good or bad bool, but we can make it into an integer if we want varying score results Destroy(this.gameObject); } if (target.gameObject.tag == "Ball") { this.GetComponent <Rigidbody2D>().AddForce(0.1f * Random.insideUnitCircle); } }