/// <summary> /// Called when [trigger enter2 d]. /// Gestiona la perdida de escudo al chocar con una bola y al perder la partida /// </summary> /// <param name="collision">The collision.</param> private void OnTriggerEnter2D(Collider2D collision) { if (GameManager.inGame && !FreezeManager.fm.freeze) { if (collision.gameObject.tag == "Ball") { if (shield.activeInHierarchy) { shield.SetActive(false); General.Audio(fuenteAudio, escudoSonido); StartCoroutine(IEBlinking()); } else { if (!blink) { General.Audio(fuenteAudio, escudoSonido); StartCoroutine(IELose()); } } } if (!GameManager.inGame && (collision.gameObject.tag == "Right" || collision.gameObject.tag == "Left")) { sr.flipX = !sr.flipX; rb.velocity /= 3; rb.velocity *= -1; rb.AddForce(Vector3.up * 5, ForceMode2D.Impulse); } } }
/// <summary> /// Instantiantes the price. /// Genera el item de premio en la explosion de la bola /// </summary> private void InstantiantePrice() { int aleatory = BallManager.bm.AleatoryNumber(); if (aleatory == 1) { Instantiate(powerUp, transform.position, Quaternion.identity); General.Audio(fuenteAudio, itemSonido); } }
/// <summary> /// Called when [trigger enter2 d]. /// Comprueba si el item colisiona con el suelo o con un elemento que lo destruya y consiga puntos. /// </summary> /// <param name="collision">The collision.</param> private void OnTriggerEnter2D(Collider2D collision) { General.Audio(fuenteAudio, itemSonido); if (collision.gameObject.tag == "Ground") { inGround = true; Destroy(gameObject, Tiempo.ITEMSUELO); } else if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Arrow" || collision.gameObject.tag == "Ancle") { int score = Puntuacion.FRUIT; ScoreManager.sm.UpdateScore(score); PopUpManager.pm.InstanciatePopUpText(transform.position, score); GameManager.gm.fruitsCatched++; Destroy(gameObject); } }
public void SonidoExplosion() { General.Audio(fuenteAudio, explosion); }