RoboPlayerPlugin playerActivationChanged(String playerName, Boolean activated) { RoboPlayerPlugin plugin = null; if (activated) { plugin = RoboManager.ActivatePlugin(playerName); plugin.Player.Position.PropertyChanged += Position_PropertyChanged; RoboPlayerControl control = new RoboPlayerControl(); control.RoboPlayer = plugin.Player; playerPanel.Controls.Add(control); } else { plugin = RoboManager.ActivePlayers.FirstOrDefault(elem => elem.Name == playerName); if (plugin != null) { plugin.Player.Position.PropertyChanged -= Position_PropertyChanged; RoboPlayerControl playerControl = playerPanel.Controls .Cast <RoboPlayerControl>() .FirstOrDefault(control => control.RoboPlayer == plugin.Player); if (playerControl != null) { playerPanel.Controls.Remove(playerControl); } } RoboManager.DeactivatePlugin(playerName); } return(plugin); }
private void RoboManager_GameStateChange(RoboManager sender, EventArgs <RoboGameState> eventArgs) { switch (eventArgs.Value) { case RoboGameState.Stopped: GameEnded(); break; } }
private void startGameToolStripMenuItem_Click(object sender, EventArgs e) { if (Board == null) { return; } RoboManager.StartGame(); RoboManager.StartRound(); }
public RoboRallyForm() { InitializeComponent(); Throttling = 50; RoboManager = new RoboManager(); RoboManager.GameStateChange += RoboManager_GameStateChange; CreateNewBoard(); SetBoardEditorVisibility(true); folderBrowserDialog.SelectedPath = Directory.GetCurrentDirectory(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (DesignMode) { return; } RoboManager.LoadPlugins(); foreach (RoboPlayerPlugin plugin in RoboManager.AvailablePlugins) { AddPluginToPlayerDropDown(plugin); } }