private void OnAlienAreaEntered(Godot.Object area) { if (area is Alien) { return; } if (area is Bullet) { var bullet = area as Bullet; Health -= (int)(bullet.Damage / Shield); Update(); bullet.QueueFree(); if (Health <= 0) { Died?.Invoke(Score); QueueFree(); } } if (area is Home) { if (!reachedHome) { ReachedHome?.Invoke(); reachedHome = true; } } }
public void Die() { Died?.Invoke(); Instantiate(_dieEffectPrefab, transform.position, transform.rotation); Destroy(gameObject); }
public void ChangeHealth(float amount) { m_CurrentHealth += amount; if (m_CurrentHealth > maxHealth) { m_CurrentHealth = maxHealth; } HealthChanged?.Invoke(m_CurrentHealth / maxHealth); if (m_CurrentHealth <= 0 && !dead) { dead = true; if (destroyOnDeath) { Died?.Invoke(); if (deathEffects.Length > 0) // Unused, prob not ready for working { var p = transform.position; Pool.Despawn( Pool.Spawn(deathEffects.AnyItem(), new Vector3(p.x, p.y, p.z), new Quaternion(0, 0, 0, 0)), 3); } } if (dyingAnimations.Length > 0) { // If there is death animations for this object m_Animator.SetBool(dyingAnimations.AnyItem(), true); // TODO: not rly useful if destroyed ... (maybe should add death delay idk) } } }
public override bool TakeDamage(float damage, DamageType typing, Node source) { if (IsDead()) { return(false); } if (source != null) { if (source is EnemyProjectiles projectiles) { playerTookDamage?.Invoke(damage, typing, projectiles); projectiles.Remove(); } } Damaged(damage); if (IsDead()) { death?.Invoke(); playerTrappedInRoom = false; } else { EmitSignal(nameof(UpdateHealth), true, GetHealth()); } return(true); }
private void CheckDeath() { if (_healthCurrent <= 0) { Died.Invoke(); } }
public void Die() { hurtBox.collider.enabled = false; hitBox.collider.enabled = false; Died.Invoke(this); Destroy(this.gameObject); }
/// <summary> /// Try to have the player take damage, returning true or false depending on whether it /// was successful. /// </summary> public virtual bool TakeDamage(float damageToTake, bool triggerInvin = true) { if (isInvincible) { return(false); } hp -= damageToTake; animator.SetTrigger("Hurt"); TookDamage.Invoke(); // If invincibility is to be applied, trigger the timer for it if (triggerInvin) { isInvincible = true; invinTimer = invinTime; } if (hp <= 0) { Died.Invoke(); Respawn(); } return(true); }
public override void Die(int killer, Weapon weapon) { IsAlive = false; Player.RespawnTick = Server.Tick + Server.TickSpeed / 2; var modeSpecial = 0; Died?.Invoke(this, GameContext.Players[killer], weapon, ref modeSpecial); Console.Print(OutputLevel.Debug, "game", $"kill killer='{killer}:{Server.ClientName(killer)}' " + $"victim='{Player.ClientId}:{Server.ClientName(Player.ClientId)}' " + $"weapon={weapon} special={modeSpecial}"); Server.SendPackMsg(new GameMsg_SvKillMsg { Killer = killer, Victim = Player.ClientId, Weapon = (int)weapon, ModeSpecial = modeSpecial }, MsgFlags.Vital, -1); GameContext.CreateSound(Position, Sound.PlayerDie); GameContext.CreateDeath(Position, Player.ClientId); Destroy(); }
public void AddHealth(float amount) { m_CurrentHealth += amount; if (m_CurrentHealth > maxHealth) { m_CurrentHealth = maxHealth; } HealthChanged?.Invoke(m_CurrentHealth / maxHealth); if (m_CurrentHealth <= 1 && !dead) { dead = true; // if (destroyOnDeath) // { Died?.Invoke(); // } if (dyingAnimations.Length > 0) { // If there is death animations for this object m_Animator.SetBool(dyingAnimations.AnyItem(), true); // TODO: not rly useful if destroyed ... (maybe should add death delay idk) } } }
public virtual async Task KillAsync() { if (Died != null) { await Died.Invoke(this); } }
private void OnDied() { if (_onDied.IsAssigned()) { _onDied.Invoke(); } Died?.Invoke(this); }
public virtual bool Die() { health = 0; effectiveHealth = health; Died.Invoke(); return(true); }
internal DiedEvent InvokeEvent(DiedEvent arg) { if (_api.ValidateEvent(arg)) { Died?.Invoke(_api, arg); } return(arg); }
public void TakeDamage(int damage) { Current = Mathf.Max(0, Current - damage); if (Current <= 0) { Died?.Invoke(); } }
public void ReceiveDamage(ICombatable damageDealer, float damage) { health -= damage; if (health <= 0) { Died?.Invoke(this); Destroy(this.gameObject); } }
void Die() { GetComponent <Collider>().enabled = false; _navMeshAgent.enabled = false; _anim.SetTrigger("Died"); Died?.Invoke(); Destroy(gameObject, 5f); //enemy will disapear after die from scene view after 5 seconds }
private void OnMouseDown() { _currentLife--; if (_currentLife <= 0) { Died?.Invoke(new Vector3[] { BuildedFirstColumnPosition, BuildedSecondColumnPosition }); } }
private void ApplyDamage() { _health--; HealthChanged?.Invoke(_health); if (_health <= 0) { Died?.Invoke(); gameObject.SetActive(false); } }
public void TakeDamage(float damage) { _health -= damage; OnPlayerHealthChangedEvent?.Invoke(_health / _maxHealth); if (_health <= 0) { Died?.Invoke(gameObject); ChangeScore?.Invoke(); } }
public void TakeDamage(int damage) { _health -= damage; if (_health <= 0) { Destroy(gameObject); Died?.Invoke(this); } }
public CharacterDeadBody Die() { CharacterObj.SetActive(false); CharacterDeadBody deadBody = characterDeadBodyPooler.Get(); deadBody.Set(Transform.position, SpriteRenderer.flipX, DeadBody); deadBody.gameObject.SetActive(true); Died?.Invoke(this, deadBody); return(deadBody); }
private void FixedUpdate() { Ray ray = new Ray(transform.position + Vector3.up, Vector3.down); if (Physics.Raycast(ray, _fallDistance) == false) { Rigidbody.constraints = RigidbodyConstraints.None; Died?.Invoke(); } }
private void ForceDeath() { health = 0; ValueChanged?.Invoke(health); Died?.Invoke(); if (deathGameEvent) { deathGameEvent.Raise(); } }
private IEnumerator DeathPlayer() { var waitForSeconds = new WaitForSeconds(_deathTime); yield return(waitForSeconds); _animator.StopPlayback(); Destroy(gameObject); Died?.Invoke(); // оповещаем GameOverScreen о смерти игрока }
public void Die() { if (TryGetComponent <PlayerInput>(out PlayerInput playerInput)) { Destroy(playerInput); } _animator.SetBool("Die", true); Died?.Invoke(); }
void OnDied() { ParticleSystem particleSystem = Instantiate(ExplosionPrefab, transform.position, Quaternion.identity).GetComponentInChildren <ParticleSystem>(); var main = particleSystem.main; main.startColor = TeamColors.Colors[Team]; Died?.Invoke(); Destroy(gameObject); }
public static void ApplyDamage(float damage) { Health -= damage; TookDamage?.Invoke(Current, EventArgs.Empty); if (Health.CompareTo(0.0F) < 0) { Died?.Invoke(Current, EventArgs.Empty); } }
public override void Tick() { if (Steps > 1) { Steps--; } else { Died?.Invoke(this, false); } }
public void TakeDemage() { _health--; HealthChanged?.Invoke(_health); _visualEffector.PlayDamageEffects(); if (_health <= 0) { Died?.Invoke(); Die(); } }
public void Die() { State = SnakeState.Dead; _moveTimer?.Dispose(); _turnTimer?.Dispose(); if (_conn.State == WebSocketState.Open) { Send(new DiedResponseModel()); } Died?.Invoke(this, null); }