void OnDeathEventClientRpc() { if (IsHost) { return; } onDeathEvent.Invoke(); }
/* private void Poisoning() { * while (Condition == ConditionType.poisoned && Hp > 0) { * lock (conditionLocker) { * _hp--; * if (_hp == 0) { * Condition = ConditionType.dead; * } * Monitor.Wait(conditionLocker, 2000); * } * } * }*/ private void CheckCondition() { if (Hp == 0) { _condition = ConditionType.dead; DeathEvent?.Invoke(this, new EventArgs()); } /* if (Condition == ConditionType.poisoned) { * poisoningThread = new Thread(Poisoning); * poisoningThread.Start(); * return; * } else if (poisoningThread != null) { * lock (conditionLocker) { * poisoningThread.Abort(); * } * }*/ if (Condition != ConditionType.healthy && Condition != ConditionType.weakened && Condition != ConditionType.dead) { return; } if (Hp > 0 && Hp < 0.1f * MaxHp) { _condition = ConditionType.weakened; } if (Hp >= 0.1f * MaxHp) { _condition = ConditionType.healthy; } }
public void OnDeathEvent() { if (DeathEvent != null) { DeathEvent.Invoke(); } }
void OnCollisionEnter(Collision other) { // Add horizontal velocity to the puck depending on where it collides with the paddle if (other.gameObject.layer == LayerMask.NameToLayer("Paddle") && !_isTethered) { // Find the vector between the puck and the paddle Vector3 _collisionVector = transform.position - other.transform.position; _rb.velocity += new Vector3(_collisionVector.normalized.x * _velocityMultiplier, 0f, 0f); } // Check collision with the bottom boundary and update lives if (other.gameObject.layer == LayerMask.NameToLayer("Death")) { GameState.decrementLives(); _scoreEvent.Invoke(GameState.lives); // set fade curtain active, reload scene if (GameState.lives > 0) { // _fadeToBlack.SetActive (true); } else { // XXX:TODO create the game over scene // _fadeToGameOver.SetActive (true); } _fadeToBlack.SetActive(true); _deathEvent.Invoke(); Destroy(gameObject); } }
public void InvokeDeath() { if (DeathEvent != null) { DeathEvent.Invoke(); } }
public void Death() { // Dead DeathEvent?.Invoke(); TurnOrder.Instance.Unsubscribe(this); // Instantiate<ParticleSystem>(properties.Explosion, transform); }
/// <summary> /// Handles the visual, and technical features of dying, such as giving the tower experience. /// </summary> private void Die() { onDeath.Invoke(this); //Anything subscribed to the event will automatically know to call Die() function. //Death Visuals }
public void TakeDamage(float damage) { _currentHealth -= damage; // Health is empty if (_currentHealth <= 0) { DeathEvent?.Invoke(Mathf.Abs(_currentHealth)); deathEvent.Invoke(); } _currentHealth = Mathf.Clamp(_currentHealth, 0f, _health); TakeDamageEvent?.Invoke(damage); if (_currentHealth <= 0) { switch (_onDeath) { case DeathType.Disable: _rootObject.SetActive(false); break; case DeathType.Destroy: Destroy(_rootObject); break; } } }
private void TriggerDeathEvent() { if (isAlive) { DeathEvent?.Invoke(); isAlive = false; } }
/// <summary> /// Получение урона /// </summary> public void TakeDamage(int damage) { HP -= damage; if (HP <= 0) { DeathEvent?.Invoke(); } }
public void OnDestroy() { if (_myNextOfKin == null) { Debug.LogError("Unregistered enemy just died"); return; } _myNextOfKin.Invoke(this); }
public virtual void OnDeath() { EXEventManager.TriggerEvent(new EnemyEvent(EnemyEvent.EnemyEventType.Death, this)); if (DeathEvent != null) { DeathEvent.Invoke(this); } Destroy(gameObject); }
public void Death() { if (dead) { return; } dead = true; SoundManager.Instance.PlaySound(SoundManager.Instance.deathScream); Die.Invoke(); }
public void TakeDamage(int Damage) { Health -= Damage; if (Health <= 0) { OnDie?.Invoke(this); gameObject.SetActive(false); } }
protected virtual void OnDeath() { if (DeathEvent != null) { DeathEvent.Invoke(RecentDamager); } // Since we destroy this instance we remove all subscribers DeathEvent = null; }
public void GetDamage(int damage) { DamageEvent?.Invoke(); CurrentHealth -= damage; if (CurrentHealth <= 0) { DeathEvent?.Invoke(); Die(); } }
public void GetDamage(float damage) { float health = (float)blackboard.GetValue("health") - damage; blackboard.UpdateValue("health", health); if (health <= 0f) { DeathEvent?.Invoke(); } }
public void Die(Vector3 direction) { //rb.isKinematic = false; //rb.WakeUp(); //rb.AddForce(direction*(enemyStats_.health - 5), ForceMode.Impulse); rb.gameObject.tag = "Untagged"; rb.gameObject.layer = 9; dead_ = true; characterAnimator_.SetTrigger("Die"); unit_dead.Invoke(this); }
protected virtual void Die() { onDeath.Invoke(); GameManager.SelectionSystem.RemoveInteractable(this); GameManager.XpSystem.IncrementXp(xpGain); if (selected) { Deselect(); } Destroy(gameObject); }
public virtual void Damaged(float damage) { if (IsAlive) { float loseHealth = Math.Max(damage - Defense, damage * 0.2f); //At least each bullet make 20% damage. Health -= loseHealth; if (Health <= 0) { DeathEvent?.Invoke(this); IsDestroyed = true; } } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.CompareTag("Wall")) { OnWallCollide.Invoke(); } if (collider.gameObject.CompareTag("playerBullet")) { --numAliens; OnDeath.Invoke(points); Destroy(this.gameObject); } }
public void TakeDamage() { if (Dead) { return; } Health -= GameManager.Properties.damage; if (Health <= 0) { DeathEvent?.Invoke(this); Health = 0; Dead = true; } }
public IEnumerator DeathTransition() { DeathEvent?.Invoke(); // Debug.Log("Start"); yield return(new WaitForSeconds(PlayerManager._instance.GetPlayerGFX.GetDeathAnimLength)); // Debug.Log("Player Died"); UIManager._instance.BlackPanel(true); yield return(new WaitForSeconds(extraDelay)); UIManager._instance.BlackPanel(false); RespawnEvent?.Invoke(); startedDeathEvent = false; }
private void LoseLife(byte numberOfLivesLost) { if (m_numberOfLives <= 0) { return; } m_numberOfLives -= numberOfLivesLost; Broadcast.Send <IBroadcast>(gameObject, (x, y) => x.Inform(Broadcasts.BroadcastMessage.Dead)); gameObject.layer = (int)Layer.Dead; DeathEvent?.Invoke(m_numberOfLives); }
protected virtual void ReduceHP(Actor source, float damage) { HP = Mathf.Max(0, HP - damage); if (_healthReference != null) { _healthReference.Value = HP; } if (Dead() && _alive) { _alive = false; StaticActorDeathEvent?.Invoke(source, this); DeathEvent?.Invoke(source); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject == player) { gameManager.health -= 1; gameManager.HealthTracker(); Destroy(gameObject); } if (other.GetComponent <BulletController>() != null) { onDeath.Invoke(body.position); Destroy(other.gameObject); Destroy(gameObject); } }
public override void Damaged(float damage) { if (IsAlive) { float loseHealth = Math.Max(damage - Defense, damage * 0.2f); //At least each bullet make 20% damage. Health -= loseHealth; if (Health <= 0) { DeathEvent?.Invoke(this); foreach (IBarrage barrage in barrages) { barrage.Destroy(); } IsDestroyed = true; } } }
public void TakeDamage(int damage) { // There's a [screamChance] chance that enemy is going to scream from pain Scream(screamChance); health -= damage; healthBar.value -= damage; if (health <= 0) { // Allow events to fire only once after dying if (!this.enabled) { return; } DeathEvent?.Invoke(); this.enabled = false; } }
private void Update() { if (health <= 0 && isPlayer && !died) { DeathEvent?.Invoke(); } if (health <= 0 && !died) { died = true; Die(); } else if (died && deathTrigger.transform.position.z - transform.position.z <= fadeDistance) { StartCoroutine(FadeOut()); } }
private void Kill(string reason) { // Don't do anything if we're already dead if (!Alive) { return; } Alive = false; // We died, stop animating the player animator.SetBool("Playing", false); // Remove the player's collider so they fall Destroy(GetComponent <BoxCollider2D>()); // Fire the OnDeath event OnDeath.Invoke(reason); }