IEnumerator Attack() { aSourceWeapon = Managers.player.currentWeapon.gameObject.GetComponent <AudioSource>(); Collider weaponCollider = Managers.player.currentWeapon.GetComponent <Collider>(); WeaponDamage wd = Managers.player.currentWeapon.GetComponent <WeaponDamage>(); attack = true; Managers.player.moveBlock = true; //Managers.player.myAnimator.SetFloat("speed", 0); Managers.player.myAnimator.SetTrigger("AttackRight"); yield return(new WaitForSeconds(0.42f)); //Начало нанесения урона if (weaponCollider != null) { weaponCollider.enabled = true; } startDamage = true; //yield return new WaitForSeconds(0.1f); if (!aSourceWeapon.isPlaying) { aSourceWeapon.Play(); //Звук удара } yield return(new WaitForSeconds(0.35f)); //Конец нанесения урона if (weaponCollider != null) { weaponCollider.enabled = false; } startDamage = false; yield return(new WaitForSeconds(0.37f)); //Завершение анимации if (wd != null) { wd.ClearDamageList(); } attack = false; Managers.player.moveBlock = false; }
IEnumerator AttackState() { AudioSource aSrcWeapon = thisNPC.currentWeapon.gameObject.GetComponent <AudioSource>(); Collider weaponCollider = thisNPC.currentWeapon.GetComponent <Collider>(); WeaponDamage wd = thisNPC.currentWeapon.GetComponent <WeaponDamage>(); if (thisAnimator.GetFloat("speed") > 0) { thisAnimator.SetFloat("speed", 0.0f); } thisAgent.isStopped = true; yield return(new WaitForSeconds(0.1f)); thisAnimator.SetTrigger("Attack"); yield return(new WaitForSeconds(0.25f)); //Начало нанесения урона if (weaponCollider != null) { weaponCollider.enabled = true; } if (!aSrcWeapon.isPlaying) { aSrcWeapon.Play(); //Звук удара } yield return(new WaitForSeconds(0.3f)); //Конец нанесения урона if (weaponCollider != null) { weaponCollider.enabled = false; } if (wd != null) { wd.ClearDamageList(); } yield return(new WaitForSeconds(0.25f)); StartCoroutine(BattleModeState()); }