Ejemplo n.º 1
0
 public void PlaySound(AudioToPlay toPlay)
 {
     if (toPlay == AudioToPlay.Dash)
     {
         audioS.clip = dash;
         audioS.Play();
     }
     else if (toPlay == AudioToPlay.Pistol)
     {
         audioS.clip = pistol;
         audioS.Play();
     }
     else if (toPlay == AudioToPlay.Shotgun)
     {
         audioS.clip = shotgun;
         audioS.Play();
     }
     else if (toPlay == AudioToPlay.M4)
     {
         audioS.clip = m4;
         audioS.Play();
     }
     else if (toPlay == AudioToPlay.PowerUp)
     {
         audioS.clip = powerUp;
         audioS.Play();
     }
     else if (toPlay == AudioToPlay.SlimeDie)
     {
         audioS.clip = slimeDie;
         audioS.Play();
     }
 }
    void DoDash()
    {
        anime.SetBool("Dash", true);
        player.constraints = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation;
        player.AddForce(new Vector2(scale.x * dashForce, 0), ForceMode2D.Impulse);

        // de esta forma se comprueba hacia el lado al que mira el jugador para saber que movimiento debe restringir
        if (scale.x < 0)
        {
            movRestrictionL = true;
        }
        else
        {
            movRestrictionR = true;
        }
        dash = false;
        AudioToPlay audio = GetComponent <AudioToPlay>();

        if (audio != null)
        {
            audio.SendAudioToPlay();
        }
        //Tiempo en realizar el dash 0.15.
        Invoke("DashCast", 0.15f);
    }
Ejemplo n.º 3
0
    public void PlaySong(AudioToPlay audio)
    {
        switch (audio)
        {
        case AudioToPlay.GameOver:
            source.PlayOneShot(gameOver);
            break;

        case AudioToPlay.Dash:
            source.PlayOneShot(dash);
            break;

        case AudioToPlay.Destroy:
            source.PlayOneShot(destroy);
            break;

        case AudioToPlay.SongA:
            source.clip = songA;
            source.Play();
            break;

        case AudioToPlay.SongB:
            source.clip = songB;
            source.Play();
            break;

        case AudioToPlay.OneUp:
            source.PlayOneShot(oneUp);
            break;
        }
    }
Ejemplo n.º 4
0
 //Método que destruye al gameObject al morir.
 public void Dead()
 {
     DropObjectOnDeath drop = GetComponent<DropObjectOnDeath>();
     if (drop != null) drop.DropObject();
     DestroyParent destroy = GetComponent <DestroyParent>();
     if (destroy != null) destroy.DestroyP();
     AudioToPlay audio = GetComponent<AudioToPlay>();
     if (audio != null) audio.SendAudioToPlay(); 
     if (tag == "Player") GameManager.instance.Respawn();
     else Destroy(gameObject);
 }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        //cacheo de componentes
        fireB = GetComponent <Rigidbody2D>();
        AudioToPlay audio = GetComponent <AudioToPlay>();

        if (audio != null)
        {
            audio.SendAudioToPlay();
        }
    }
Ejemplo n.º 6
0
    void Start()
    {
        GameManager.instance.InvulnerablePlayer();
        AudioToPlay audio = GetComponent <AudioToPlay>();

        if (audio != null)
        {
            audio.SendAudioToPlay();
        }
        Invoke("ShieldDuration", shieldDuration);
    }