void OnTriggerEnter2D(Collider2D collider2D) { Debug.Log(collider2D.tag); if (collider2D.tag == waterTag) { this.maxSpeed -= maxSpeed * (waterSlowDownPercentage / 100); } else if (collider2D.tag.Contains("Enemy")) { this.gameObject.SetActive(false); AudioManager.PlayAudio(playerDestroyed); playerExplosion.transform.position = this.gameObject.transform.position; playerExplosion.SetActive(true); GameOverManager.EndGame(); } else if (collider2D.tag == "SpeedPowerUp") { StartCoroutine(fasterMovementForNseconds(5f)); collider2D.gameObject.SetActive(false); AudioManager.PlayAudio(powerUpPickUP); } else if (collider2D.tag == "ReloadPowerUp") { playerBulletManager.StartCoroutine(playerBulletManager.fasterReloadForNSeconds(5f)); collider2D.gameObject.SetActive(false); AudioManager.PlayAudio(powerUpPickUP); } }
void OnTriggerEnter2D(Collider2D collider2D) { if (collider2D.tag.Contains("Bullet")) { GameOverManager.EndGame(); } }
/// <summary> /// Reduces hp by amt and clamps hp from 0 to maxHP, and causes game to end if hp==0 /// </summary> /// <param name="amt">Quantity of damage to take, or negative value to heal</param> public override void TakeDamage(float amt) { base.TakeDamage(amt); if (hp == 0) { gameOverManager.EndGame(!playerGoal); } }
IEnumerator ExecuteSteps() { foreach (int action in mainSteps) { if (action == 0) // move forward { MoveForward(); yield return(new WaitForSeconds(0.7f)); } else if (action == 1) // turn left { Debug.Log("light2"); Turn(true); yield return(new WaitForSeconds(0.7f)); } else if (action == 2) // turn right { Turn(false); yield return(new WaitForSeconds(0.7f)); } else if (action == 3) // toggle light { toggleLight(); yield return(new WaitForSeconds(0.7f)); } /*else if (action == 4) { // run P1 * foreach (int act in procSteps) { * if (act == 0) { // move forward * MoveForward (); * } else if (act == 1) { // turn left * Turn (true); * } else if (act == 2) { // turn right * Turn (false); * } else if (act == 3) { // toggle light * toggleLight (); * } * yield return new WaitForSeconds (0.7f); // pause for 1 second bewtween each step * } * }*/ } // TODO: check success if (Success()) { gameManager.EndGame(); Debug.Log("Level complete!"); } else { alertTextUI = false; gameManager.AlertTextUI(); Debug.Log("Didn't light all the targets!"); } }
public void OnExplode() { if (gameObject.tag == "Player") { gameOverManager.EndGame(); } Destroy(gameObject); if (deathSound) { AudioSource.PlayClipAtPoint(deathSound, transform.position); } var t = transform; for (int i = 0; i < totalParts; i++) { t.TransformPoint(0, -100, 0); BodyPart clone = Instantiate(bodyPart, t.position, Quaternion.identity) as BodyPart; clone.rigidbody2D.AddForce(Vector3.right * Random.Range(-50, 50)); clone.rigidbody2D.AddForce(Vector3.up * Random.Range(100, 400)); } }
IEnumerator ExecuteSteps() { foreach (int action in mainSteps) { if (action == 0) // move forward { MoveForward(); yield return(new WaitForSeconds(0.7f)); } else if (action == 1) // turn left { Debug.Log("light2"); Turn(true); yield return(new WaitForSeconds(0.7f)); } else if (action == 2) // turn right { Turn(false); yield return(new WaitForSeconds(0.7f)); } else if (action == 3) // toggle light { toggleLight(); yield return(new WaitForSeconds(0.7f)); } else if (action == 4) // run P1 { foreach (int act in procSteps) { if (act == 0) // move forward { MoveForward(); yield return(new WaitForSeconds(0.7f)); } else if (act == 1) // turn left { Turn(true); yield return(new WaitForSeconds(0.7f)); } else if (act == 2) // turn right { Turn(false); yield return(new WaitForSeconds(0.7f)); } else if (act == 3) // toggle light { toggleLight(); yield return(new WaitForSeconds(0.7f)); } else if (act == 4) // run p1 { while (test == true) { foreach (int d in procSteps) { // if (d == 0) // move forward { MoveForward(); yield return(new WaitForSeconds(0.7f)); } else if (d == 1) // turn left { Turn(true); yield return(new WaitForSeconds(0.7f)); } else if (d == 2) // turn right { Turn(false); yield return(new WaitForSeconds(0.7f)); } else if (d == 3) // toggle light { toggleLight(); yield return(new WaitForSeconds(0.7f)); } if (Success()) { gameManager.EndGame(); Debug.Log("Level complete!"); test = false; } } } } } } } // check success if (Success()) { gameManager.EndGame(); Debug.Log("Level complete!"); } else { Debug.Log("Didn't light all the targets!"); } }