Exemplo n.º 1
0
    public void Fire()
    {
        if (IsCoolingDown || !enabled)
        {
            return;
        }
        if (!Ammo)
        {
            Debug.LogError("No ammo ref is set on gun " + name, gameObject);
            return;
        }

        if (audioAction)
        {
            audioAction.audioCollection = HasAmmo ? gunData.fireSound : gunData.dryShotSound;
            audioAction.Play();
        }


        if (HasAmmo)
        {
            SpendAmmo();
            CreateBullet(Vector2.zero, RandomSpreadAngle);
        }
        else
        {
            onTryFireWhenEmpty.Invoke();
        }

        _cooldownTimer = 0;
    }
Exemplo n.º 2
0
        public override void OnEnter()
        {
            // get the audio action component
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)
            {
                Finish();
                return;
            }

            _audioAction = go.GetComponent <AudioAction>();

            if (_audioAction == null)
            {
                Finish();
                return;
            }

            _audioAction.Play();
            Finish();
        }