/** * Destroy the game object that triggered the collision. */ private void DestroyBrick() { GameObject prefab = Instantiate(brokenBrick); prefab.transform.position = gameObject.transform.position; AudioService.PlayOneShot(prefab, "Break Brick"); Destroy(gameObject); }
private void OnBecameVisible() { if (hasBeenRun == false) { AudioService.PlayOneShot(gameObject, "Player Land"); Destroy(gameObject, 2.5f); hasBeenRun = true; } }
/** * {inheritDoc} */ public override void Kill() { if (isAlive == true) { AudioService.PlayOneShot(gameObject, "Monster Die"); DisableMotion(); base.Kill(); } }
/** * Play an audio event given its name. */ private void PlayAudioShot(string eventName) { if (eventName != currentEvent) { StopAudioLoop(); AudioService.PlayOneShot(gameObject, eventName); currentEvent = eventName; } }
/** * {inheritDoc} */ public override void Damage() { if (isAlive == true) { isAlive = false; AudioService.PlayOneShot(gameObject, "Monster Hurt"); DisableMotion(); DisableColliders(); AddDamageForce(); } }
/** * Fired when an object collides with the finish line. */ private void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.CompareTag("Player")) { GameObject target = collider.gameObject; var player = target.GetComponent <PlayerController>(); if (player != null && !player.hasWon) { GetComponent <Animator>().SetBool("isActive", true); AudioService.PlayOneShot(gameObject, "Player Win"); player.DeclareWinner(); } } }
/** * Handle collisions of the player with a Koopa's shell. This * causes the shell to move fast from side to side or stop its * movement if it was already moving. */ private void OnShieldCollision(Collision2D collision) { KoopaController koopa = GetComponent <KoopaController>(); ContactPoint2D contact = collision.GetContact(0); if (!koopa.wasPropeled) { AudioService.PlayOneShot(gameObject, "Shell Collide"); koopa.StartPropulsion(15.0f * contact.normal.x); } else if (koopa.wasPropeled && contact.normal.y < 0.5f) { AudioService.PlayOneShot(gameObject, "Shell Collide"); koopa.StopPropulsion(); } }
private void OnEnable() { AudioService.PlayOneShot(gameObject, "Activate Extralife"); }
private void OnEnable() { AudioService.PlayOneShot(gameObject, "Collect Points"); }
/** * Activate the power-up when collected. */ protected override void CollectPowerup(Collider2D collider) { GetColliderPlayer(collider).ActivateMushroomPowers(); AudioService.PlayOneShot(gameObject, "Collect Mushroom"); base.CollectPowerup(collider); }
/** * {inheritDoc} */ public override void OnHeadCollision() { AudioService.PlayOneShot(gameObject, "Shell Collide"); stoppedTime = Time.time; ActivateShell(); }
private void OnEnable() { AudioService.PlayOneShot(gameObject, "Activate Mushroom"); }
private void OnEnable() { AudioService.PlayOneShot(gameObject, "Activate Flower"); }
private void OnEnable() { AudioService.PlayOneShot(gameObject, "Player Fire"); Destroy(gameObject, 2.5f); }
/** * Activate the power-up when collected. */ protected override void CollectPowerup(Collider2D collider) { AudioService.PlayOneShot(gameObject, "Collect Extralife"); base.CollectPowerup(collider); }