private void Update() { if (colliding) { if (this.gameObject.tag == "DownPipe") { if ((Input.GetKeyDown(KeyCode.S) || (Input.GetKeyDown(KeyCode.DownArrow)))) { sfx.PlaySoundEffect(pipeSound); CameraControl cameraControl = player.gameObject.GetComponent <CameraControl>(); var players = GameObject.FindGameObjectsWithTag("Player"); Debug.Log(players.Length); if (players.Length == 2) { Vector3 offsetPos = new Vector3 { x = warpTarget.position.x, y = warpTarget.position.y + .50f, z = warpTarget.position.z }; players[1].gameObject.transform.position = offsetPos; } players[0].gameObject.transform.position = warpTarget.position; } } else { sfx.PlaySoundEffect(pipeSound); CameraControl cameraControl = player.gameObject.GetComponent <CameraControl>(); var players = GameObject.FindGameObjectsWithTag("Player"); Debug.Log(players.Length); if (players.Length == 2) { Vector3 offsetPos = new Vector3 { x = warpTarget.position.x, y = warpTarget.position.y + .50f, z = warpTarget.position.z }; players[1].gameObject.transform.position = offsetPos; } players[0].gameObject.transform.position = warpTarget.position; } } }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (canHit) { // Bounce the block up slightly transform.position += Vector3.up * Time.deltaTime; yield return(new WaitForSeconds(0.1f)); transform.position = originalPos; // Play sound effect and change sprite to "after hit" sprite sfx.PlaySoundEffect(powerUpSound); ChangeSprite(); canHit = false; // can't hit again // Animate our "fake star" to appear to come out of the block FakeStar.GetComponent <Animator>().Play("FakeStar"); yield return(new WaitForSeconds(1.0f)); // Destroy the "fake star" object and instantiate the real star Destroy(FakeStar); Instantiate(Star, Spawn.transform.position, Quaternion.identity); } } }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (hitCount < 8) { // bounce block up and down transform.position += Vector3.up * Time.deltaTime; yield return(new WaitForSeconds(0.1f)); transform.position = originalPos; // create coin, play sound effect, increment hit counter CreateCoin(); sfx.PlaySoundEffect(coinSfx); hitCount++; // add scores ScoreKeeping.scoreValue += 200; CoinTracker.coinValue += 1; } // if hit count has maxed out, change sprite to "after hit sprite" else if (hitCount >= 8) { ChangeSprite(); } } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { sfx.PlaySoundEffect(pipeSound); } }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (canPlay) { // raise the flag from the castle anim.Play("FlagRaise"); anim.Play("FlagRaise_Level2"); canPlay = false; // animate the individual fireworks and play their sound effects sfx.PlaySoundEffect(fireworksSound); fireworks.Play("Fireworks"); yield return(new WaitForSeconds(0.9f)); // wait a small bit to show animation fireworks.gameObject.SetActive(false); // destroy object once done sfx.PlaySoundEffect(fireworksSound); fireworks2.Play("Fireworks"); yield return(new WaitForSeconds(0.9f)); fireworks2.gameObject.SetActive(false); sfx.PlaySoundEffect(fireworksSound); fireworks3.Play("Fireworks"); yield return(new WaitForSeconds(0.9f)); fireworks3.gameObject.SetActive(false); sfx.PlaySoundEffect(fireworksSound); fireworks4.Play("Fireworks"); yield return(new WaitForSeconds(0.9f)); fireworks4.gameObject.SetActive(false); sfx.PlaySoundEffect(fireworksSound); fireworks5.Play("Fireworks"); yield return(new WaitForSeconds(0.9f)); fireworks5.gameObject.SetActive(false); // CameraControl.lockX = false; } } yield return(null); }
void HitInternal() { sfx.PlaySoundEffect(breakSound); spriteRenderer.enabled = false; particleSystem.Play(); Destroy(gameObject, 0.3f); ScoreKeeping.scoreValue += 50; }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { sfx.PlaySoundEffect(coinSfx); Destroy(gameObject); ScoreKeeping.scoreValue += 200; CoinTracker.coinValue += 1; } }
void HitInternal() { if (hitCount == 0) { MoveBlock(); ChangeSprite(); CreateCoin(); sfx.PlaySoundEffect(coinSfx); ScoreKeeping.scoreValue += 200; CoinTracker.coinValue += 1; hitCount++; } }
public IEnumerator Fireballs() { float minWaitTime = 2f; float maxWaitTime = 4f; while (true) { yield return(new WaitForSeconds(Random.Range(minWaitTime, maxWaitTime))); sfx.PlaySoundEffect(fireBallSound); ShootFireball(); } }
private IEnumerator DestroyBridge() { // CameraControl.lockX = true; bowser.GetComponent <BowserController>().stoppedCoroutines = true; StopCoroutine(bowser.GetComponent <BowserController>().Fireballs()); StopCoroutine(bowser.GetComponent <BowserController>().RandomMovement()); StopCoroutine(bowser.GetComponent <BowserController>().JumpTimer()); sfx.PlaySoundEffect(bowserDiesSound); for (int i = 0; i < bridgeBlocks.Length; i++) { Destroy(bridgeBlocks[i]); yield return(new WaitForSeconds(0.05f)); } ScoreKeeping.scoreValue += 2000; // CameraControl.lockX = false; }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (canPlay) { sfx.PlayEndMusic(); sfx.PlaySoundEffect(flagSound); anim.Play("Flag_Fall"); anim.Play("FlagFall_Level3"); anim.Play("FlagFall_Level1"); canPlay = false; } } yield return(null); }
void FinalScore() { int timeRemaining = (int)TimeKeeping.timeValue; // get timer value // for the amount of time remaining, add score value and take from time value // these are the bonus coins for time remaining on the clock if (timeRemaining > 0) { ScoreKeeping.scoreValue += 10; sfx.PlaySoundEffect(coinSfx); TimeKeeping.timeValue -= 10; } else { CancelInvoke(); // once 0 is hit, stop the Invoke function StartCoroutine(ChangeScene()); } }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (canHit) { // Bounce the block up slightly transform.position += Vector3.up * Time.deltaTime; yield return(new WaitForSeconds(0.1f)); transform.position = originalPos; // Play sound effect and change sprite to "after hit" sprite sfx.PlaySoundEffect(powerUpSound); ChangeSprite(); canHit = false; // can't hit again // if the player is small, produce a red mushroom if (Player_Move.PlayerState == 0) { // Animate our "fake mushroom" to appear to come out of the block FakeMushroom.GetComponent <Animator>().Play("FakeMushroom"); yield return(new WaitForSeconds(1.0f)); // Destroy the "fake mushroom" object and instantiate the real mushroom Destroy(FakeMushroom); Instantiate(Mushroom, Spawn.transform.position, Quaternion.identity); } // if the palyer is big, produce a flower else if (Player_Move.PlayerState == 1) { // Animate our "fake mushroom" to appear to come out of the block FakeFlower.GetComponent <Animator>().Play("FakeMushroom"); yield return(new WaitForSeconds(1.0f)); // Instantiate Flower at spawn point Destroy(FakeFlower); Instantiate(Flower, Spawn.transform.position, Quaternion.identity); } } } }
IEnumerator OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { if (canHit) { // Bounce the block up slightly transform.position += Vector3.up * Time.deltaTime; yield return(new WaitForSeconds(0.1f)); transform.position = originalPos; // Play sound effect and change sprite to "after hit" sprite sfx.PlaySoundEffect(powerUpSound); ChangeSprite(); canHit = false; // can't hit again // Instantiate Flower at spawn point Instantiate(Flower, Spawn.transform.position, Quaternion.identity); } } }