コード例 #1
0
ファイル: Game.cs プロジェクト: Ocrosoft/CSharpHB
 //判断按键是否有效,0X2009
 public void JudgeKeyPress(char keyChar, Graphics g)
 {
     try
     { for (int i = 0; i < _listDrKey.Count; i++)
       {
           if (i > 27)
           {
               break;
           }
           DrKey keys = new DrKey();
           keys = _listDrKey[i];
           if (keys.KeyName.IndexOf(keyChar) != -1)
           {
               if (keys.Position.Y >= 550 * _zoomRate)                                //有效
               {
                   if (Math.Abs(keys.Position.Y - 700 * _zoomRate) <= 60 * _zoomRate) //正确
                   {
                       if (Math.Abs(keys.Position.Y - 700 * _zoomRate) <= 20)         //完美
                       {
                           _perfect++;
                       }
                       _listDrKey.RemoveAt(i); //移除
                       _accept++;              //正确++;
                       _combo++;
                       if (_combo > _maxCombo)
                       {
                           _maxCombo = _combo;
                       }
                       //显示连击,还没做完
                       // MessageBox.Show(keys.Position.ToString());
                   }
                   else
                   {
                       _listDrKey.RemoveAt(i);
                       _combo = 0;
                   }
                   //418, 193
                   //422, 228
                   g.DrawImage(Key2, keys.Position.X - (int)(2 * _zoomRate), keys.Position.Y - (int)(25 * _zoomRate), (int)(95 * 0.75 * _zoomRate), (int)(90 * 0.75 * _zoomRate));
                   break;
               }
           }
       }
     }
     catch (Exception exc)
     {
         showError("出现错误,ErrorCode:0X2009,ErrorInfo:" + exc);
     }
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: Ocrosoft/CSharpHB
 //移动按键,并且创建按键0X2008
 public void keyMove()
 {
     try
     {
         //创建key
         while (Math.Abs(_currentTime + _speedCustom - _keyTime) <= 0.05)
         {
             for (int i = 0; i < 9; i++)
             {
                 if (myKey.Key[i] == true)
                 {
                     DrKey keys = new DrKey();
                     keys.Position = new Point((int)(155 * _zoomRate) + (int)(i * 80 * _zoomRate), (int)(120 * _zoomRate));
                     keys.KeyName  = keyChar[i].ToString();
                     _listDrKey.Add(keys);
                 }
             }
             _cursor++;
             if (_cursor >= KeyCount1)
             {
                 _cursor  = -1;
                 _keyTime = -1;
             }
             if (_cursor != -1)
             {
                 myKey    = _listKey[_cursor];
                 _keyTime = myKey.Min * 60 + myKey.Sec + myKey.Ms / 1000.0;
             }
         }
         //移动key
         for (int i = 0; i < _listDrKey.Count; i++)
         {
             drKey           = _listDrKey[i];
             drKey.MoveSpeed = (int)(_keySpeed * _zoomRate);
             drKey.Move();
             if (drKey.Position.Y >= 740 * _zoomRate)
             {
                 _combo = 0;
                 _listDrKey.RemoveAt(i);
                 drKey.Dispose();
                 i--;
             }
         }
     }
     catch (Exception exc)
     {
         showError("出现错误,ErrorCode:0X2008,ErrorInfo:" + exc);
     }
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: Ocrosoft/CSharpHB
 //判断按键是否有效,0X2009
 public void JudgeKeyPress(char keyChar, Graphics g)
 {
     try
     {
         for (int i = 0; i < _listDrKey.Count; i++)
         {
             if (i > 27)
             {
                 break;
             }
             DrKey keys = new DrKey();
             keys = _listDrKey[i];
             if (keys.KeyName.IndexOf(keyChar) != -1)
             {
                 if (keys.Position.Y > 710 * _zoomRate)
                 {
                     continue;                                                          //超过线的可见但不可触发
                 }
                 if (keys.Position.Y >= 550 * _zoomRate)                                //有效
                 {
                     if (Math.Abs(keys.Position.Y - 700 * _zoomRate) <= 60 * _zoomRate) //正确
                     {
                         if (Math.Abs(keys.Position.Y - 700 * _zoomRate) <= 20)         //完美
                         {
                             Perfect++;
                             g.DrawString("Charming", new Font("Comic Sans MS", (float)(10 * _zoomRate)), fontBrush, (int)((1024 - 90) * _zoomRate), (int)((768 / 2.0 - 45) * _zoomRate));
                         }
                         _listDrKey.RemoveAt(i); //移除
                         Accept++;               //正确++;
                         _combo++;
                         if (_combo > MaxCombo)
                         {
                             MaxCombo = _combo;
                         }
                         //显示连击
                         if (_combo < 10)
                         {
                             g.DrawString(_combo.ToString(), myFont, fontBrush, (int)((1024 - 80) * _zoomRate), (int)((768 / 2.0 - 90) * _zoomRate));
                         }
                         else if (_combo < 100)
                         {
                             g.DrawString(_combo.ToString(), myFont, fontBrush, (int)((1024 - 90) * _zoomRate), (int)((768 / 2.0 - 90) * _zoomRate));
                         }
                         else
                         {
                             g.DrawString(_combo.ToString(), myFont, fontBrush, (int)((1024 - 105) * _zoomRate), (int)((768 / 2.0 - 90) * _zoomRate));
                         }
                     }
                     else
                     {
                         _listDrKey.RemoveAt(i);
                         _combo = 0;
                     }
                     //418, 193
                     //422, 228
                     g.DrawImage(Key2, keys.Position.X - (int)(2 * _zoomRate), keys.Position.Y - (int)(25 * _zoomRate), (int)(95 * 0.75 * _zoomRate), (int)(90 * 0.75 * _zoomRate));
                     break;
                 }
             }
         }
     }
     catch (Exception exc)
     {
         showError("出现错误,ErrorCode:0X2009,ErrorInfo:" + exc);
     }
 }