Ejemplo n.º 1
0
        /// <summary>
        /// Called when the window is loaded.
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="e">The arguments</param>
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            _bitmap = new WriteableBitmap(Settings.Default.VideoWidth, Settings.Default.VideoHeight, 72, 72, PixelFormats.Rgb24, null);

            VideoImage.Source = _bitmap;

            _isInSession = false;
            Title        = Settings.Default.Title + " : Ready";

            _rand    = new Random();
            _gamepad = new GamepadState(UserIndex.One);
            _continuousCommandState = new Dictionary <string, float>();

            _curriculumItemPaths = Settings.Default.Curriculum.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            _continuousCommandState.Add("move", 0);
            _continuousCommandState.Add("strafe", 0);
            _continuousCommandState.Add("pitch", 0);
            _continuousCommandState.Add("turn", 0);
            _continuousCommandState.Add("crouch", 0);
            _continuousCommandState.Add("jump", 0);
            _continuousCommandState.Add("attack", 0);
            _continuousCommandState.Add("use", 0);

            _discreteCommandState = new Dictionary <string, bool>();
            _discreteCommandState.Add("movenorth", false);
            _discreteCommandState.Add("moveeast", false);
            _discreteCommandState.Add("movesouth", false);
            _discreteCommandState.Add("movewest", false);

            _pendingMessagesMutex = new SemaphoreSlim(1);
            _pendingCommandsMutex = new SemaphoreSlim(1);
            _pixelsMutex          = new SemaphoreSlim(1);

            _pendingMessages = new Queue <string>();

            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromSeconds(1.0 / 30);
            _timer.Tick    += timer_Tick;
            _timer.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the window is loaded.
        /// </summary>
        /// <param name="sender">The event sender</param>
        /// <param name="e">The arguments</param>
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            _bitmap = new WriteableBitmap(Settings.Default.VideoWidth, Settings.Default.VideoHeight, 72, 72, PixelFormats.Rgb24, null);

            VideoImage.Source = _bitmap;

            _isInSession = false;
            Title = Settings.Default.Title + " : Ready";

            _rand = new Random();
            _gamepad = new GamepadState(UserIndex.One);
            _continuousCommandState = new Dictionary<string, float>();

            _curriculumItemPaths = Settings.Default.Curriculum.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            _continuousCommandState.Add("move", 0);
            _continuousCommandState.Add("strafe", 0);
            _continuousCommandState.Add("pitch", 0);
            _continuousCommandState.Add("turn", 0);
            _continuousCommandState.Add("crouch", 0);
            _continuousCommandState.Add("jump", 0);
            _continuousCommandState.Add("attack", 0);
            _continuousCommandState.Add("use", 0);

            _discreteCommandState = new Dictionary<string, bool>();
            _discreteCommandState.Add("movenorth", false);
            _discreteCommandState.Add("moveeast", false);
            _discreteCommandState.Add("movesouth", false);
            _discreteCommandState.Add("movewest", false);

            _pendingMessagesMutex = new SemaphoreSlim(1);
            _pendingCommandsMutex = new SemaphoreSlim(1);
            _pixelsMutex = new SemaphoreSlim(1);

            _pendingMessages = new Queue<string>();

            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromSeconds(1.0 / 30);
            _timer.Tick += timer_Tick;
            _timer.Start();
        }