void CheckForBombHurt() { float currentSecond = Mathf.Ceil(Time.time); if (currentSecond > lastBombHurtTime) { lastBombHurtTime = currentSecond; if (gameUnit.bomb > 0) { gameUnit.ReceiveDamage(gameUnit.bomb); } } }
public void AttackPlayer() { if (lastAttackTime + (1f / gameUnit.combinedAttackSpeed) < Time.time) { if (Game.Instance.player != null) { int dmg = gameUnit.combinedStrength; GameUnit playerUnit = Game.Instance.player.GetComponent <GameUnit>(); int actualDamageDealt = playerUnit.ReceiveDamage(dmg); if (playerUnit.spikes > 0) { int reflectedDamage = (int)Mathf.Round(Mathf.Max(1f, actualDamageDealt * playerUnit.spikes * 0.2f)); gameUnit.ReceiveDamage(reflectedDamage); } lastAttackTime = Time.time; } } }
/// <summary> /// handles the damage of projectile /// </summary> /// <param traget of projectile ="enemy"></param> void Damage(Transform enemy) { GameUnit e = enemy.GetComponent <GameUnit>(); if (e != null) { if (e.coreStats.shield > 0) { switch (damageType) { case DamageType.Laser: e.ReceiveDamage(damage); break; case DamageType.Explosive: e.ReceiveDamage(damage * 0.5f); break; case DamageType.Incendinary: e.ReceiveDamage(0); break; case DamageType.EMP: e.ReceiveDamage(damage * 2.0f); break; case DamageType.Other: e.ReceiveDamage(damage); break; default: e.ReceiveDamage(damage); break; } } else { if (e.coreStats.unitType == GameUnit.UnitType.Organic) { switch (damageType) { case DamageType.Laser: e.ReceiveDamage(damage); break; case DamageType.Explosive: e.ReceiveDamage(damage * 1.2f); break; case DamageType.Incendinary: e.ReceiveDamage(damage * 1.5f); break; case DamageType.EMP: e.ReceiveDamage(0); break; case DamageType.Other: e.ReceiveDamage(damage); break; default: e.ReceiveDamage(damage); break; } } else if (e.coreStats.unitType == GameUnit.UnitType.Mechanic) { switch (damageType) { case DamageType.Laser: e.ReceiveDamage(damage); break; case DamageType.Explosive: e.ReceiveDamage(damage * 1.2f); break; case DamageType.Incendinary: e.ReceiveDamage(damage * 0.8f); break; case DamageType.EMP: e.ReceiveDamage(damage * 0.5f); break; case DamageType.Other: e.ReceiveDamage(damage); break; default: e.ReceiveDamage(damage); break; } } } } }