Ejemplo n.º 1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.O) && Id == 0 || Input.GetKeyDown(KeyCode.P) && Id == 1)
        {
            Die();
        }


        float vertical = ReInput.players.GetPlayer(Id).GetAxisRaw("Vertical");


        _bubblesAnimator.GetComponent <SpriteRenderer>().enabled = (Mathf.Abs(vertical) > 0.5f);
        ParticleSystem system = _bubblesAnimator.GetComponentInChildren <ParticleSystem>();

        if (system != null)
        {
            if ((Mathf.Abs(vertical) > 0.5f) && !system.isEmitting)
            {
                system.Play();
            }
            else if (Mathf.Abs(vertical) < 0.5f && system.isEmitting)
            {
                system.Stop();
            }
        }

        if (Mathf.Abs(vertical) > 0.5f)
        {
            if (!_playingSound)
            {
                _playingSound = true;
                _audioRemote  = AudioManager.PlaySound("Accelerate");
            }
        }
        else
        {
            if (_playingSound)
            {
                _audioRemote.FadeOut();
                _playingSound = false;
            }
        }

        if (!Invincible)
        {
            return;
        }

        _currentInvincibilityTime += Time.deltaTime;
        if (_currentInvincibilityTime > _invincibilityDuration)
        {
            //Stop animation
            AnimationController.SetBool("Damaged", false);
            Invincible = false;
        }
    }
Ejemplo n.º 2
0
    IEnumerator DelayOnSpawn()
    {
        yield return(new WaitForSeconds(DelayBeforeSpawn));

        foreach (PlayAnimation animator in Animators)
        {
            animator.PlayAnim();
        }

        AudioRemote remote = AudioManager.PlaySound("Bubbles");

        yield return(new WaitForSeconds(DelayBeforeBubbles));

        remote.FadeOut();
        foreach (PlayAnimation animator in Animators)
        {
            animator.StopAnim();
        }
        SpawnBubbles();
    }