Exemplo n.º 1
0
        public void UpdateInput(ref KeyClass KClass)
        {
            if (this.keyboard.Acquire().IsFailure)
            {
                return;
            }
            Result result = this.keyboard.Poll();

            if (result.IsFailure)
            {
                return;
            }
            this.lastKeyboardState    = this.currentKeyboardState;
            this.currentKeyboardState = this.keyboard.GetCurrentState();
            result = Result.Last;
            if (result.IsFailure)
            {
                return;
            }
            KClass.ArrowLeft  = this.currentKeyboardState.IsPressed(Key.LeftArrow);
            KClass.ArrowRight = this.currentKeyboardState.IsPressed(Key.RightArrow);
            KClass.ArrowUp    = this.currentKeyboardState.IsPressed(Key.UpArrow);
            KClass.ArrowDown  = this.currentKeyboardState.IsPressed(Key.DownArrow);
            KClass.Key_Shift  = this.currentKeyboardState.IsPressed(Key.LeftShift);
            KClass.Key_Z      = this.currentKeyboardState.IsPressed(Key.Z) | this.currentKeyboardState.IsPressed(Key.Return);
            KClass.Key_X      = this.currentKeyboardState.IsPressed(Key.X);
            KClass.Key_C      = this.currentKeyboardState.IsPressed(Key.R);
            KClass.Key_Ctrl   = this.currentKeyboardState.IsPressed(Key.LeftControl);
            KClass.Key_ESC    = this.currentKeyboardState.IsPressed(Key.Escape);
            KClass.Key_plus   = this.currentKeyboardState.IsPressed(Key.Equals);
            KClass.Key_minus  = this.currentKeyboardState.IsPressed(Key.Minus);
            KClass.Key_plus  |= KClass.Key_Ctrl;
            KClass.Key_minus |= KClass.Key_Shift;
        }
Exemplo n.º 2
0
 public override void Ctrl()
 {
     if (Time % CtrlCircle == 0)
     {
         KC = new KeyClass {
             Key_Z = true
         };
         Vector2 move = GenerateMove();
         double  num1 = -move.X;
         double  num2 = -move.Y;
         if (move.Length() < 80.0)
         {
             KC.Key_Shift = true;
         }
         if (num1 > 1.0)
         {
             KC.ArrowLeft = true;
         }
         else if (num1 < -1.0)
         {
             KC.ArrowRight = true;
         }
         if (num2 > 1.0)
         {
             KC.ArrowUp = true;
         }
         else if (num2 < -1.0)
         {
             KC.ArrowDown = true;
         }
     }
     BulletList.ForEach(x => {
         if (!x.HitCheck(this, x.Region) && DeadTime <= Time)
         {
             return;
         }
         KC.Key_X = true;
     });
     StageData.GlobalData.KClass.Hex2Key(KC.Key2Hex());
     base.Ctrl();
 }
Exemplo n.º 3
0
 public override void Ctrl()
 {
     if (this.Time % this.CtrlCircle == 0)
     {
         this.KC       = new KeyClass();
         this.KC.Key_Z = true;
         Vector2 move = this.GenerateMove();
         double  num1 = -(double)move.X;
         double  num2 = -(double)move.Y;
         if ((double)move.Length() < 80.0)
         {
             this.KC.Key_Shift = true;
         }
         if (num1 > 1.0)
         {
             this.KC.ArrowLeft = true;
         }
         else if (num1 < -1.0)
         {
             this.KC.ArrowRight = true;
         }
         if (num2 > 1.0)
         {
             this.KC.ArrowUp = true;
         }
         else if (num2 < -1.0)
         {
             this.KC.ArrowDown = true;
         }
     }
     this.BulletList.ForEach((Action <BaseBullet_Touhou>)(x =>
     {
         if (!x.HitCheck((BaseObject)this, (float)x.Region) && this.DeadTime <= this.Time)
         {
             return;
         }
         this.KC.Key_X = true;
     }));
     this.StageData.GlobalData.KClass.Hex2Key(this.KC.Key2Hex());
     base.Ctrl();
 }
Exemplo n.º 4
0
 public void UpdateInput(ref KeyClass KClass)
 {
     if (this.joystick == null || this.joystick.Acquire().IsFailure || this.joystick.Poll().IsFailure)
     {
         return;
     }
     this.lastJoystickState    = this.currentJoystickState;
     this.currentJoystickState = this.joystick.GetCurrentState();
     if (Result.Last.IsFailure)
     {
         return;
     }
     KClass.ArrowLeft  = this.currentJoystickState.X < -600;
     KClass.ArrowRight = this.currentJoystickState.X > 600;
     KClass.ArrowUp    = this.currentJoystickState.Y < -600;
     KClass.ArrowDown  = this.currentJoystickState.Y > 600;
     KClass.Key_Shift  = this.currentJoystickState.IsPressed(MapJoyStick.Slow);
     KClass.Key_Z      = this.currentJoystickState.IsPressed(MapJoyStick.Shoot);
     KClass.Key_X      = this.currentJoystickState.IsPressed(MapJoyStick.Bomb);
     KClass.Key_Ctrl   = this.currentJoystickState.IsPressed(MapJoyStick.Skip);
     KClass.Key_ESC    = this.currentJoystickState.IsPressed(MapJoyStick.Pause);
     KClass.Key_plus  |= KClass.Key_Ctrl;
     KClass.Key_minus |= KClass.Key_Shift;
 }
