public static int HitPower(StarObject starObject, SRSController srs, double power) { double distance = getDistance(starObject.Row, starObject.Col, srs.GetMyRow(), srs.GetMyCol()); distance = power / Math.Pow(distance, 0.4); return((int)(power < 5 ? 5 : distance)); }
/* * */ public MainWindow() { InitializeComponent(); // start of custom code WriteToLog.write("---- System Start ----", string.Empty, true); debug = Config.ReadElement("Debug", "False", true).Equals("true", StringComparison.OrdinalIgnoreCase); // initialize the sub classes GameBoard = new GameBoard(this); GameMap = new GameMap(this); SRS = new SRSController(this); LRS = new LRSController(this); Warp = new WarpController(this); Torpedoes = new TorpedoController(this); Phasers = new PhaserController(this); Shields = new ShieldController(this); Impulse = new ImpulseController(this); GameObjects = new GameObjects(this); DamageControl = new DamageControl(this); StarBases = new StarBaseController(this); Probes = new ProbeController(this); // set up a new board and start the timer NewGame(8); CreateTimer(); WriteToLog.write("Debug = " + debug.ToString()); WriteToLog.ClearOldLogs(); // set up the hotkeys rcImpulse.InputGestures.Add(new KeyGesture(Key.I, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(rcImpulse, ImpulseCommand)); rcWarp.InputGestures.Add(new KeyGesture(Key.W, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(rcWarp, WarpCommand)); rcTorpedoes.InputGestures.Add(new KeyGesture(Key.T, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(rcTorpedoes, TorpedoCommand)); rcPhasers.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(rcPhasers, PhaserCommand)); rcShields.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(rcShields, ShieldCommand)); }