void SubstractHealthBasedOnDamageType(float dmg, WeaponData.DamageType type) { if (m_health_current <= 0) { return; } if (m_isEnemy) { PlayerHudManager.currentInstance.DisplayDamageNumber((int)dmg, type, transform.position); } if (m_attachToPlayerEntity != null) { m_attachToPlayerEntity.m_ref_playerHudManager.ShakeHud(dmg); if (type != WeaponData.DamageType.photon) { m_attachToPlayerEntity.ResetShieldRecharge(); } } m_shield_current -= dmg; if (m_shield_current < 0) { m_health_current += m_shield_current; m_shield_current = 0; } if (m_health_current < 0) { DestroyEntity(); } }
public void DisplayDamageNumber(int dmg, WeaponData.DamageType dmgtype, Vector3 worldPos) { GameObject lastInstantiatedObject = ObjectPool.currentInstance.GetFromPool_dmgNum(); lastInstantiatedObject.SetActive(true); lastInstantiatedObject.GetComponent <DamageNotificationBehaviour>().SetAs(dmg, dmgtype, Camera.main.WorldToScreenPoint(worldPos)); }
public void DealDamage(float dmg, WeaponData.DamageType dmgType) { if (m_health_current <= 0) { return; } SubstractHealthBasedOnDamageType(dmg, dmgType); dmg *= m_bonusDefMultiplier; if (dmg < 1) { dmg = 1; } }
public void SetAs(int amount, WeaponData.DamageType dmgType, Vector3 screenPos) { if (SelfTextComponent == null) { SelfTextComponent = this.GetComponent <Text>(); } SelfTextComponent.text = amount.ToString(); transform.position = screenPos; switch (dmgType) { case WeaponData.DamageType.critical: { animSpeedMultiplier = 2; sizeMultiplier = 2f; lifetimeMultiplier = 2; StartCoroutine("AnimationNormal"); SelfTextComponent.color = Color.yellow; break; } case WeaponData.DamageType.photon: { animSpeedMultiplier = 1.5f; sizeMultiplier = 0.75f; lifetimeMultiplier = 0.75f; StartCoroutine("AnimationNormal"); SelfTextComponent.color = Color.red; break; } case WeaponData.DamageType.nuclear: { animSpeedMultiplier = 1; sizeMultiplier = 1; lifetimeMultiplier = 1; StartCoroutine("AnimationNormal"); SelfTextComponent.color = ColorPallete.color_effectNuclear; break; } case WeaponData.DamageType.explosive: { animSpeedMultiplier = 1; sizeMultiplier = 1; lifetimeMultiplier = 1; StartCoroutine("AnimationNormal"); SelfTextComponent.color = ColorPallete.color_effectExplosive; break; } default: { animSpeedMultiplier = 1; sizeMultiplier = 1; lifetimeMultiplier = 1; StartCoroutine("AnimationNormal"); SelfTextComponent.color = Color.white; break; } } }