Exemplo n.º 5
0
 public void MainProcess()
 {
     if (this.firstFrame)
     {
         this.fpsTimer.Start();
         this.firstFrame = false;
     }
     else if (!this.fixedFPS || this.PresentState is GameState_SplashScreen)
     {
         this.fpsTimer.Start();
     }
     else
     {
         for (int index = 0; index < this.presentInterval; ++index)
         {
             this.fpsTimer.IncreaseOneFrame();
         }
     }
     if (this.InitFlag && this.GlobalData.LoadingList.Count == 0)
     {
         this.GlobalData.LoadModelDictionary();
         this.InitFlag = false;
         this.PresentState.StateSwitchData = new StateSwitchDataPackage()
         {
             NextState = "MainMenu",
             NeedInit  = true,
             SDPswitch = new StageDataPackage(this.GlobalData)
         };
     }
     if (this.PresentState.StateSwitchData != null)
     {
         StateSwitchDataPackage stateSwitchData = this.PresentState.StateSwitchData;
         if (stateSwitchData.NextState == "GameExit")
         {
             this.Form_Main.Close();
             return;
         }
         if (stateSwitchData.NextState != null)
         {
             if (stateSwitchData.NextState == "MainMenu" && this.GlobalData.Rep != null)
             {
                 this.GlobalData.Rep.CloseRpy();
             }
             this.GlobalData.BGM_Pause();
             this.PresentState.StateSwitchData = (StateSwitchDataPackage)null;
             this.PresentState = this.GameStatesDictionary[stateSwitchData.NextState];
             if (stateSwitchData.SDPswitch != null)
             {
                 this.PresentState.StageData = stateSwitchData.SDPswitch;
             }
             if (stateSwitchData.NeedInit)
             {
                 this.PresentState.Init();
                 this.PresentState.BGM_ON();
             }
             else
             {
                 this.GlobalData.BGM_Resume();
             }
         }
     }
     if (this.useDirectInput)
     {
         KeyClass KClass1 = new KeyClass();
         KeyClass KClass2 = new KeyClass();
         try
         {
             this.KCapture.UpdateInput(ref KClass1);
         }
         catch
         {
         }
         try
         {
             this.JCapture.UpdateInput(ref KClass2);
         }
         catch
         {
         }
         KeyClass.KeyMix(ref this.GlobalData.KClass, KClass1, KClass2);
         if (this.KCapture.currentKeyboardState != null)
         {
             if (this.KCapture.currentKeyboardState.IsPressed(Key.LeftAlt) && this.KCapture.currentKeyboardState.IsPressed(Key.F4))
             {
                 this.Form_Main.Close();
                 return;
             }
             if (this.KCapture.currentKeyboardState.IsPressed(Key.F8) && this.KCapture.lastKeyboardState.IsReleased(Key.F8))
             {
                 this.WindowSwitch();
             }
             if (this.KCapture.currentKeyboardState.IsPressed(Key.P) && this.KCapture.lastKeyboardState.IsReleased(Key.P))
             {
                 this.ScreenShot();
             }
         }
     }
     if (this.deviceLost)
     {
         Thread.Sleep(15);
         if (!(this.DeviceMain.TestCooperativeLevel() == SlimDX.Direct3D9.ResultCode.DeviceNotReset))
         {
             return;
         }
         this.GlobalData.OnResetDevice();
         this.deviceLost = false;
         this.firstFrame = true;
     }
     else
     {
         try
         {
             if (this.OnPause && this.PresentState is BaseStage)
             {
                 this.GlobalData.KClass.Key_ESC = true;
             }
             this.PresentState.UpdateData();
             for (int index = 1; index < this.presentInterval; ++index)
             {
                 if (this.PresentState.StateSwitchData != null)
                 {
                     if (this.PresentState.StateSwitchData.NextState == null)
                     {
                         this.PresentState.UpdateData();
                     }
                 }
                 else
                 {
                     this.PresentState.UpdateData();
                 }
             }
             this.DeviceMain.Clear(ClearFlags.ZBuffer | ClearFlags.Target, (Color4)Color.Black, 1f, 0);
             this.DeviceMain.BeginScene();
             this.PresentState.Render();
             this.DeviceMain.EndScene();
             this.DeviceMain.Present(Present.None);
             if (this.GlobalData.BGM_Player.OnPause)
             {
                 this.PresentState.BGM_Resume();
             }
         }
         catch (Direct3D9Exception ex)
         {
             if (ex.ResultCode == SlimDX.Direct3D9.ResultCode.DeviceLost)
             {
                 this.GlobalData.OnLostDevice();
                 this.deviceLost = true;
             }
             else
             {
                 ErrorLog.SaveErrorLog(ex.Message, ex.ResultCode.Description);
                 int num = (int)MessageBox.Show(ex.Message);
                 this.Form_Main.Close();
             }
         }
         if (this.verticalSync && (this.presentInterval == 1 || this.fullWindow))
         {
             return;
         }
         float num1 = 16f * (float)this.presentInterval - this.fpsTimer.GetDuration();
         if ((double)num1 > 0.0)
         {
             Thread.Sleep((int)num1);
         }
         do
         {
         }while(16.6200008392334 * (double)this.presentInterval - (double)this.fpsTimer.GetDuration() > 0.0);
         if (this.fixedFPS && (double)num1 < -16.6666698455811 * (double)this.delayTolerance)
         {
             for (int index = 0; (double)index < -(double)num1 / 16.6666698455811 - (double)this.delayTolerance; ++index)
             {
                 this.fpsTimer.IncreaseOneFrame();
             }
         }
     }
 }