OSDN Git Service

6ad199a555a305e47ff21eec6cf96802c55cd891
[strokestylet/CsWin10Desktop3.git] / StrokeStyleT / ステージ / 結果 / 結果ステージ.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Linq;
5 using FDK.メディア;
6
7 namespace SST.ステージ.結果
8 {
9         /// <summary>
10         /// 入力:
11         ///  Action BGMを終了する
12         ///  Func<SST.ステージ.演奏.演奏ステージ> 演奏ステージインスタンスを取得する
13         ///  
14         /// 出力:
15         ///  なし
16         /// </summary>
17         class 結果ステージ : ステージ
18         {
19                 public enum フェーズ
20                 {
21                         初期状態,
22                         表示中,
23                         終了,
24                 }
25                 public フェーズ 現在のフェーズ { get; protected set; } = フェーズ.初期状態;
26
27                 // 外部依存 Action。
28                 public Action BGMを終了する = null;
29                 public Func<SST.ステージ.演奏.演奏ステージ> 演奏ステージインスタンスを取得する = null;
30
31                 public 結果ステージ()
32                 {
33                         this.子リスト.Add( this.背景動画 = new 動画( @"$(Static)\images\結果画面BGV.mp4", StrokeStyleT.Config.動画デコーダのキューサイズ ) );
34                         this.子リスト.Add( this.背景画像 = new 画像( @"$(Static)\images\結果画面 背景.png" ) );
35                         this.子リスト.Add( this.結果表示パラメータパネル = new 画像( @"$(Static)\images\結果画面 パラメータパネル.png" ) );
36                         this.子リスト.Add( this.結果表示パラメータ = new 画像フォント( @"$(Static)\images\結果画面 パラメータフォント.png", @"$(Static)\images\結果画面 パラメータフォント矩形リスト.xml" ) );
37                 }
38                 protected override void On活性化( デバイスリソース dr )
39                 {
40                         FDK.Log.Info( "結果ステージを開始します。" );
41
42                         this.背景動画.ループ再生する = true;
43                         this.現在のフェーズ = フェーズ.表示中;
44                 }
45                 protected override void On非活性化( デバイスリソース dr )
46                 {
47                         FDK.Log.Info( "結果ステージを終了します。" );
48
49                         this.BGMを終了する?.Invoke();    // ここでBGMを終了する。
50                 }
51                 public override void 進行描画する( デバイスリソース dr )
52                 {
53                         // 進行描画。
54
55                         this.背景動画.進行描画する( dr, new SharpDX.RectangleF( 0f, 0f, dr.設計画面サイズdpx.Width, dr.設計画面サイズdpx.Height ) );
56                         this.背景画像.描画する( dr, 0f, 0f );
57
58                         #region " 結果表示パラメータ "
59                         //----------------
60                         this.結果表示パラメータパネル.描画する( dr, 60f, 196f );
61
62                         var 演奏ステージ = this.演奏ステージインスタンスを取得する();
63                         var hitTypes = new[] { 演奏.ヒット判定種別.PERFECT, 演奏.ヒット判定種別.GREAT, 演奏.ヒット判定種別.GOOD, 演奏.ヒット判定種別.POOR, 演奏.ヒット判定種別.MISS, 演奏.ヒット判定種別.AUTO };
64
65                         int 総数 = 0;
66                         foreach( var hitType in hitTypes )
67                                 総数 += 演奏ステージ.ヒットした回数[ hitType ];
68
69                         float Xdpx = 360f;
70                         float Ydpx = 230f;
71                         foreach( var hitType in hitTypes )
72                         {
73                                 int 回数 = 演奏ステージ.ヒットした回数[ hitType ];
74                                 double 割合 = ( 0 < 総数 ) ? ( 回数 * 100.0 / 総数 ) : 0.0;
75                                 this.結果表示パラメータ.描画する( dr, Xdpx, Ydpx, $"{回数:00000}({割合:000.0}%)" );
76                                 Ydpx += 71f;
77                         }
78                         //----------------
79                         #endregion
80
81                         // 入力。
82
83                         StrokeStyleT.すべての入力デバイスをポーリングする();
84
85                         // Enter or ESC 押下 → ステージ終了。
86                         if( StrokeStyleT.キーボード入力.キーが押された( SharpDX.DirectInput.Key.Return ) ||
87                                 StrokeStyleT.キーボード入力.キーが押された( SharpDX.DirectInput.Key.Escape ) )
88                         {
89                                 this.現在のフェーズ = フェーズ.終了;
90                         }
91                 }
92
93                 protected readonly FDK.メディア.動画 背景動画;
94                 protected readonly FDK.メディア.画像 背景画像;
95                 protected readonly FDK.メディア.画像 結果表示パラメータパネル;
96                 protected readonly FDK.メディア.画像フォント 結果表示パラメータ;
97         }
98 }