private void OnChangeState(State state, State prevState) { if (state.Name == EnemyStateType.Death.ToString()) { Death?.Invoke(this); } }
public TouchResponseData Touch(TouchData touchData) { if (_dead || !Game.CheckTeamVsTeam(touchData.teamId, teamId)) { return(TouchResponseData.empty); } Console.WriteLine($"Health {teamId} hurt by team {touchData.teamId}"); int previous = health; health -= touchData.damage; TouchResponseData result; result.damageTaken = touchData.damage; GFXQuick gfx = Main.i.factory.SpawnGFX(GameFactory.Path_GFXBloodImpact); gfx.Spawn(touchData.hitPos, touchData.hitNormal); if (health <= 0) { _dead = true; result.responseType = TouchResponseType.Killed; _onDeath?.Invoke(); } else { int change = health - previous; result.responseType = TouchResponseType.Damaged; _onHealthChange?.Invoke(health, change, touchData); } return(result); }
/// <summary> /// If the network is dead, send a signal to whoever is listening. /// </summary> protected void RaiseDeathEvent() { if (Death != null) { Death.Invoke(this); } }
public void OnDeath() { if (Death != null) { Death.Invoke(); } }
private void Health_Changed(IMutableVariable <double> e) { if (e?.Value <= 0) { Death?.Invoke(this, this); } }
private void OnChangeState(State state, State prevState) { if (state.Name == PlayerStateType.Idle.ToString()) { Death?.Invoke(); } }
public TouchResponseData Touch(TouchData touchData) { if (_dead) { return(TouchResponseData.empty); } int previous = _health; _health -= touchData.damage; TouchResponseData result; result.damageTaken = touchData.damage; GFXQuick gfx = Main.i.factory.SpawnGFX(GameFactory.Path_GFXBloodImpact); gfx.Spawn(touchData.hitPos, touchData.hitNormal); if (_health <= 0) { _dead = true; result.responseType = TouchResponseType.Killed; _onDeath?.Invoke(); } else { int change = _health - previous; result.responseType = TouchResponseType.Damaged; _onHealthChange?.Invoke(_health, change, touchData); } return(result); }
/// <summary> /// Raises the death event. /// </summary> protected virtual void OnDeath() { if (Death != null) { Death.Invoke(); } }
private void Update() { var size = _bounds.size; var playerPos = _playerTransform.position; var playerPoints = new[] { new Vector3(-size.x, playerPos.y, playerPos.z), new Vector3(size.x, playerPos.y, playerPos.z), new Vector3(playerPos.x, playerPos.y, size.z), new Vector3(playerPos.x, playerPos.y, -size.z) }; var minDistSq = float.MaxValue; foreach (var point in playerPoints) { var distSq = (_bounds.ClosestPoint(point) - playerPos).sqrMagnitude; if (distSq < minDistSq) { minDistSq = distSq; } } var minDist = Mathf.Sqrt(minDistSq); if (minDist < Constants.BoundDeathDistance) { Death?.Invoke(); } }
public void GetHit(BodyPart bp) { logger.Debug("Игрока " + Name + " бьют."); int ResPoints; if (bp != Blocked) { logger.Info("Блокирование не помогло от удара."); if (HP - 10 > 0) { if (bp == BodyPart.Head) { logger.Trace("Соперник бъет в голову."); if (HP - 15 > 0) { ResPoints = 15; HP -= ResPoints; Wound?.Invoke(this, new PlayerEventArgs(String.Format("Player {0} received minus {1} points, wounded {2}", Name, ResPoints, bp), Name, ResPoints, HP)); logger.Trace(Name + " получил минус 15 очков."); logger.Trace("Оставшееся здоровье: " + HP); } else { logger.Info(Name + " проиграл."); HP = 0; Death?.Invoke(this, new PlayerEventArgs($"Player {Name} is dead.", Name, HP, HP)); } } else { if (bp == BodyPart.Body) { logger.Trace("Соперник бъет в корпус."); } else { logger.Trace("Соперник бъет в ноги."); } ResPoints = 10; HP -= ResPoints; logger.Trace(Name + " получил минус 10 очков."); logger.Trace("Оставшееся здоровье: " + HP); Wound?.Invoke(this, new PlayerEventArgs(String.Format("Player {0} received minus {1} points, wounded {2}", Name, ResPoints, bp), Name, ResPoints, HP)); } } else { logger.Info(Name + " проиграл."); HP = 0; Death?.Invoke(this, new PlayerEventArgs($"Player {Name} is dead.", Name, HP, HP)); } } else { logger.Debug("Повезло! Блокирование спасло от удара."); logger.Trace("Оставшееся здоровье: " + HP); Block?.Invoke(this, new PlayerEventArgs($"Player {Name} was blocked succsessfully", Name, 0, HP)); } }
public void Die() { deathEvent?.Invoke(gameObject); // invoke delegate OnDeath.Invoke(); // Invoke UnityEvent GameObject x = Instantiate(deathParticles, transform.position, Quaternion.identity); // Instantiate particles gameObject.SetActive(false); }
private void OnTriggerEnter(Collider other) { if (other.tag == "Falling Block") { Death?.Invoke(); Destroy(this.gameObject); } }
public virtual void OnDamage(float dmg) { Health -= dmg; if (Health <= 0) { Death?.Invoke(); OnDeath(); } }
public void ChangeHealth(int amount) { currentHealth += amount; currentHealth = Math.Max(0, currentHealth); currentHealth = MathF.Min(currentHealth, MaxHealth); if (currentHealth == 0) { Death?.Invoke(); } }
public ComputerAIPresenter(IComputerAIWindow computerAIWindow, IFighter fighter) { ComputerAIWindow = computerAIWindow; Fighter = fighter; #region Подписка на события бойцa fighter.Block += (fighterName, hp) => Block?.Invoke(fighterName, hp); fighter.Wound += (fighterName, hp) => Wound?.Invoke(fighterName, hp); fighter.Death += (fighterName, hp) => Death?.Invoke(fighterName, hp); #endregion }
private IEnumerator KillCoroutine() { m_animController.SetTrigger("Convert"); m_incidentalAudio.PlayOneShot(m_convertSound, 1.0f); yield return(new WaitForSeconds(2)); if (Death != null) { Death.Invoke(); } }
public void Damage(int damage) { hp -= damage; if (hp <= 0) { Death?.Invoke(this, EventArgs.Empty); hp = 0; } HealthChanged?.Invoke(this, hp); }
public void ResiveDemage(int damage) { CurrentHealth -= damage; if (CurrentHealth >= 0) { OnHealthChanged?.Invoke(CurrentHealth, MaximumHealth); } else { Death?.Invoke(); } }
private void HandleCollision(object sender, EventArgs e) { //Eat Food when coliding with it if (sender.GetType() == typeof(Food)) { EatFood((Food)sender); } //Die when colliding with TailPiece or EnemySnakeHead else if (sender.GetType() == typeof(SnakeTailPiece) || sender.GetType() == typeof(EnemySnake)) { Death?.Invoke(this, new EventArgs()); } }
//refrencing the C# script gameStates private void Update() { if (Flipper.Value == 1f) { GameLoad = GameTypes.wTypes.Starting; } else if (Flipper.Value == 2f) { GameLoad = GameTypes.wTypes.Playing; } else if (Flipper.Value == 3f) { GameLoad = GameTypes.wTypes.Death; } else if (Flipper.Value == 4f) { GameLoad = GameTypes.wTypes.Win; } else { print("Errrorr!!!!"); } switch (GameLoad) { case GameTypes.wTypes.Starting: Start.Invoke(); break; case GameTypes.wTypes.Playing: Play.Invoke(); break; case GameTypes.wTypes.Death: Death.Invoke(); break; case GameTypes.wTypes.Win: Win.Invoke(); break; } }
private void OnValidate() { if (_health > MaxHealth) { _health = MaxHealth; } if (_health <= 0) { _health = 0; } HealthChanged?.Invoke(_health, MaxHealth); if (_health == 0) { Death?.Invoke(); } }
private void OnCollisionEnter(Collision collision) { if (collision.transform.tag == "Platform") { isVector = false; } else if (collision.transform.tag == "PlatformBottom") { isVector = true; } else if (collision.transform.tag == "Lose") { Death.Invoke(); } }
public FighterPresenter(IFighterWindow fighterWindow, IFighter fighter) { FighterWindow = fighterWindow; Fighter = fighter; #region Подписка на события бойцa Fighter.Block += (fighterName, hp) => Block?.Invoke(fighterName, hp); Fighter.Wound += (fighterName, hp) => Wound?.Invoke(fighterName, hp); Fighter.Death += (fighterName, hp) => Death?.Invoke(fighterName, hp); #endregion #region Подписка на события страницы FighterWindow.Fight += (sender, e) => Fight?.Invoke(sender, e); FighterWindow.Reload += (sender, e) => Reload?.Invoke(sender, e); #endregion }
public override void Update(double fps = 1) { base.Update(fps); TickDamping(fps); if (_pos.X < 0) { _pos.X = 0; _vec.X = -_vec.X / BumpDamping; } else if (_pos.X > _grid.Width - _canvas.Width - 30) { _pos.X = _grid.Width - _canvas.Width - 30; _vec.X = -_vec.X / BumpDamping; } if (_pos.Y < 0) { _pos.Y = 0; _vec.Y = -_vec.Y / BumpDamping; } else if (_pos.Y > _grid.ActualHeight - _canvas.ActualHeight - 45) { _pos.Y = _grid.ActualHeight - _canvas.ActualHeight - 45; _vec.Y = -_vec.Y / BumpDamping; } for (int i = 0; i < Missiles.Count; i++) { Missiles[i].Update(fps); if (Missiles[i].ToRemove) { Missiles[i].Remove(); Missiles.Remove(Missiles[i]); } } if (_lastShot < fps / _shotsPerSec) { _lastShot++; } if (HP <= 0) { Death?.Invoke(this, new EventArgs()); } }
public void GetHit(BodyParts part) { if (part != Blocked) { hp -= power; Wound?.Invoke(this, new PlayerEventArgs(Name, hp, power)); if (hp <= 0) { hp = 0; Death?.Invoke(this, new PlayerEventArgs(Name, hp, 0)); } } else { Block?.Invoke(this, new PlayerEventArgs(Name, hp, 0)); } }
public void TakeDamage(GameObject from, float damage) { if (_currentHealthPoints > 0) { _currentHealthPoints -= damage; SetEventArgs(from, damage, damage / maxHealthPoints); DamageReceived?.Invoke(this, _eventArgs); } if (_currentHealthPoints <= 0) { Death?.Invoke(this, _eventArgs); Destroy(gameObject); } if (destructionSequence != null) { var remainingHealth = 1 - damage / maxHealthPoints; StartCoroutine(destructionSequence.DestructionSequenceCorutine(this, remainingHealth)); } }
public void GetHit(BodyParts bodyParts) { if (bodyParts != Bloked) { if (HP > 0) { HP -= 10; Wound?.Invoke(this, new FightEventArgs(Name, HP)); } else { Death?.Invoke(this, new FightEventArgs(Name, HP)); } } else { Block?.Invoke(this, new FightEventArgs(Name, HP)); } }
virtual public void getHit(BodyParts attacked, BattleEventArgs e) { if (attacked == body) { Block?.Invoke(this, e); } else { Hp -= (int)attacked; e.hp = Hp; if (Hp > 0) { Wound?.Invoke(this, e); } else { Death?.Invoke(this, e); } } }
public void GetHit(PartOfTheBody hit) { if (Blocked == hit) { Block?.Invoke(FighterName, Hp); } else { Hp -= 20; if (Hp <= 0) { Death?.Invoke(FighterName, 0); } else { Wound?.Invoke(FighterName, Hp); } } }
public void TryBlock(BodyComponents attackedPart, CombatEventArgs e) { if (!GetHit(attackedPart)) { Block?.Invoke(this, e); } else { int damage = e.randomGenerator.Next(2, 20); e.currentHP = HP - damage; HP = e.currentHP; if (HP > 0) { Wound?.Invoke(this, e); } else { Death?.Invoke(this, e); } } }