//damage stuffs public static float DamageCalculator(float Damage, Enemy enemy, Projectile.Type projectile) { float totalDamage = 0f; float resistedDamage; float baseDmg = Damage; Projectile.Type proj = projectile; string enemyType = enemy.EnemyType; Color textColour = Color.Black; string popUpText = ""; resistedDamage = Resist(enemy ); if (enemyType == "Soldier") { if (projectile == Projectile.Type.Gun) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) * 2; popUpText = PopUpTextManager.Effective + ":" + totalDamage.ToString(); } else if (projectile == Projectile.Type.Tesla) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, 0, enemy, ref popUpText, ref textColour); popUpText = PopUpTextManager.Neutral + ":" + totalDamage.ToString(); } else { textColour = Color.Yellow; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) / 2; popUpText = PopUpTextManager.Resist + ":" + totalDamage.ToString(); } } else if (enemyType == "Tank") { if (projectile == Projectile.Type.Rocket) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) * 2; popUpText = PopUpTextManager.Effective + ":" + totalDamage.ToString(); } else if (projectile == Projectile.Type.Tesla) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, 0, enemy, ref popUpText, ref textColour); popUpText = PopUpTextManager.Neutral + ":" + totalDamage.ToString(); } else { textColour = Color.Yellow; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) / 4; popUpText = PopUpTextManager.Resist + ":" + totalDamage.ToString(); } } else if (enemyType == "Helicopter") { if (projectile == Projectile.Type.SAM) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) * 2; popUpText = PopUpTextManager.Effective + ":" + totalDamage.ToString(); } else if (projectile == Projectile.Type.Tesla) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, 0, enemy, ref popUpText, ref textColour); popUpText = PopUpTextManager.Neutral + ":" + totalDamage.ToString(); } else { textColour = Color.Yellow; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) / 2; popUpText = PopUpTextManager.Resist + ":" + totalDamage.ToString(); } } else if (enemyType == "Jeep") { if (projectile == Projectile.Type.Rocket) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) * 4; popUpText = PopUpTextManager.Effective + ":" + totalDamage.ToString(); } else if (projectile == Projectile.Type.Tesla) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, 0, enemy, ref popUpText, ref textColour); popUpText = PopUpTextManager.Neutral + ":" + totalDamage.ToString(); } else { textColour = Color.Yellow; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) / 2; popUpText = PopUpTextManager.Resist + ":" + totalDamage.ToString(); } } else if (enemyType == "Transport") { if (projectile == Projectile.Type.Rocket) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) * 3; popUpText = PopUpTextManager.Effective + ":" + totalDamage.ToString(); } else if (projectile == Projectile.Type.Tesla) { textColour = Color.DarkKhaki; totalDamage = TotalDamageCrunch(baseDmg, 0, enemy, ref popUpText, ref textColour); popUpText = PopUpTextManager.Neutral + ":" + totalDamage.ToString(); } else { textColour = Color.Yellow; totalDamage = TotalDamageCrunch(baseDmg, resistedDamage, enemy, ref popUpText, ref textColour) / 3; popUpText = PopUpTextManager.Resist + ":" + totalDamage.ToString(); } } PopUpTextManager.Add(new PopUpText(popUpText, enemy.ScreenPos, textColour)); return totalDamage; }
public static void TowerDamaged(float Damage, Tower tower, Projectile.Type projectile) { //Damage calcualtions should be put here. Not sure on the best way to handle this, could get very large with if's tower.Health -= (int)Damage; }
public static void EnemyDamaged(float Damage, Enemy enemy, Projectile.Type projectile) { enemy.hitPoints -= GameManager.DamageCalculator(Damage, enemy, projectile); }