public void SetCurrentMode(string selectedMode) { CurrentMode = selectedMode.ToLower(); switch (CurrentMode) { case "foes": _search_mode = new searchfoe(); break; case "friends": _search_mode = new searchfriends(); break; case "all": _search_mode = new searchall(); break; default: throw new OperationsError("Invalid Mode"); } }
/// <summary> /// Operations Manager constructor. /// </summary> private OperationsManager() { NumberMissiles = MAX_MISSILES; // Set up access to all needed objects _target_manager = TargetManager.GetInstance(); _turret = new MissileLauncherAdapter(); _target_manager.TargetAdded += on_targets_changed; _lock = new Object(); /* we need a way to make these search modes more plug-n-play*/ _search_modes = new List<string>(); _search_modes.Add("Foes"); _search_modes.Add("Friends"); _search_modes.Add("All"); _search_mode = new searchfoe(); _bw = new BackgroundWorker(); _bw.WorkerSupportsCancellation = true; _td = new TargetDetector(); _td.ImageProcessed += new EventHandler(on_targets_detected); _timer = new ThreadedTimer.Timer(); _timer.TimeCaptured += new EventHandler<TimerEventArgs>(_timer_TimeCaptured); TurretReset(); _visual_target = false; }