private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Dude") { RubberDuckMovement duck = col.gameObject.GetComponent <RubberDuckMovement> (); if (!duck.attachVortex && !duck.alreadyVortex) { if (ducksAttached < 11) { //attach duck.attachVortex = true; duck.alreadyVortex = true; col.gameObject.GetComponent <SpringJoint2D> ().enabled = true; duck.tornadoReset(); if (duck.hitGround) { controlScript.ducksDead--; } //set duck index duckList [ducksAttached] = col.gameObject; movingConnectors [ducksAttached] = freeConnectors [ducksAttached]; movingConnectors [ducksAttached].transform.position = new Vector3(movingConnectors[ducksAttached].transform.position.x, duck.gameObject.transform.position.y, 0); col.gameObject.GetComponent <SpringJoint2D> ().connectedBody = movingConnectors [ducksAttached].GetComponent <Rigidbody2D> (); ducksAttached++; } } } }
//Remove powerUp from view, apply if player caught it, otherwise do nothing public void removePowerUp() { if (caught) //Apply the powerup { if (powerType == 2) //Big Mode { effectPS.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); GetComponent <SpriteRenderer> ().enabled = false; GetComponent <CapsuleCollider2D> ().enabled = false; createCaughtEffect(1, 250); if (!controlScript.fallingDude.GetComponent <Bouncer> ().inBigMode() && !controlScript.attachedDude.GetComponent <Bouncer> ().inBigMode()) { controlScript.toggleBigMode(true); fText = PoolingManager.pooler.getPooledObject(7); fText.SetActive(true); fText.GetComponent <FloatingText> ().createBigModeText(GameObject.Find("Teeter(Player)").transform.position); controlScript.delayedResetFText(fText); if (gameObject.activeInHierarchy) //This is here because of repeat collisions, try to fix those instead of this condition { StartCoroutine(endBigMode()); } GameObject.Find("SceneManager").GetComponent <SmScript>().setActivePowerUp(this.gameObject); teeterScript.playPowerUpSound(powerUpSound, .35f); } else { disablePowerUp(); teeterScript.playPowerUpSound(powerUpSound); givePointsInsteadOfPowerUp(250); } } else if (powerType == 1) //Bomb { effectPS.Stop(); disablePowerUp(); createCaughtEffect(2, 250); if (!controlScript.gameObject.GetComponent <BalloonMovement> ().bombIsSet()) { controlScript.gameObject.GetComponent <BalloonMovement> ().setBombTemp(); fText = PoolingManager.pooler.getPooledObject(7); fText.SetActive(true); fText.GetComponent <FloatingText> ().createBombSetText(GameObject.Find("Teeter(Player)").transform.position); controlScript.delayedResetFText(fText); teeterScript.playPowerUpSound(powerUpSound); //teeterScript.playPowerUpSound (bombSound, .6f); } else { givePointsInsteadOfPowerUp(250); teeterScript.playPowerUpSound(powerUpSound); } } else if (powerType == 3) //Bird - Duck recycle { effectPS.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); GetComponent <SpriteRenderer> ().enabled = false; GetComponent <CapsuleCollider2D> ().enabled = false; createCaughtEffect(3, 250); if (!controlScript.fallingDude.GetComponent <Bouncer>().getGreenPowerUp()) { fText = PoolingManager.pooler.getPooledObject(7); fText.SetActive(true); controlScript.fallingDude.GetComponent <Bouncer> ().setGreenPowerUp(true); if (checkDudeType()) //Bird Green powerup { greenType = 1; fText.GetComponent <FloatingText> ().createSpringText(GameObject.Find("Teeter(Player)").transform.position); if (controlScript.springAnchor.activeInHierarchy) { if (controlScript.springAnchor.GetComponent <BungieController> ().leavingScreen) { controlScript.springAnchor.GetComponent <BungieController> ().resetAnchor(); } } controlScript.springAnchor.SetActive(true); controlScript.powerUpActive = true; if (gameObject.activeInHierarchy) //This is here because of repeat collisions, try to fix those instead of this condition { StartCoroutine(endSpring()); } teeterScript.playPowerUpSound(powerUpSound, .35f); } else //Ducks Green powerup { greenType = 2; fText.GetComponent <FloatingText> ().createVortexText(GameObject.Find("Teeter(Player)").transform.position); controlScript.powerUpActive2 = true; teeterScript.playPowerUpSound(powerUpSound, .35f); teeterScript.playPowerUpSound(whooshSound); int rand = Random.Range(4, 7); for (int i = 0; i < rand; i++) { if (controlScript.deadDucks.Count != 0) { if (controlScript.deadDucks.Peek() != null) //Pop a previously dead duck from the queue and launch into the air { GameObject duck = (GameObject)controlScript.deadDucks.Dequeue(); duck.GetComponent <Rigidbody2D> ().AddForce(duck.transform.up * (Random.Range(.7f, 1.01f) * 5.15f), ForceMode2D.Impulse); duck.GetComponent <SpriteRenderer> ().sortingOrder = 5; RubberDuckMovement duckScript = duck.GetComponent <RubberDuckMovement> (); duckScript.hitGround = false; duckScript.delayLayerChange(); controlScript.ducksDead--; if (controlScript.ducksDead < 0) { controlScript.ducksDead = 0; } // Debug.Log ("-1 dead duck: " + controlScript.ducksDead.ToString () + " dead ducks."); // Debug.Log (controlScript.deadDucks.Count.ToString() + " ducks in the queue"); } } } controlScript.powerUpActive2 = false; controlScript.fallingDude.GetComponent <Bouncer> ().setGreenPowerUp(false); } controlScript.delayedResetFText(fText); GameObject.Find("SceneManager").GetComponent <SmScript> ().setActiveSpringPowerUp(this.gameObject); } else { disablePowerUp(); teeterScript.playPowerUpSound(powerUpSound); givePointsInsteadOfPowerUp(250); } } else //Might need later { } } else { GameObject.Find("Teeter(Player)").GetComponent <TeeterBase> ().playPowerUpSound(powerHitGroundSound); disablePowerUp(); controlScript.displayPowerMissEffect(transform.position, powerType); } }