Example #1
0
 public static void startGame()
 {
     if (!KeyMap.readFromFile())
     {
         OggBuffer kError = DSound.playOgg(DSound.NSoundPath + "\\kme.ogg");
         while (kError.isPlaying())
         {
             if (dxInput.isKeyHeldDown())
             {
                 break;
             }
             Thread.Sleep(10);
         }                 //while
         kError.stopOgg();
         kError = null;
     }
     Options.setDifficulty(Options.difficulties.easy);
     Interaction.clearData();
     mainMenu();
     if (!Options.requestedShutdown)
     {
         Common.startGame();
         if (Common.firstTimeLoad)
         {
             Common.firstTimeLoad = false;
             while (!Common.threadNotifier)
             {
                 Thread.Sleep(6000);
             }
         }
     }
 }
Example #2
0
        public static void startGame(bool firstTimeLoad)
        {
            if (!firstTimeLoad)
            {
                return;
            }

            try
            {
                textBox1          = new TextBox();
                textBox1.Location = new System.Drawing.Point(0, 0);
                textBox1.Name     = "textBox1";
                textBox1.ReadOnly = true;
                textBox1.Size     = new System.Drawing.Size(100, 20);
                textBox1.TabIndex = 0;

                SapiSpeech.initialize();
                DSound.initialize(textBox1.Handle);
                dxInput.DInputInit(textBox1);

                DSound.initializeOgg();
                Options.readFromFile();
                KeyMap.initialize();
                //this.Deactivate += new EventHandler(GUI_Deactivate);
                //this.Activated += new EventHandler(GUI_Activated);

                if (!Common.isRegistered())
                {
                    MessageBox.Show("This game is not registered. Please contact"
                                    + " BPCPrograms SD to obtain a license.",
                                    "Registration");
                }
                register();
                OggBuffer introSound = DSound.playOgg(DSound.SoundPath + "\\i.ogg");
                while ((introSound.isPlaying() && !dxInput.isKeyHeldDown()))
                {
                    Thread.Sleep(5);
                }
                introSound.stopOgg();
                introSound = null;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message + " " + err.StackTrace, "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
Example #3
0
        private static void showDevices()
        {
            InputDeviceCollection dList = null;
            ////holds keyboards
            InputDeviceCollection dList2 = null;

            ////holds game controllers
            dList = DirectInput.GetDevices(DeviceClass.Keyboard, DeviceEnumerationFlags.AttachedOnly);
            ////enumerator for keyboards
            dList2 = DirectInput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly);
            ////enumerator for all game controllers

            DeviceInstance[] devList = null;
            devList = (DeviceInstance[])(Array.CreateInstance(typeof(DeviceInstance),
                                                              (dList2 == null) ? 1 : 2));
            foreach (DeviceInstance d in dList)
            {
                devList[0] = d;
                break;
            }
            if (dList2 != null)
            {
                foreach (DeviceInstance d in dList2)
                {
                    devList[1] = d;
                    break;
                }
            }
            string[] devListSTR = new string[(dList2 == null) ? 1 : 2];
            devListSTR[0] = "mainmenu_5_1_1.wav";
            if (dList2 != null)
            {
                devListSTR[1] = "mainmenu_5_1_2.wav";
            }
            int mindex = Common.sVGenerateMenu(null, devListSTR);

            if (mindex == -1)
            {
                return;
            }
            ////exit menu
            if (mindex > 0)
            {
                ////chose joystick
                ////so config it
                dxInput.DInputInit(Common.mainGUI.Handle, devList[mindex].InstanceGuid);
                configureJS(devList[mindex].InstanceGuid);
                KeyMap.readFromFile();
                SecondarySoundBuffer confirm = DSound.LoadSound(DSound.NSoundPath + "\\gce.wav");
                DSound.PlaySound(confirm, true, false);
                while (DSound.isPlaying(confirm))
                {
                    Thread.Sleep(10);
                }
                DSound.unloadSound(confirm);
                confirm = null;
            }
            else
            {
                if (dxInput.JSDevice != null)
                {
                    dxInput.JSDevice.Unacquire();
                    dxInput.JSDevice = null;
                }         //if !null
                KeyMap.readFromFile();
            }             //if chose keyboard
        }
Example #4
0
        private static void buildKeyMapMenu()
        {
            string[] devices = { "mainmenu_5_1_1.wav",
                                 "mainmenu_5_1_2.wav" };
            short    dO = Common.sVGenerateMenu("mainmenu_5_1_i.wav",
                                                devices);

            if (dO == -1)
            {
                return;
            }

            bool mapKeyboard = false;
            bool mapJoystick = false;

            if (dO == 0)
            {
                mapKeyboard = true;
            }
            else
            {
                mapJoystick = true;
            }

            short index = -1;

            Key[] r = null;
            Key[] m = null;
            ////modifiers will only be assigned if keyboard is used
            int[] jsKey = null;
            while (index != 0)
            {
                r     = null;
                m     = null;
                jsKey = null;
                string[] strKeys = null;
                if (mapKeyboard)
                {
                    strKeys = KeyMap.getKeyStrings(null);
                }
                else
                {
                    strKeys = KeyMap.getKeyStrings(Vehicle.Action.throttleUp,
                                                   Vehicle.Action.throttleDown,
                                                   Vehicle.Action.turnLeft,
                                                   Vehicle.Action.turnRight,
                                                   Vehicle.Action.bankLeft,
                                                   Vehicle.Action.bankRight,
                                                   Vehicle.Action.rollLeft,
                                                   Vehicle.Action.rollRight,
                                                   Vehicle.Action.brakeLeft,
                                                   Vehicle.Action.brakeRight,
                                                   Vehicle.Action.highGTurn,
                                                   Vehicle.Action.ascend,
                                                   Vehicle.Action.descend,
                                                   Vehicle.Action.level,
                                                   Vehicle.Action.togglePointOfView,
                                                   Vehicle.Action.increaseMusicVolume,
                                                   Vehicle.Action.decreaseMusicVolume);
                }
                index = (short)(Common.sVGenerateMenu("ki.wav",
                                                      strKeys) + 1);
                if (index > 0)
                {
                    if (mapKeyboard)
                    {
                        OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp1.ogg");
                        while (dxInput.isKeyHeldDown())
                        {
                            ////wait till the user lets up on enter.
                            Application.DoEvents();
                        }
                        while (m == null)
                        {
                            m = dxInput.getKeys();
                        }
                        prompt.stopOgg();
                        prompt = null;

                        prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp2.ogg");
                        while ((dxInput.isKeyHeldDown()))
                        {
                            ////wait till the user lets up on enter.
                            Application.DoEvents();
                        }
                        ////Next, get a key
                        while (r == null)
                        {
                            r = dxInput.getKeys();
                        }
                        prompt.stopOgg();
                        prompt = null;
                        if (m[0] == Key.Return)
                        {
                            KeyMap.addKey((Vehicle.Action)index, r[0]);
                        }
                        else
                        {
                            KeyMap.addKey((Vehicle.Action)index, m[0], r[0]);
                        }
                    }
                    else
                    {
                        ////joystick
                        OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp3.ogg");
                        while (dxInput.isJSButtonHeldDown())
                        {
                            Application.DoEvents();
                        }
                        while (jsKey == null)
                        {
                            jsKey = dxInput.getJSKeys();
                            Application.DoEvents();
                        }
                        prompt.stopOgg();
                        prompt = null;
                        KeyMap.addKey((Vehicle.Action)index, dxInput.getJSKeys()[0]);
                    }
                    ////joystick
                }
                ////index>=0
            }

            ////Since the parent loop has been broken, the user has pressed escape.
            ////We need to save the new keymap data to a file now so that it will be restored when the game loads
            KeyMap.saveToFile();
        }