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); } }
/// <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(); } }