private void StartPlayer(PlotColor color, SwarmGame swarmGame) { Thread thread; SwarmWorker sw; // create the worker thread sw = new SwarmWorker(); sw.Configure(color, m_scripts[(int)color], swarmGame); // kick off the thread thread = new Thread(new ThreadStart(sw.RunGame)); thread.Start(); }
public void On_Loaded(object sender, EventArgs args) { SwarmWorker[] sw = new SwarmWorker[4]; TextBlock text; Rectangle button; Slider slider; // capture the canvas reference m_root = this; // hookup start button text = (m_root.FindName("StartText") as TextBlock); text.MouseLeftButtonDown += StartButtonClick; button = (m_root.FindName("StartButton") as Rectangle); button.MouseLeftButtonDown += StartButtonClick; // hook up handlers for configuration HookRadioClick("RedRadio", RedClick); HookRadioClick("YellowRadio", YellowClick); HookRadioClick("BlueRadio", BlueClick); HookRadioClick("GreenRadio", GreenClick); HookRadioClick("FieldRadio", FieldClick); // hook up slider updates slider = (m_root.FindName("NumSwarmSlider") as Slider); slider.ValueChanged += NumSwarmClick; slider = (m_root.FindName("DuplicationSlider") as Slider); slider.ValueChanged += DuplicationClick; slider = (m_root.FindName("WinPerSlider") as Slider); slider.ValueChanged += WinPerClick; // setup the board based on the field config FieldClick(null, null); RedClick(null, null); YellowClick(null, null); BlueClick(null, null); GreenClick(null, null); // create the ui timer m_uiTimer = new DispatcherTimer(); m_uiTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); m_uiTimer.Tick += new EventHandler(PaintUI); m_uiTimer.Start(); }