private void HealthChecks() // In and InvokeRepeating { try { if (GetHealth() >= 1f && !IsDamagedFlag) { QuickLogger.Debug("Turbine Repaired", true); OnRepaired?.Invoke(); UpdateDamageState(); IsDamagedFlag = true; } if (GetHealth() <= 0f && IsDamagedFlag) { QuickLogger.Debug("Turbine Damaged", true); OnDamaged?.Invoke(); UpdateDamageState(); IsDamagedFlag = false; } } catch (Exception e) { QuickLogger.Error(e.Message); } }
public void TakeDamage(Transform fromObject, bool isFall = false) { //if (isVulnerable && curNumOfHeart > 0) if (!isInVulnerable) // FOR TESTING FOR NOW { Vector2 dir = transform.position - fromObject.position; dir = dir.normalized; if (isFall) { isFalling = true; rb.AddForce(-dir * 2000); // suck StartCoroutine(Fall()); } else { rb.AddForce(dir * 5000); // push isInVulnerable = true; // flickering right away if not fallingS } curNumOfHeart -= 1; OnDamaged?.Invoke(); } if (curNumOfHeart <= 0) { // GAME OVER } }
public void Tune() { if (OnDamaged == null) { OnDamaged += delegate { Console.WriteLine("Sorry, car couldnt handle that tuning - its characteristics are lowered\n"); HorsePower /= 2; Weight *= 1.3f; }; } Random rand = new Random(); int chance = rand.Next(1, 4); if (chance == 1 && OnDamaged != null) { OnDamaged?.Invoke(); return; } else { HorsePower *= 1.2f; Weight *= 0.9f; } }
/// <summary> /// Always takes away from the health. Use Heal to add. /// </summary> public void Damage(int damageValue_) { if (_invulnerable) { return; } _health -= Mathf.Abs(damageValue_); if (_health < 0) { _health = 0; } if (_debug) { Debug.Log(gameObject.name + " damaged: " + damageValue_ + " | Health: " + _health); } OnDamaged.Invoke(); if (_invulnerableAfterDamage) { OnBecomeInvulnerable.Invoke(); _invulnerable = true; _invulnerabilityEvent.TriggerEvent(this); _invulnerabilityEvent.OnEventComplete(OnEndInvulnerablity); } if (IsDead() && !_onDeathInvoked) { _onDeathInvoked = true; OnDeath.Invoke(); } }
public bool GiveDamage(ActorBase attacker, int damage) { if (IsInvincible == true) { return(false); } this.Hp -= damage; if (this.Hp <= 0) { this.Hp = 0; ActorContainer.Instance.Remove(this); EffectManager.Instance.Show(EffectType.Dead, this.transform.position); Destroy(this.gameObject); } OnHpChanged?.Invoke(this.Hp); OnDamaged?.Invoke(); Vector2 attackDirection = this.transform.position - attacker.transform.position; float pushPower = 10f; if (attacker is Character && (attacker as Character).Weapon is MeleeWeapon) { pushPower = ((attacker as Character).Weapon as MeleeWeapon).MeleeWeaponInfo.PushPower; } PushByHit(pushPower, attackDirection.normalized); StartCoroutine(InvincibleProcess()); return(true); }
public void TakeDamage(float damage) { hp -= damage; hp = Mathf.Clamp(hp, 0, maxHP); UpdateIsDead(); OnDamaged?.Invoke(); }
// IObject interface implementation public virtual void OnHit(IObject attacker, int damage, bool forced = false) { if (IsInvincible == true && forced == false) { return; } CallEndEventWhenHit(); int prevHp = Hp; Hp -= damage; if (Hp <= 0) { Hp = 0; } OnDamaged?.Invoke(prevHp, Hp); Ai.AttackListener.Instance.OnDamaged(attacker, this, damage); if (Hp == 0) { OnDeath(); } else { SfxManager.Instance.Play(SfxType.Character_Hit); StartCoroutine(DamageProcess(attacker)); } }
private void HealthChecks() // In and InvokeRepeating { try { if (!QPatch.Configuration.AllowDamage && GetHealth() <= 0f) { OnRepaired?.Invoke(); _prevHealth = 100; return; } if (GetHealth() >= 1f && !IsDamagedFlag() && !Mathf.Approximately(_prevHealth, GetHealth())) { QuickLogger.Debug("Drill Repaired", true); OnRepaired?.Invoke(); _prevHealth = GetHealth(); } if (GetHealth() <= 0f && IsDamagedFlag() && !Mathf.Approximately(_prevHealth, GetHealth())) { QuickLogger.Debug("Drill Damaged", true); OnDamaged?.Invoke(); _prevHealth = GetHealth(); } } catch (Exception e) { QuickLogger.Error(e.Message); } }
public void SetDamage(int damage) { if (_currentShield > 0) { _currentShield -= damage; if (_currentShield >= 3) { _shield.SetState(ShieldState.green); } else if (_currentShield == 2) { _shield.SetState(ShieldState.yellow); } else if (_currentShield == 1) { _shield.SetState(ShieldState.red); } else { _shield.SetState(ShieldState.none); } } else { _currentHealth -= damage; } OnDamaged?.Invoke(_currentShield, _currentHealth); }
public void Damage(int damageAmount) { // Cycle through hearst starting from the end for (int i = heartList.Count - 1; i >= 0; i--) { Heart heart = heartList[i]; // Test if this heart can absorb damageAmount if (damageAmount > heart.GetFragmentAmount()) { // Heart cannot absorb full damageAmount, damage heart, and keep going to next heart damageAmount -= heart.GetFragmentAmount(); heart.Damage(heart.GetFragmentAmount()); } else { // Heart can absorb full damageAmount, absorb, and break out of the cycle heart.Damage(damageAmount); break; } } OnDamaged?.Invoke(this, EventArgs.Empty); if (IsDead()) { OnDead?.Invoke(this, EventArgs.Empty); } }
public void Damage(Player attacker, float damageMultiplier) { OnDamaged?.Invoke(this, new OnDamagedEventArgs { attacker = attacker, damageMultiplier = damageMultiplier, }); }
public void ReceiveDamage() { health--; animator.SetTrigger("isHit"); AudioManager.Instance.Play("isHit"); OnDamaged?.Invoke(health); }
/// <summary> /// hit or damaged by a damager /// </summary> /// <param name="src"></param> public virtual bool ReceiveDamage(Damager src) { if (!invincible) { //check if damage is less than 0 if (src.damage < 0) { print("damage shouldn't be less than 0!"); } beforeDamaged?.Invoke(this, src); //update current health m_current_health = Mathf.Clamp(m_current_health - src.damage, 0, m_current_health); //call back to OnDamaged method, deal with damaged event onDamaged?.Invoke(this, src); //died if (m_current_health == 0) { died?.Invoke(this, src); } else {//not die //set invincible time SetInvincible(invincible_time); //call back after damaged listener afterDamaged?.Invoke(this, src); } //receive damage success return(true); } else { //receive damage failed, because of invincible time return(false); } }
public void Damaged() { if (!m_bNoDamage) { // 受傷後的無敵時間 if (remainUltimateTime > 0f) { return; } sprite.Flash(); if (random.Next(1, 100) < systemDamageRate) { int indexOfSystemId = MathUtility.RandomWithWeights(random, systemLevels); if (systemLevels[indexOfSystemId] > 0) { systemLevels[indexOfSystemId]--; } RefreshSystemValues(); OnDamaged?.Invoke((SystemId)indexOfSystemId); } remainUltimateTime = ultimateTime; } }
public virtual bool Init(IMyRemoteControl rc = null) { Rc = rc ?? Term.GetBlocksOfType <IMyRemoteControl>(collect: x => x.IsFunctional).FirstOrDefault(); if (rc == null) { return(false); } DroneName = DroneNameProvider; Antennae = Term.GetBlocksOfType <IMyRadioAntenna>(collect: x => x.IsFunctional); bool hasSetup = ParseSetup(); if (!hasSetup) { return(false); } AiSessionCore.AddDamageHandler(Grid, (block, damage) => { OnDamaged?.Invoke(block, damage); }); Grid.OnBlockAdded += block => { OnBlockPlaced?.Invoke(block); }; _ownerFaction = Grid.GetOwnerFaction(true); BotOperable = true; return(true); }
private void Start() { _currentHealth = _MaxHealth; _currentShield = _MaxShield; _shield = FindObjectOfType <Shield>(); OnDamaged?.Invoke(_currentShield, _currentHealth); }
public void TakeDamage(int dmg) { hp -= dmg; OnDamaged?.Invoke(dmg); if (hp <= 0) { OnDied?.Invoke(); } }
public void RpcDealDamage(float damage) { hitpoints -= damage; OnDamaged.Invoke(damage); if (hitpoints <= 1 && isServer) { IDead.Invoke(); } Debug.Log("Damaged!"); }
public void TakeDamage(int amount) { _health -= amount; _health = Mathf.Clamp(_health, 0, _maxHealth); OnDamaged?.Invoke(this, EventArgs.Empty); if (IsDead()) { OnDeath?.Invoke(this, EventArgs.Empty); } }
public void Damage(int damageAmount) { _healthAmount -= damageAmount; _healthAmount = Mathf.Clamp(_healthAmount, 0, healthAmountMax); OnDamaged?.Invoke(this, EventArgs.Empty); if (IsDead()) { OnDied?.Invoke(this, EventArgs.Empty); } }
public void UpdateHealth(int health) { this.health += health; OnDamaged.Invoke(health); if (this.health <= 0) { OnDead.Invoke(this); } }
public void Damage(int damageAmount) { // Calc healthAmount -= damageAmount; healthAmount = Mathf.Clamp(healthAmount, 0, maxHealthAmount); // Events OnDamaged?.Invoke(this, EventArgs.Empty); if (IsDead()) { OnDied?.Invoke(this, EventArgs.Empty); } }
public void TakeDamage(int amount) { currentHealth -= amount; if (currentHealth <= 0) { currentHealth = 0; } if (isDead()) { Die(); } OnDamaged?.Invoke(this, EventArgs.Empty); }
public void TakeDamage(float damage) { Debug.Log(gameObject + $" take {damage} damage"); hp -= damage; if (hp <= 0) { hp = 0; onDie?.Invoke(this.gameObject); Die(); } onDamaged?.Invoke(); }
public void Damage(int amount) { health -= amount; if (health < 0) { health = 0; } OnHealthChanged?.Invoke(this, EventArgs.Empty); OnDamaged?.Invoke(this, EventArgs.Empty); if (health <= 0) { Die(); } }
public void Damage(int DamageAmount) { CurrentHealth -= DamageAmount; if (CurrentHealth < 0) { CurrentHealth = 0; } OnHealthChanged?.Invoke(this, EventArgs.Empty); OnDamaged?.Invoke(this, EventArgs.Empty); if (CurrentHealth <= 0) { Die(); } }
public void DealDamage(float value) { if (value < 0) { Debug.LogError("DealDamage value should be bigger than 0"); return; } CurrentHealth -= value; OnDamaged.Invoke(); if (CurrentHealth <= 0) { KillThis(); } }
public void Damage(int damage) { if (damage > 0 && IsAlive) { Health -= damage; OnDamaged?.Invoke(damage); if (Health <= 0) { IsAlive = false; OnDeath?.Invoke(); } OnStatusChanged?.Invoke(); } }
public virtual void Damaged(float val, Vector3 dir) { if (!acInfo.isBeatable) { return; } acInfo.hp -= val; for (int i = 0; i < 3; i++) { var newEffect = Instantiate(damagedEffect, bodyCollider.bounds.center + new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) + Vector3.up * 2, Quaternion.identity); newEffect.transform.localScale = Vector3.one * 2; } if (null != OnDamaged) { OnDamaged.Invoke(); } }
public void Damage(Vector3 DamageRecoil) { if (m_canBeDamaged) { Life--; if (Life <= 0) { OnDeath?.Invoke(); return; } m_canBeDamaged = false; DOVirtual.DelayedCall(InvibilityTime, () => m_canBeDamaged = true); OnDamaged?.Invoke(DamageRecoil); } }