public void OnMouse(ref Game.state nowstate, ref bool redraw, Point p, double width_, double height_) { if (Helper.PointIn(p, width_ / 2, height_ / 2, width_ / 2 + 200, height_ / 2 + 200)) { nowstate = Game.state.Selecting; Stop(ref redraw); } }
public void OnKey(ref bool redraw, ref Game.state nowstate, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Escape) { nowstate = Game.state.Menu; redraw = true; } }
public void OnMouse(ref Game.state nowstate, ref bool redraw, Point p, double width_, double height_) { if (Helper.PointIn(p, width_ / 2, height_ / 2, width_ / 2 + 40, height_ / 2 + 40)) { nowstate = Game.state.Selecting; summarysong.Stop(); redraw = true; } }
public void OnKey(ref Game.state nowstate, ref bool redraw, KeyEventArgs e, ref Playing playing) { if (e.Key == Key.Right) { selectIndex = (selectIndex + 1) % songList.Count; difficultyIndex = 0; redraw = true; fade = true; } else if (e.Key == Key.Left) { selectIndex = (selectIndex - 1 + songList.Count) % songList.Count; difficultyIndex = 0; redraw = true; fade = true; } else if (e.Key == Key.Space || e.Key == Key.Enter) { nowstate = Game.state.Playing; playing.song = song; playing.factor = factor; playing.song.LoadAll(difficultyIndex); Stop(ref redraw); } else if (e.Key == Key.Escape) { nowstate = Game.state.Menu; Stop(ref redraw); } else if (e.Key == Key.Down) { difficultyIndex = (difficultyIndex + 1) % song.difficuties.Count(); redraw = true; } else if (e.Key == Key.Up) { difficultyIndex = (difficultyIndex - 1 + song.difficuties.Count()) % song.difficuties.Count(); redraw = true; } else if (e.Key == Key.Add) { if (factor <= 1) { factor += 0.05; redraw = true; } } else if (e.Key == Key.Subtract) { if (factor >= 0.10) { factor -= 0.05; redraw = true; } } }
public void OnKey(ref Game.state nowstate, ref bool redraw, KeyEventArgs e) { Console.WriteLine("Key Down: " + e.Key); if (e.Key == Key.Escape || e.Key == Key.Enter) { nowstate = Game.state.Selecting; redraw = true; summarysong.Stop(); } }
public void OnMouse(ref Game.state state, ref bool redraw, Point p, double width_, double height_, ref Playing playing) { if (Helper.PointIn(p, 260, 380, 260 + 120, 380 + 40)) { state = Game.state.Playing; playing.song = song; playing.factor = factor; playing.song.LoadAll(difficultyIndex); state = Game.state.Playing; Stop(ref redraw); } }
public void OnMouse(ref Game.state nowstate, ref bool redraw, Point p, double width_, double height_) { if (Helper.PointIn(p, 253, 350, 253 + 128, 350 + 40)) { redraw = true; nowstate = Game.state.Menu; } if (Helper.PointIn(p, 253 + 120 + 50, 350, 253 + 120 + 50 + 115, 350 + 40)) { redraw = true; nowstate = Game.state.Selecting; } }
public void OnKey(ref Game.state nowstate, ref bool redraw, KeyEventArgs e) { if (e.Key == Key.Space || e.Key == Key.Enter) { nowstate = Game.state.Selecting; Stop(ref redraw); } else if (e.Key == Key.Tab) { nowstate = Game.state.GameHelper; Stop(ref redraw); } }
public void OnDraw(CanvasHelper cv, ref bool redraw, ref Game.state state) { if (redraw) { cv.cv.Children.Clear(); GameStart(); song.bgm.Position = TimeSpan.Zero; //idx = 0; redraw = false; } cv.cv.Children.Clear(); cv.Image(0, 0, cv.width, cv.height, song.picture); //cv.Image(stageOffset, 0, 203, 480,(Brush) resources["img-stage"]); cv.Rectangle(28, 0, 162 - 28, 480, 1, Helper.Color("#fff", 0.1), Helper.Color("#000", 0.1)); foreach (double x in segments) { cv.line(x, 0, x, 406); } for (int i = 0; i < song.notes.Count; i++) { song.notes[i].Draw(cv, t, segments, resources, factor); } t = Convert.ToDecimal(song.bgm.Position.TotalMilliseconds); //绘制轨道光 for (int i = 0; i < 4; ++i) { if ((keyPressed & (1 << i)) > 0) { cv.Image(segments[i], 406 - 350, segments[i + 1] - segments[i], 350, (Brush)resources["img-light"]); if (i == 0 || i == 3) { cv.Image(segments[i], 413, segments[i + 1] - segments[i], 480 - 413, (Brush)resources["img-key1D"]); } else { cv.Image(segments[i], 413, segments[i + 1] - segments[i], 480 - 413, (Brush)resources["img-key2D"]); } } else { if (i == 0 || i == 3) { cv.Image(segments[i], 413, segments[i + 1] - segments[i], 480 - 413, (Brush)resources["img-key1"]); } else { cv.Image(segments[i], 413, segments[i + 1] - segments[i], 480 - 413, (Brush)resources["img-key2"]); } } } //绘制combo { int c = combo; //求总位数算位置 int n = 0; do { c /= 10; n++; } while (c != 0); c = combo; int i = 0; do { cv.Image(segments[2] - 22 + 12 * n - 25 * i, 70, 25, 25, (Brush)resources["img-score-" + c % 10]); ++i; c /= 10; } while (c != 0); } //绘制分数,score += combo + note.status { int s = score; int n = 0; do { s /= 10; n++; } while (s != 0); s = score; int i = 0; do { cv.Image(350 + 12 * n - 25 * i, 50, 25, 25, (Brush)resources["img-score-" + s % 10]); ++i; s /= 10; } while (s != 0); } //Miss判定逻辑 foreach (Note note in song.notes) { if (note.status == Note.Status.Free) { if (note.time < t - 200) { note.status = Note.Status.Miss; note.endstatus = Note.Status.Miss; judgeUI = "0"; combo = 0; } } else if (note.type == Note.Type.Hold && note.endstatus == Note.Status.Free) { if (note.endtime < t - 200) { note.endstatus = Note.Status.Miss; judgeUI = "0"; combo = 0; } } } //绘制判定UI if (judgeUI != null) { double x1 = segments[1] - (segments[2] - segments[1]) / 2; Brush b = ((Brush)resources["img-hit-" + judgeUI]).Clone(); b.Opacity = (double)judgeUITimeout / 10; double scale = judgeUITimeout; Console.WriteLine(judgeUI); cv.Image(x1 - scale, 300 - scale, (segments[4] + segments[3]) / 2 - x1 + 2 * scale, 20 + 2 * scale, b); if (--judgeUITimeout < 5) { ResetJudgeUI(); } } if (song.bgm != null && song.bgm.NaturalDuration.HasTimeSpan && song.bgm.Position.TotalSeconds >= song.bgm.NaturalDuration.TimeSpan.TotalSeconds) { Thread.Sleep(3000); state = Game.state.Summary; redraw = true; } }
public void OnKey(ref Game.state nowstate, ref bool redraw, KeyEventArgs e) { if (e.Key == Key.Escape) { song.bgm.Stop(); nowstate = Game.state.Selecting; redraw = true; } else if (e.Key == Key.Oem3) { song.bgm.Stop(); GameStart(); //song.bgm.Play(); } else if (e.Key == Key.P) { song.bgm.Stop(); nowstate = Game.state.Summary; redraw = true; } else { if (e.Key == Key.D) { keyPressed |= 1; } else if (e.Key == Key.F) { keyPressed |= 2; } else if (e.Key == Key.J) { keyPressed |= 4; } else if (e.Key == Key.K) { keyPressed |= 8; } else { return; } } decimal t = Convert.ToDecimal(song.bgm.Position.TotalMilliseconds); // Key effect ((MediaPlayer)resources["wav-se"]).Position = TimeSpan.Zero; ((MediaPlayer)resources["wav-se"]).Play(); Note note; int dt = FindClosestFreeNote(song.notes, e.Key, t, false, out note); error = dt; if (note != null) { if (null != note.Judge(t, false, ref combo, ref score)) { //按键判定有效,显示判定UI ShowJudgeUI(note.status); } } }