Ejemplo n.º 1
0
    public void PullTrigger()
    {
        if ((triggerReseted == true || isAuto == true) && AmmoInMag > 0 && fireRateTimer + TimeBetweenShots < Time.time)
        {
            // Calculate new FireRate
            if(increasingFireRate)
            {
                FireRateIndex -= (int)Mathf.Floor((Time.time - fireRateTimer) / ( dynamicTimeBtwShots[FireRateIndex] + fireRateDecreaseTime));
                FireRateIndex++;
            }

            // Shoot Bullet
            patternInstance.Shoot(bulletData, self.transform, barrelOffSet);

            // Consume Ammo
            AmmoInMag -= ammoConsumption;
            
            // Play MuzzleFlash Animation
            weapon.PlayarFiringAnimations(muzzleFashAnimation.Next());
            AudioManager.Instance.PlaySound(fireAudio);

            charge++;
            triggerReseted = false;
            fireRateTimer = Time.time;
        }
    }
    private IEnumerator End()
    {
        foreach (var frame in end_animation.Next())
        {
            SpriteRenderer.sprite = frame;
            yield return(new WaitForSeconds(animationSpeed));
        }

        SpriteRenderer.sprite = null;
    }
    private IEnumerator Begin()
    {
        foreach (var frame in begin_animation.Next())
        {
            SpriteRenderer.sprite = frame;
            yield return(new WaitForSeconds(animationSpeed));
        }

        middleRutine = StartCoroutine(Middle());
        StartCoroutine(DamageArea());
    }