//After collision with a falling dude, bounce the other dude and set up conditions/variables for each dude private void bounceDude(Collision2D col) { // ParticleSystem ps; // if(teeterSide == 'l'){ // ps = Instantiate(landingPS, new Vector2(transform.position.x + .2f, transform.position.y + .1f), Quaternion.identity); // }else{ // ps = Instantiate(landingPS, new Vector2(transform.position.x - .2f, transform.position.y + .1f), Quaternion.identity); // } // Destroy (ps, .4f); checkHit(col); //Saw 1/2 if (!controlScript.gameOver) { bouncerScript.setAttached('l', false); bouncerScript.setAttached('r', false); bouncerScript.setParent(null); bungieScript.dude = dudeOnSaw; dudeOnSaw = col.gameObject; bouncerScript = dudeOnSaw.GetComponent <Bouncer> (); bouncerScript.setParent(saw); bouncerScript.setTeeterCol(false); bouncerScript.setBalloonCol(false); bouncerScript.switchPlatformCollider(false); if (teeterSide == 'l') { bouncerScript.setAttached('l', true); } else { bouncerScript.setAttached('r', true); } source.PlayOneShot(bounceSound, .75f); // Play the bounce sound } }
// Update is called once per frame void Update() { if (controlScript == null) { controlScript = control.GetComponent <Controller>(); } //Update the position of the seesaw and rider if (!controlScript.gameOver) { if (dudeOnSaw != null && bouncerScript != null) { placeDude(); //Position the rider to stand on the seesaw } else { dudeOnSaw = controlScript.attachedDude; bouncerScript = dudeOnSaw.GetComponent <Bouncer> (); } checkBounds(); //Make sure the seesaw remains inside the bounds of the game } else //Keeps dude on saw from falling when other dude dies { //dudeOnSaw.GetComponent<Bouncer>().setTeeterCol(true); bouncerScript.setTeeterCol(true); } calcVelocity(); if (SmScript.gameManager.showingAd) //Stop music playing before an ad { if (source.isPlaying) { source.Stop(); } } }