private IEnumerator Recharge(float _rechargeTime) { m_rb.isKinematic = false; yield return(new WaitForSeconds(_rechargeTime)); m_swatterState = SwatterState.Upright; }
/// <summary> /// Slams down the swatter, in an attemot to hit the ants (players) /// </summary> private IEnumerator Slam() { m_swatterState = SwatterState.Slamming; m_rb.isKinematic = true; yield return(StartCoroutine(RotateDown())); Camera.main.GetComponent <CameraShake>().Shake(0.6f, 1, 0.8f); m_smackAudio.Play(); m_swatterState = SwatterState.Floored; checkForCollision(); yield return(new WaitForSeconds(1.5f)); StartCoroutine(RotateUp()); }
private IEnumerator RotateUp() { m_swatterState = SwatterState.Retracting; int rotatedDegrees = 0; float originalX = transform.eulerAngles.x; while (transform.eulerAngles.x > 1.5f) { transform.rotation = Quaternion.Lerp( Quaternion.Euler(originalX, transform.eulerAngles.y, transform.eulerAngles.z), Quaternion.Euler(0, transform.eulerAngles.y, transform.eulerAngles.z), (float)rotatedDegrees / 90); rotatedDegrees += 1; yield return(new WaitForSeconds(m_RetractFuration / (float)90)); } m_swatterState = SwatterState.ReCharging; StartCoroutine(Recharge(m_rechargeTime)); }