IEnumerator Attack(bool ranged) { _attacking = true; _muzzleFlash._active |= (_range > 1); _pT._targetPos = transform.position; PlayerTurn._underAttack = true; _rotating = true; _anim.SetBool("Attack", true); var x = transform.position.x + (_player.position.x - transform.position.x) / 2; var z = transform.position.z + (_player.position.z - transform.position.z) / 2; _midPoint.transform.position = new Vector3(x, 0, z); if (ranged) { _cam.EnableShotCam(); } yield return(new WaitForSeconds(0.88f)); _calcDam.CalculateChance(); _calcDam.Damage(); _playerAnim.SetBool("Hit", true); yield return(new WaitForSeconds(0.32f)); _anim.SetBool("Attack", false); _playerAnim.SetBool("Hit", false); yield return(new WaitForSeconds(1.0f)); _attacking = false; _rotating = false; PlayerTurn._underAttack = false; _actionsRemaining--; }
//Funciton to call when attack is submitted IEnumerator Attack() { //Disable targetting UI _targetedEnemy.DisableTarget(); //Get midpoint info and move Camera to location var x = transform.position.x + (_targetPos.x - transform.position.x) / 2; var z = transform.position.z + (_targetPos.z - transform.position.z) / 2; _midPoint.transform.position = new Vector3(x, 0, z); _cam._playerTarget = _targetPos; _cam.EnableShotCam(); //Deduct AP and minimize/reset UI _ap -= _attackCost; _combatUI.UpdateAP(); _combatUI.DeactivateButtons(false); _attackToggle = false; _attacking = true; //Allow time for the camera to move yield return(new WaitForSeconds(0.4f)); //Check what kind of attack was submitted switch (_attackType) { case 0: print("Error - no attack type selected"); break; case 1: print("Peow!"); _anim.SetBool("Attack", true); _muzzleFlash._active = true; break; case 2: print("Chop!"); _anim.SetBool("Attack", true); break; default: print("Error - no attack type selected"); break; } yield return(new WaitForSeconds(0.75f)); _calcDam.Damage(); _enemyAnim.SetBool("Hit", true); yield return(new WaitForSeconds(0.75f)); _anim.SetBool("Attack", false); _enemyAnim.SetBool("Hit", false); //Wait for animations to finish && re-enable input yield return(new WaitForSeconds(0.5f)); _attacking = false; }