private void Die() { if (OnDeath != null) { OnDeath.Invoke(); } }
/** * <summary> * Decrements the health value and if is dead returns the given experience, 0 otherwise * </summary> */ public float OnDamageReceived(float damage) { OnHit?.Invoke(); if (IsAlive()) { audioManager.Play("BodyHit"); } var finalDamage = absorption >= damage ? 0 : damage - absorption; health -= finalDamage; if (IsAlive()) { if (IsSkeleton()) { randomAudio.Play(); } return(0); } if (!isDead) { OnDeath?.Invoke(); if (IsSkeleton()) { audioManager.Play("SkeletonDeath"); } isDead = true; return(experience); } return(0); }
public virtual void Die() { Dead = true; OnDeath?.Invoke(); //if (Animator != null) // Animator.SetBool("Dead", true); }
// Handle the player's death void Kill() { Debug.Log("killed"); isDead = true; if (OnDeath != null) { OnDeath.Invoke(); } if (Equals(this.gameObject.tag, "Player")) { // Disable any character control PlayerInputHandler inputHandler = GetComponent <PlayerInputHandler>(); inputHandler.PlayerActionsEnabled = false; inputHandler.PlayerMovementEnabled = false; // TODO: Play the death animation respawnManager.RespawnPlayer(CharacterPrefab); } else { Destroy(this.gameObject); } }
public override void Die() { if (dead) { return; } dead = true; activated = false; // Animation and Sound of death AudioManager.instance.PlaySound("DieSound"); dieParticles.Play(); // If enemy didn't drop power up we may drop some ammo if (!GeneratePowerUP()) { GenerateAmmoBox(); } // Call OnDeath event OnDeath?.Invoke(); if (animator != null) { ChangeAnimationState("Die"); } }
public void Update(uint tick, float _gameSpeed) { List <Entity> toDestroy = new List <Entity>(); for (int i = 0; i < Compatible.Count; i++) { var entity = Compatible[i]; var ageComponent = entity.GetComponent <OldAgeComponent>(); ageComponent.CurrentAge += _gameSpeed * _oldAgeMultiplier; if (ageComponent.CurrentAge >= ageComponent.MaxAge && _oldAgeEnabled) { toDestroy.Add(entity); // Check if we would be killing an entity with energy if (entity.TryGetComponent <EnergyComponent>(out EnergyComponent deadEnergy)) { deadEnergy.HandleDeath(_energyManager, Pool, _simulation.JsonSettings, entity.GetComponent <TransformComponent>().WorldPosition); } var transform = entity.GetComponent <TransformComponent>(); OnDeath?.Invoke(new DeathEventInfo(transform.WorldPosition, tick * _gameSpeed, entity.Id, entity.Tag, new OldAgeDeathCause())); } } foreach (var e in toDestroy) { Pool.DestroyEntity(e); } }
private void OnTriggerEnter2D(Collider2D collider) { if (collider.CompareTag("SoulBoundary") && _isEscaping) { if (_updateTargetRotationCoroutine != null) { StopCoroutine(_updateTargetRotationCoroutine); _updateTargetRotationCoroutine = null; } _targetRotation = Quaternion.AngleAxis(180f, Vector3.forward) * transform.rotation; //print("Rotated 180 degrees"); } var scythe = collider.GetComponent <Scythe>(); if (scythe is null) { return; } print("Victim hit by scythe"); OnDeath?.Invoke(this, EventArgs.Empty); OnDeathUnityEvent?.Invoke(); StartCoroutine(ReleaseSoulDelayed(_timeUntilSoulReleased)); }
public void Death(RealmTime time) { DamageCounter.Death(time); CurrentState?.OnDeath(new BehaviorEventArgs(this, time)); OnDeath?.Invoke(this, new BehaviorEventArgs(this, time)); Owner.LeaveWorld(this); }
private void CheckForDeath() { if (combatStats.Health <= 0) { OnDeath?.Invoke(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Obstacle")) { if (!isDeath) { // Calculate point of impact deathImpactDirection = transform.position - other.transform.position; deathImpactDirection.Normalize(); audioSource.clip = deathAudio; audioSource.Play(); isDeath = true; OnDeath?.Invoke(); } } if (other.gameObject.CompareTag("Goal")) { if (!isDeath) { OnGoalTouched?.Invoke(); } } }
public virtual void Die() { OnDeath?.Invoke(this); StatisticsManager.Instance.AddIntValue($"Entity.Killed.{stats.name}", 1); Destroy(gameObject); }
public void ReceiveDamage(int damage, bool playClip = false) { if (isUntouchable || isDead) { return; } if (healthPoints >= DamagedThreshold * MaxHealth && healthPoints - damage < DamagedThreshold * MaxHealth) { audioSource.PlayOneShot(deacticatedClip, 1.0f); } healthPoints = Mathf.Clamp(healthPoints - damage, 0, MaxHealth); if (playClip) { audioSource.PlayOneShot(damageClip, 0.3f); } UpdateHealthBar(); if (healthPoints <= 0) { gameOverEffect.SetActive(true); isDead = true; OnDeath.Invoke(); audioSource.Play(); } }
private void Kill() { OnAnyEnemyDeath?.Invoke(); UnitKillPointReached?.Invoke(); OnDeath?.Invoke(); StartCoroutine(KillWithDelay()); }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("Player")) { agent.isStopped = true; OnDeath.Invoke(); } }
public void Death() { anim.SetBool("IsDead", true); movement.SetMovement(false); pScore.SetActive(false); sfxDeath.Play(); OnDeath?.Invoke(); }
public void Damages(float point) { CurrentHP -= point; if (CurrentHP <= 0) { OnDeath?.Invoke(); } }
private void Update() { if (!health.IsAlive && gameObject.activeSelf) { gameObject.SetActive(false); OnDeath?.Invoke(this); } }
public void Kill(Player eliminator) { SoundManager.Instance.PlaySingle(Sound.UnitDieSound); DestroyedCheck(); Destroy(gameObject); _destroyed = true; OnDeath?.Invoke(this, new EliminatedEventArgs(eliminator)); }
public void DoDamage(float _damage) { stats.Health -= _damage; if (stats.Health <= 0f) { OnDeath?.Invoke(transform.name); } }
protected virtual void HandleDeath() { if (deathResult != null) { OnDeath.Invoke(master, deathResult); deathResult = null; } }
public void TakeDamage() { Hp--; if (Hp == 0) { OnDeath?.Invoke(this); } }
void Die() { if (OnDeath != null) { OnDeath.Invoke(); } Destroy(this.gameObject); }
private void Die() { if (IsAlive) { IsAlive = false; OnDeath?.Invoke(); } }
private void OnStateChanged(SheepState state) { if (state == SheepState.Death) { OnDeath?.Invoke(this); isDead = true; } }
protected virtual void LateUpdate() { if (IsDying) { Destroy(gameObject); OnDeath?.Invoke(this); } }
public virtual void Die() { if (IsAlive()) { return; } OnDeath?.Invoke(); }
private void Die(string tag) { if (tag.Equals("Death")) { _input.Disable(); _collisionComponent.Disable(); _playerAnimationComponent.Death(() => OnDeath.Invoke()); } }
public Character(ContentManager content, Vector2 position, float speed, CharactersInRange charactersInRange, OnDeath onDeath, float health) : base(content) { this.SPEED = speed; this.rangeRing = new RadiusRing(content, position); this.charactersInRange = charactersInRange; this.healthBar = new HealthBar(content, position, health); this.onDeath = onDeath; }
protected async void Die() { _isDead = true; Visible = false; OnDeath?.Invoke(); await ToSignal(_soundPlayer, "finished"); QueueFree(); }
public void SetHealth(int newValue) { Current = Math.Max(0, Math.Min(MaxHealth, newValue)); if (Current == 0) { OnDeath?.Invoke(); IsDead = true; } }