/// <summary> /// Update is called every frame, if the MonoBehaviour is enabled. /// </summary> protected virtual void Update() { if (!isAttacking) { if (UInput.GetButtonDown(INC.ATTACK)) { weaponAnimator.SetAttack(1); StartCoroutine(DoAttack(normalAttack)); } else if (Input.GetKeyDown(specialAttackKey)) { weaponAnimator.SetAttack(2); StartCoroutine(DoAttack(specialAttack)); } } else if (isAttacking && (Time.time - delayTimer) >= currentDelay) { isAttacking = false; } }
/// <summary> /// Shooting system processing. /// </summary> protected virtual IEnumerator ShootingProcessing() { WaitForSeconds updateDelay = new WaitForSeconds(delay); WaitForEndOfFrame endOfFrame = new WaitForEndOfFrame(); while (true) { if (!weaponReloading.BulletsIsEmpty() && !weaponReloading.IsReloading()) { if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) || fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK)) { DoShoot(); yield return(updateDelay); } else if (fireMode == Mode.Queue && UInput.GetButtonDown(INC.ATTACK)) { for (int i = 0; i < queueCount; i++) { DoShoot(); weaponAnimator.SetAttack(1); yield return(endOfFrame); weaponAnimator.SetAttack(-1); yield return(updateDelay); } } } else if (UInput.GetButtonDown(INC.ATTACK)) { AudioClip sound = soundProperties.GetRandomEmptySound(); if (sound != null) { audioSource.PlayOneShot(sound); } weaponAnimator.SetAttack(0); yield return(endOfFrame); weaponAnimator.SetAttack(-1); } yield return(null); } }