public void Fire() { //int damage = 800 + Rnd(50); int damage = CalculateDamage(800, 50); int distance = enemy.Distance(); if ((Game.Rnd(4) + ((enemy.Distance() / 500) + 1) > 7)) { wg.WriteLine("Torpedo missed Klingon at " + distance + " sectors..."); } else { wg.WriteLine("Photons hit Klingon at " + distance + " sectors with " + damage + " units"); if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } } }
public void FirePhoton(Galaxy wg) { Klingon enemy = (Klingon)wg.Variable("target"); if (_torpedoStrength > 0) { int distance = enemy.Distance(); if ((Rnd(4) + ((distance / 500) + 1) > 7)) { wg.WriteLine("Torpedo missed Klingon at " + distance + " sectors..."); } else { //int damage = 800 + Rnd(50); int damage = CalculatePhotonDamage(800, 50); wg.WriteLine("Photons hit Klingon at " + distance + " sectors with " + damage + " units"); if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } } _torpedoStrength -= 1; } else { wg.WriteLine("No more photon torpedoes!"); } }
protected void Hit(Galaxy wg, int damage, Klingon enemy) { if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } }
public void FirePhaser(Galaxy wg) { int amount = int.Parse(wg.Parameter("amount")); Klingon enemy = (Klingon)wg.Variable("target"); if (_energyRemaining >= amount) { int distance = enemy.Distance(); if (distance > 4000) { wg.WriteLine("Klingon out of range of phasers at " + distance + " sectors..."); } else { int damage = amount - (((amount / 20) * distance / 200) + Rnd(200)); if (damage < 1) { damage = 1; } wg.WriteLine("Phasers hit Klingon at " + distance + " sectors with " + damage + " units"); if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } } _energyRemaining -= amount; } else { wg.WriteLine("Insufficient energy to fire phasers!"); } }
public void FireWeapon(Galaxy wg) { if (wg.Parameter("command").Equals("phaser")) { int amount = int.Parse(wg.Parameter("amount")); Klingon enemy = (Klingon)wg.Variable("target"); if (e >= amount) { int distance = enemy.Distance(); if (distance > 4000) { wg.WriteLine("Klingon out of range of phasers at " + distance + " sectors..."); } else { int damage = amount - (((amount / 20) * distance / 200) + Rnd(200)); if (damage < 1) { damage = 1; } wg.WriteLine("Phasers hit Klingon at " + distance + " sectors with " + damage + " units"); if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } } e -= amount; } else { wg.WriteLine("Insufficient energy to fire phasers!"); } } else if (wg.Parameter("command").Equals("photon")) { Klingon enemy = (Klingon)wg.Variable("target"); if (t > 0) { int distance = enemy.Distance(); if ((Rnd(4) + ((distance / 500) + 1) > 7)) { wg.WriteLine("Torpedo missed Klingon at " + distance + " sectors..."); } else { int damage = 800 + Rnd(50); wg.WriteLine("Photons hit Klingon at " + distance + " sectors with " + damage + " units"); if (damage < enemy.GetEnergy()) { enemy.SetEnergy(enemy.GetEnergy() - damage); wg.WriteLine("Klingon has " + enemy.GetEnergy() + " remaining"); } else { wg.WriteLine("Klingon destroyed!"); enemy.Delete(); } } t -= 1; } else { wg.WriteLine("No more photon torpedoes!"); } } }