public override void ApplyDamage(int damage) { if (m_currentShield - damage < 0 && m_currentShield != 0) { int damageLeftovers = damage - m_currentShield; m_currentShield = 0; m_HPUI.UpdateShield(m_currentShield); ApplyDamage(damageLeftovers); } else if (m_currentShield - damage >= 0) { m_currentShield -= damage; m_HPUI.UpdateShield(m_currentShield); return; } else { m_currentHealth -= damage; m_HPUI.UpdateHealth(m_currentHealth); if (m_currentHealth <= 0) { m_currentHealth = 0; m_stateMachine.SetState(m_nextState); } } }
public override void ApplyDamage(int damage) { m_currentHealth -= damage; m_HPUI.UpdateHealth(m_currentHealth); if (m_currentHealth <= 0) { m_currentHealth = 0; AllyDead?.Invoke(); gameObject.SetActive(false); } }
public override void ApplyDamage(int damage) { if (m_firstShot) { FirstShot(); return; } m_currentHealth -= damage; m_HPUI.UpdateHealth(m_currentHealth); if (m_currentHealth <= 0) { m_currentHealth = 0; EnemyDead?.Invoke(); if (m_ammoBox) { GameObject ammoBox = Instantiate(m_ammoBox, transform.position, Quaternion.identity); ammoBox.transform.parent = null; } gameObject.SetActive(false); } }
public void UpdateAppearance(bool showUI = true) { foreach (var entry in Entries) { if (entry.Value == Health) { foreach (var on in entry.On) { on.SetActive(true); } foreach (var off in entry.Off) { off.SetActive(false); } } } if (showUI) { healthBarUI.gameObject.SetActive(true); healthBarUI.UpdateHealth(Health); } }