Example #1
0
        /// <summary>
        /// Occurs when the user clicks the new game button. When a new game is created the office
        /// camera is shown and a user instance is created. This is also a good time to setup the
        /// Game logic engine which handles the characters and user. The flashlight is also
        /// initialized.
        /// </summary>
        /// <param name="sender">ignored</param>
        /// <param name="e">ignored</param>
        private void NewGameImageButton_Click(object sender, EventArgs e)
        {
            OfficeForm officeCameraForm = new OfficeForm();

            //
            // Stop the theme music anytime a game starts.
            //
            _soundEngine.StopSound(_startMenuThemeMusic);

            User user = new User()
            {
                MaskImage   = global::FNAF.Properties.Resources.FreddyMask,
                CurrentForm = officeCameraForm,
                LastForm    = this
            };

            //
            // Start the game engine. This is the engine that handles basic game logic such as
            // when to play certain sounds, randomly moves characters throughout the rooms and
            // decides when to scare if to scare at all. This will also setup the user/security
            // guard.
            //
            ThreadingEngine.StartThread(new GameEngine(user));

            //
            // Each game requires the flashlight so start the flashlight thread here.
            //
            ThreadingEngine.StartThread(new Flashlight());

            //
            // The new game is initialized now start the office camera to begin.
            //
            GameEngine.ShowForm(officeCameraForm, this);
        }