private void SetBot(DefenseBot bot) { // Remove RemoveBot(); // Set bot _map.AddItem(bot); _bot = bot; // Brain Viewer BrainRGBRecognizer brainRecog = _bot.Parts.FirstOrDefault(o => o is BrainRGBRecognizer) as BrainRGBRecognizer; if (brainRecog != null) { _brainViewer = new BrainRGBRecognizerViewer() { Recognizer = brainRecog, }; panelCustom.Content = _brainViewer; } // Progress bars _progressBars = new ShipProgressBarManager(pnlProgressBars); _progressBars.Bot = _bot; _progressBars.Foreground = this.Foreground; pnlProgressBars.Visibility = Visibility.Visible; }
private void RemoveBot() { // Viewer if (_viewer != null) { _viewer.Close(); _viewer = null; } // Brain Viewer panelCustom.Content = null; _brainViewer = null; //Progress Bars _progressBars = null; pnlProgressBars.Visibility = Visibility.Collapsed; // Bot if (_bot != null) { _map.RemoveItem(_bot); _bot.Dispose(); _bot = null; } }