public MainPage() { //force color scheme for now Preferences.Intstance.ColorScheme = ColorSchemes.Schemes[1]; var player = CrossSimpleAudioPlayer.Current; for (int i = 0; i < (int)DrumType.count; i++) { players[i] = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer(); players[i].Loop = false; } LoadSamples(1); InitializeComponent(); int j = 0; foreach (Button button in gridButtons.Children) { DrumType drum = (DrumType)j; button.Clicked += (s, e) => OnDrumButton(drum); j++; } Preferences.Intstance.ColorSchemeUpdated += ColorSchemeUpdated; //to set the animations ColorSchemeUpdated(this, Preferences.Intstance.ColorScheme.SchemeType); }
public MainPage() { //force color scheme for now Preferences.Intstance.ColorScheme = ColorSchemes.Schemes[0]; for (int i = 0; i < (int)DrumType.count; i++) { players[i] = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer(); players[i].Loop = false; } InitializeComponent(); int j = 0; foreach (Button button in gridButtons.Children) { DrumType drum = (DrumType)j; button.Clicked += (s, e) => OnDrumButton(drum); j++; } btnRecord.Clicked += BtnRecordClicked; btnPlay.Clicked += BtnPlayClicked; btnSettings.Clicked += (s, e) => Navigation.PushAsync(new ColorSchemePage()); btnAbout.Clicked += (s, e) => DisplayAlert("DrumPad", "v0.5.1", "OK"); Preferences.Intstance.ColorSchemeUpdated += ColorSchemeUpdated; //to set the animations ColorSchemeUpdated(this, Preferences.Intstance.ColorScheme.SchemeType); }
/// <summary> /// 敲击鼓 /// </summary> /// <param name="dt"></param> /// <param name="iterate"></param> public void KnockPlay(DrumType dt) { switch (dt) { case DrumType.LeftFace: PlayLeftFace(); break; case DrumType.RightFace: PlayRightFace(); break; case DrumType.LeftSide: PlayLeftSide(); break; case DrumType.RightSide: PlayRightSide(); break; case DrumType.FaceAll: PlayLeftFace(); PlayRightFace(); break; case DrumType.SideAll: PlayLeftSide(); PlayRightSide(); break; } }
/// <summary> /// 判断按键是否符合游戏规则 /// </summary> private bool KnockKeyIsCodex(CadenceSign cs, DrumType k) { bool isCodex = false; if (k == cs.drumType) { isCodex = true; } if (k == DrumType.LeftSide && cs.drumType == DrumType.RightSide) { isCodex = true; } if (k == DrumType.RightSide && cs.drumType == DrumType.LeftSide) { isCodex = true; } if (k == DrumType.LeftFace && cs.drumType == DrumType.RightFace) { isCodex = true; } if (k == DrumType.RightFace && cs.drumType == DrumType.LeftFace) { isCodex = true; } return(isCodex); }
double lostArrage = 500 * 10; //按错与位置出入太大 /// <summary> /// 通知有按键按下 /// </summary> /// <param name="key"></param> public void NotifyKeyDown(DrumType dt) { if (SignEnd()) { return; } for (int i = indexActual; i < signCount;) { if (null == CadenceSigns) { return; } CadenceSign cs = CadenceSigns[i]; double atime = (lapseTime - arriveEndPointOffset);// / (1 * speed);//当前实际流逝时间 if (CommHelper.Abs(cs.DelayTimeMill - atime) <= normalArrage) { //double lv = Canvas.GetLeft(cs.currentSign); cs.currentSign.Visibility = Visibility.Collapsed; LayoutRoot.Children.Remove(cs.currentSign); indexActual++; cs.state = 2; HitArgs ha = new HitArgs(); ha.DrumType = dt; ha.SignSource = cs; ha.HitType = HitType.Normal; if (cs.drumType != DrumType.FaceAll && cs.drumType != DrumType.SideAll) { cs.DelayTimeMill -= (int)(10 * speed); } if (CommHelper.Abs(cs.DelayTimeMill - atime) <= niceArrage) { ha.HitType = HitType.Nice; } //得分算出来后计算按键是否对应 if (!KnockKeyIsCodex(cs, dt)) { ha.HitType = HitType.Lost; } OnHit(this, ha); return; } else if (CommHelper.Abs(cs.DelayTimeMill - atime) <= lostArrage) { RemoveAndSendMsg(cs, 1, HitType.Lost); return; } else { return;//没有满足的直接跳出 } } }
void OnDrumButton(DrumType drumType) { if (isRecording) { recording.Add(new Note(DateTime.Now.Ticks - recordingStart, drumType)); } players[(int)drumType]?.Play(); animations[(int)drumType]?.Commit(this, drumType.ToString()); }
private void OnDrumButton(DrumType drumType) { //players[(int)drumType]?.Play(); foreach (DrumType i in (DrumType[])Enum.GetValues(typeof(DrumType))) { if (i != DrumType.count) { players[(int)i]?.Stop(); //players[(int)i].Volume = 0.0; //Debug.WriteLine((int)i); } } //players[(int)drumType].Volume = 1.0; players[(int)drumType]?.Play(); animations[(int)drumType]?.Commit(this, drumType.ToString()); }
/// <summary> /// 抬起敲下的鼓 /// </summary> /// <param name="dt"></param> /// <param name="iterate"></param> public void RelaseKnockPlay(DrumType dt) { switch (dt) { case DrumType.LeftFace: RelaseLeftFace(); break; case DrumType.RightFace: RelaseRightFace(); break; case DrumType.LeftSide: RelaseLeftSide(); break; case DrumType.RightSide: RelaseRightSide(); break; case DrumType.FaceAll: RelaseLeftFace(); RelaseRightFace(); break; case DrumType.SideAll: RelaseLeftSide(); RelaseRightSide(); break; } if (Knocked != null) { DrumKnockArgs dka = new DrumKnockArgs(); dka.DrumType = dt; Knocked(this, dka); } }
private void PlayDrum(DrumType drumType) { _fmod.PlaySound(_drums[drumType]); _fmod.Update(); }
/// <summary> /// 判断按键是否符合游戏规则 /// </summary> private bool KnockKeyIsCodex(CadenceSign cs, DrumType k) { bool isCodex = false; if (k == cs.drumType) isCodex = true; if (k == DrumType.LeftSide && cs.drumType == DrumType.RightSide) isCodex = true; if (k == DrumType.RightSide && cs.drumType == DrumType.LeftSide) isCodex = true; if (k == DrumType.LeftFace && cs.drumType == DrumType.RightFace) isCodex = true; if (k == DrumType.RightFace && cs.drumType == DrumType.LeftFace) isCodex = true; return isCodex; }
/// <summary> /// 通知有按键按下 /// </summary> /// <param name="key"></param> public void NotifyKeyDown(DrumType dt) { if (SignEnd()) return; for (int i = indexActual; i < signCount; ) { if (null == CadenceSigns) return; CadenceSign cs = CadenceSigns[i]; double atime = (lapseTime - arriveEndPointOffset);// / (1 * speed);//当前实际流逝时间 if (CommHelper.Abs(cs.DelayTimeMill - atime) <= normalArrage) { //double lv = Canvas.GetLeft(cs.currentSign); cs.currentSign.Visibility = Visibility.Collapsed; LayoutRoot.Children.Remove(cs.currentSign); indexActual++; cs.state = 2; HitArgs ha = new HitArgs(); ha.DrumType = dt; ha.SignSource = cs; ha.HitType = HitType.Normal; if (cs.drumType != DrumType.FaceAll && cs.drumType != DrumType.SideAll) { cs.DelayTimeMill -= (int)(10 * speed); } if (CommHelper.Abs(cs.DelayTimeMill - atime) <= niceArrage) { ha.HitType = HitType.Nice; } //得分算出来后计算按键是否对应 if (!KnockKeyIsCodex(cs, dt)) { ha.HitType = HitType.Lost; } OnHit(this, ha); return; } else if (CommHelper.Abs(cs.DelayTimeMill - atime) <= lostArrage) { RemoveAndSendMsg(cs, 1, HitType.Lost); return; } else { return;//没有满足的直接跳出 } } }
void OnDrumButton(DrumType drumType) { players[(int)drumType]?.Play(); animations[(int)drumType]?.Commit(this, drumType.ToString()); }
public Note(long ticks, DrumType drumType) { Ticks = ticks; DrumType = drumType; }