public void CheckIfHealthIsZero() { if (currentHealth <= 0) { IsDead?.Invoke(); } }
private void OnCollisionEnter(Collision collision) { if (_canJump == false) { return; } if (collision.gameObject.TryGetComponent(out PlatformSegmentDead platformSegmentDead)) { if (_ball.BallCanDead) { _ball.StaminaZero(); Dead?.Invoke(); } else { Jump(platformSegmentDead); } } else if (collision.gameObject.TryGetComponent(out PlatformSegment platformSegment)) { Jump(platformSegment); } else if (collision.gameObject.TryGetComponent(out FinishSegment finishSegment)) { Finish?.Invoke(); } }
public float ReceiveDamage(float damage) { Debug.Log("receive " + damage + " damage, " + health + " hp left"); health -= damage; if (health > 400) { currentSprite = 0; } else if (health > 200 && health < 400) { currentSprite = 1; } else { currentSprite = 2; } if (health <= 0) { if (Dead != null) { Dead.Invoke(this, null); } } return(health); }
public void StartWork() { IsWorking = true; while (IsWorking) { Y += 2; if (_rnd.NextDouble() <= _brokeChance && !IsBroken && !IsRodsDisconnect) { IsBroken = true; Broken?.Invoke(this); _liveTimer = new Timer(TimeSpan.FromSeconds(TimeToDistraction).TotalMilliseconds); _liveTimer.Elapsed += (o, e) => { Dead?.Invoke(this); StopWork(); _liveTimer?.Stop(); }; _liveTimer.Start(); return; } if (_rnd.NextDouble() <= _rodDisconnectChance && !IsRodsDisconnect && !IsBroken) { IsBroken = true; RodsDisconnect?.Invoke(this); return; } Thread.Sleep(200); } }
private void Die() { target = null; acting = false; currentHp = 0; Dead.Invoke(this); this.gameObject.SetActive(false); }
private IEnumerator Die() { Debug.Log("test"); yield return(new WaitForSeconds(dieOffset / 1000f)); _dead = true; Dead?.Invoke(); Destroy(gameObject); }
private void DeathLogic() { if (!_isDead) { _isDead = true; Destroy(this.gameObject); Dead?.Invoke(); } }
protected void Die() { if (_dieded) { return; } _dieded = true; Dead?.Invoke(this); }
public void TakeDamage(float value) { Hp -= value; if (Hp <= 0) { IsDead = true; Dead?.Invoke(this, new EventArgs()); } }
public void GetDamage(int damage) { HP -= damage; if (HP <= 0) { StopAllCoroutines(); StartCoroutine(Die()); Dead?.Invoke(); } }
public void ApplyDamage() { _currentHealth--; HealthChanged?.Invoke(_currentHealth); if (_currentHealth <= 0) { _isDead = true; Dead?.Invoke(); } }
public void ApplayDamage(int damage) { _currentHealth -= damage; HealthChanged?.Invoke(_currentHealth, _health); if (_currentHealth <= 0) { Dead?.Invoke(0, Money); Destroy(gameObject); } }
/// <summary> /// Returns true if the attack killed the Shooter. /// </summary> public bool Attack(float damage, ShooterProcessor attacker) { this.profile.Health -= damage; bool dead = this.profile.Health <= 0; if (dead) { Dead?.Invoke(this, attacker); } return(dead); }
public void ReduceSize() { transform.localScale = new Vector3(transform.localScale.x - Time.deltaTime, transform.localScale.y - Time.deltaTime, transform.localScale.z - Time.deltaTime); _currentSize = transform.localScale.x; if (IsMinimumSize()) { Dead?.Invoke(); } }
public void CheckVictoryORDeath(HerroTemplate other) { if (Helth <= 0) { Dead?.Invoke(this, new ResultBatle($"герой {Name} побежден")); countDeath++; } if (other.Helth <= 0) { Victory?.Invoke(this, new ResultBatle($"герой {Name} одержал победу")); countVictory++; } }
private void TakeDamage() { if (_currentHealth > 0) { _currentHealth--; HealthChanged?.Invoke(_currentHealth); } if (_currentHealth <= 0) { Dead?.Invoke(); } }
public float ReceiveDamage(float damage) { health -= damage; currentSprite = 1; SpriteRenderer.sprite = Sprites[currentSprite]; Debug.Log("receive " + damage + " damage, " + health + " hp left"); if (health <= 0) { if (Dead != null) { Dead.Invoke(this, null); } } return(health); }
public void takeDamage(Damage damage) { if ((this.Group & damage.Attacks) != 0) { this.Amount -= damage.Amount; if (DamageTaken != null) { DamageTaken.Invoke(this); } if (this.Amount <= 0) { if (Dead != null) { Dead.Invoke(this); } } } }
public float ReceiveDamage(float damage) { health -= damage; sp -= 10; stopSP = true; accelerateSP = false; if (sp < 0) { sp = 0; } if (health <= 0) { if (Dead != null) { Dead.Invoke(this, null); } } return(health); }
public void Defence(int damage) { int oldHP = HP; if (Armor.Durability >= 100) { HP -= damage; } else if (Armor.Defence < damage) { HP -= damage - Armor.Defence; } Armor.Using(); if (HP <= 0) { Dead?.Invoke(this, new DeadEventArgs()); return; } Defenced?.Invoke(this, new DefencedEventArgs() { Damage = oldHP - HP }); }
public void Intersect(IInteractable intersectedObject) { if (UserState == UserState.Dead) { return; } if (intersectedObject is Bullet bullet) { if (bullet.UserId != Id) { StarShip.HitPoints -= bullet.Damage; if (StarShip.HitPoints <= 0) { UserState = UserState.Dead; TimeToLive = 42; DeadCount++; Dead?.Invoke(bullet.UserId); } } } }
public void ScaleShrinkGrow() { if (Input.GetButton("Fire1")) { StaffANIM.SetBool("TranGrowP", true); StaffANIM.SetBool("IsGrowingP", true); if (TranGP == true) { if (InVol == false) { if (mass > 0f) { Player.transform.localScale = Vector3.Lerp(Player.transform.localScale, new Vector3(PSgrow, PSgrow, PSgrow), Time.deltaTime * PSgrowtime); if (CurrentSize.magnitude <= maxSize.magnitude) { gameManager.GetComponent <GameManager>().MassAvailable -= (GrowTime * Time.deltaTime); } if (CurrentSize.magnitude >= maxSize.magnitude) { Debug.Log("TooLorge"); } } if (mass <= 0f) { Debug.Log("NoMass"); } } } } if (Input.GetButtonDown("Fire1")) { PlayerUP.Invoke(); if (TooLorge == true) { Debug.Log("DeadByLorge"); Dead.Invoke(); StartCoroutine(DiedDead(.5f)); } } if (Input.GetButtonUp("Fire1")) { StaffANIM.SetBool("IsGrowingP", false); StaffANIM.SetBool("TranGrowP", false); Wipe.Invoke(); } if (Input.GetButton("Fire2")) { StaffANIM.SetBool("TranShrinkP", true); StaffANIM.SetBool("IsShrinkingP", true); if (InVol == false && TranSP == true) { Player.transform.localScale = Vector3.Lerp(Player.transform.localScale, new Vector3(PSshrink, PSshrink, PSshrink), Time.deltaTime * PSshrinktime); if (CurrentSize.magnitude < avgSize.magnitude) { if (CurrentSize.magnitude >= PminSize.magnitude) { gameManager.GetComponent <GameManager>().MassAvailable += (GrowTime * Time.deltaTime) * 1.25f; } if (CurrentSize.magnitude <= PminSize.magnitude) { Debug.Log("smol"); } } } } if (Input.GetButtonDown("Fire2")) { PlayerDown.Invoke(); if (TooSmol == true) { Debug.Log("DeadBySmol"); Dead.Invoke(); StartCoroutine(DiedDead(.5f)); } } if (Input.GetButtonUp("Fire2")) { Wipe.Invoke(); StaffANIM.SetBool("TranShrinkP", false); StaffANIM.SetBool("IsShrinkingP", false); } }
private void DoDead() { Dead?.Invoke(this, new EventArgs()); }
protected override async Task ServiceTaskAsync(CancellationToken cancellationToken) { var buffer = new byte[525]; while (!cancellationToken.IsCancellationRequested) { try { if (streamSource.Aviable < 12) { await Task.Delay(10, cancellationToken); continue; } var stream = await streamSource.GetStreamAsync(); var i = await stream.ReadAsync(buffer, 0, 12, cancellationToken); Message request = new Message(buffer); if (!request.IsHeaderValid) { await stream.FlushAsync(cancellationToken); continue; } i = await stream.ReadAsync(buffer, 12, request.DataLength + 1, cancellationToken); request = new Message(buffer); Story.Add(new MessageStoryItem(MessageStoryItem.Direction.Rx, request)); switch (request.Command) { case Command.BroadcastQuery: await MakeResponseAndSend(request, cancellationToken); break; case Command.IndividualQuery: await MakeResponseAndSend(request, cancellationToken); break; case Command.AutoRun: Status.Start = true; A4 = A4PeriodicSend(request.Source, cancellationToken); // await MakeResponseAndSend(request, cancellationToken); break; case Command.Shutdown: Status.Start = false; await MakeResponseAndSend(request, cancellationToken); break; //case Command.RealtimeData: default: // ignore stream.Flush(); break; } }catch (Exception ex) { await OnErrorAsync(ex, cancellationToken); break; } await Task.Delay(100, cancellationToken); } Status.Start = false; Dead?.Invoke(this, null); }//ServiceTaskAsync()
public void Kill() { Dead.Invoke(); }
private void RaiseDead(bool value) => Dead?.Invoke(this, value);
/// <summary> /// Fired when the entity has died. /// </summary> protected virtual void OnDead(EntityChangedEventArgs e) { Dead?.Invoke(this, e); }
public void Die() { Destroy(gameObject); OnDied?.Invoke(); }
public void OnDead() { Dead?.Invoke(); }
public void Die() { Dead?.Invoke(); }