IEnumerator Parry() { if (CanParry()) { if (currentParryState == ParryState.None) { playerAnim.Play("Parry"); CustomFunctions.PlaySound(parryBubbleSound); currentParryState = ParryState.IsParrying; parryCircle.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); while (parryCircle.transform.localScale.x > 0) { parryCircle.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f) * Mathf.Exp(1.5f - parryCircle.transform.localScale.x); yield return(new WaitForSeconds(0.01f)); } } if (parryCircle.transform.localScale.x <= 0) { //print("DONE"); currentParryState = ParryState.ParryCooldown; if (parryWasSuccessful == false) { yield return(new WaitForSeconds(0.2f)); } StopParry(); } } yield break; }
public void DestroyThis() { if (hitParticlePrefab != null) { GameObject hitParticle = Instantiate(hitParticlePrefab); hitParticle.transform.position = this.transform.position; CustomFunctions.PlaySound(CustomFunctions.instance.ammoHit); Destroy(hitParticle, 1f); } Destroy(this.gameObject); }
void BounceAmmo(Collision2D collision) { if (currentNumberOfBounces < numberOfBouncesBeforeDestroying) { currentNumberOfBounces++; CustomFunctions.PlaySound(bounceSound); transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z - 180f); } else { ammoDamageZone.DestroyThis(); } }
void ApplyJumpForce() { CustomFunctions.PlaySound(CustomFunctions.instance.jumpSound); playerRigidbody.velocity = new Vector2(0f, 0f); playerRigidbody.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse); if (GetComponent <PlayerHealth>().currentHealth > 0) { anim.Play("Jump"); } /*GameObject spawnedJumpParticles = Instantiate(jumpParticlesPrefab, this.transform); * spawnedJumpParticles.transform.position = this.transform.position; * Destroy(spawnedJumpParticles, 1f);*/ }
void IHealthEntity.DoDamage(float damageAmount, GameObject playerThatShot) { if (currentHealth <= 0) //if we're playing the death anim, we dont take damage { return; } currentHealth -= damageAmount; CustomFunctions.HitPause(); CustomFunctions.PlaySound(getHitSound); if (currentHealth <= 0) { Die(playerThatShot); } }
void Shoot() { if (playerController == null) { playerController = GetComponent <PlayerController>(); } if (playerHealth == null) { playerHealth = GetComponent <PlayerHealth>(); } if (currentWeaponAction != null) { if (playerController.CanMove() || playerHealth.currentParryState == PlayerHealth.ParryState.IsParrying) { if (playerHealth.currentParryState == PlayerHealth.ParryState.IsParrying) { playerHealth.StopParry(); } if (currentWeaponState == WeaponState.ReadyToShoot) { if (currentAmmo > 0) { currentWeaponAction.Shoot(); CameraShaker.Instance.ShakeOnce(1f, 2f, 0.1f, 0.1f); CustomFunctions.PlaySound(GameManager.instance.weaponDatabase.allWeapons[currentWeapon].weaponShootSound); currentWeaponState = WeaponState.WaitingForNextShot; RemoveAmmo(); StartCoroutine(WaitForNextShot()); if (currentWeaponAction.OnShoot != null) { currentWeaponAction.OnShoot(); } } } } } }
public void TakeHitEffect(float damageAmount, GameObject playerThatShot) { if (currentParryState != ParryState.IsParrying) { RefreshDamageDisplay(); CustomFunctions.HitPause(); CustomFunctions.PlaySound(getHitSound); DisplayDamageOnMap(damageAmount, false); StopCoroutine(HitEffectSpriteBlink()); StartCoroutine(HitEffectSpriteBlink()); } else { ResetParry(); CustomFunctions.PlaySound(parryHitSound); RefreshDamageDisplay(); DisplayDamageOnMap(damageAmount, true); CustomFunctions.HitPause(); } //print("Take hit effect with current health " + currentHealth); }