IEnumerator Attack() { PlayerAnimationController.SetBool("IsAttacking", true); isAttacking = true; swordColider.enabled = true; CancelInvoke("ResetHitCombo"); switch (hitCombo) { case 0: default: PlayerAnimationController.PlayAnimation("Attack_1"); GameObject particles = Instantiate(meleeAttackParticles, particleOrigin.transform); yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_1"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); swordColider.enabled = false; yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_1"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); Destroy(particles); break; case 1: PlayerAnimationController.PlayAnimation("Attack_2"); particles = Instantiate(meleeAttackParticles, particleOrigin.transform); yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_2"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); swordColider.enabled = false; yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_2"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); Destroy(particles); break; case 2: PlayerAnimationController.PlayAnimation("Attack_3"); particles = Instantiate(meleeAttackParticles, particleOrigin.transform); yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_3"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); swordColider.enabled = false; yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Attack_3"].length * 0.5f / PlayerAnimationController.GetFloat("AttackSpeed"))); Destroy(particles); break; } PlayerAnimationController.SetBool("IsAttacking", false); isAttacking = false; hitCombo = (hitCombo + 1) % 3; if (hitCombo != 0) { Invoke("ResetHitCombo", hitComboResetDelay); } }
IEnumerator Shoot() { CancelInvoke("ResetHitCombo"); isAttacking = true; PlayerAnimationController.SetBool("IsAttacking", true); weapon.sharedMesh = null; PlayerAnimationController.PlayAnimation("Shoot"); yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Shoot"].length * 0.6f / PlayerAnimationController.GetFloat("ShootSpeed"))); Projectile projectile = Instantiate(projectilePrefab, projectileOrigin.position, Quaternion.identity); projectile.gameObject.SetActive(true); yield return(new WaitForSeconds(PlayerAnimationController.AnimationClips["Shoot"].length * 0.4f / PlayerAnimationController.GetFloat("ShootSpeed"))); weapon.sharedMesh = defaultMesh; hitCombo = (hitCombo + 1) % 3; if (hitCombo != 0) { Invoke("ResetHitCombo", hitComboResetDelay); } PlayerAnimationController.SetBool("IsAttacking", false); yield return(new WaitForSeconds(ProjectileCooldown)); isAttacking = false; }