Esempio n. 1
0
        public virtual IEnumerator Dynamic()
        {
            yield return(new WaitForEndOfFrame());

            IWeaponAnimator   weaponAnimator       = GetComponent <IWeaponAnimator>();
            IEnumerator       setSpreadIEnumerator = null;
            WeaponActionState lastState            = WeaponActionState.Idle;

            while (true)
            {
                if (lastState != weaponAnimator.GetActiveState())
                {
                    for (int i = 0; i < animationStates.Length; i++)
                    {
                        AnimationState animationState = animationStates[i];
                        if (animationState.state == weaponAnimator.GetActiveState())
                        {
                            if (setSpreadIEnumerator != null)
                            {
                                StopCoroutine(setSpreadIEnumerator);
                            }
                            setSpreadIEnumerator = SetSpread(animationState.spread, animationState.smooth);
                            StartCoroutine(setSpreadIEnumerator);
                            lastState = weaponAnimator.GetActiveState();
                            break;
                        }
                    }
                }
                yield return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Do shoot.
        /// </summary>
        protected virtual void DoShoot()
        {
            if (spreadProperties != null)
            {
                spreadProperties.ApplySpread(weaponAnimator.GetActiveState());
            }

            switch (bulletType)
            {
            case BulletType.RayBullet:
                RayBulletShootingProcess();
                break;

            case BulletType.PhysicsBullet:
                PhysicsBulletShootingProcess();
                break;
            }

            AudioClip sound = soundProperties.GetRandomFireSound();

            if (sound != null)
            {
                audioSource.PlayOneShot(sound);
            }

            weaponReloading.BulletSubtraction();
            AttackParticleEffect();

            if (spreadProperties != null)
            {
                spreadProperties.ResetRotation();
            }
        }