OSDN Git Service

進行と描画を分離していた箇所のうち、高速進行が不要なものは進行描画メソッドに移行。
[strokestylet/CsWin10Desktop3.git] / StrokeStyleT / ステージ / 結果 / 結果ステージ.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Linq;
5 using SharpDX;
6 using SharpDX.DirectInput;
7 using FDK;
8 using FDK.メディア;
9
10 namespace SST.ステージ.結果
11 {
12         class 結果ステージ : ステージ
13         {
14                 public enum フェーズ
15                 {
16                         表示中,
17                         完了,
18                 }
19
20                 public フェーズ 現在のフェーズ
21                 {
22                         get;
23                         protected set;
24                 }
25
26                 public 結果ステージ()
27                 {
28                         this.子リスト.Add( this._背景画像 = new 画像( @"$(System)images\結果画面 背景.png" ) );
29                         this.子リスト.Add( this._背景動画 = new 動画( @"$(System)images\結果画面BGV.mp4", App.システム設定.動画デコーダのキューサイズ ) );
30                         this.子リスト.Add( this._結果表示パラメータ = new 画像フォント( @"$(System)images\結果画面 パラメータフォント.png", @"$(System)\images\結果画面 パラメータフォント矩形リスト.xml" ) );
31                         this.子リスト.Add( this._結果表示パラメータパネル = new 画像( @"$(System)images\結果画面 パラメータパネル.png" ) );
32                 }
33
34                 protected override void On活性化( グラフィックデバイス gd )
35                 {
36                         using( Log.Block( FDKUtilities.現在のメソッド名 ) )
37                         {
38                                 this.現在のフェーズ = フェーズ.表示中;
39                                 this._活性化した直後である = true;
40                         }
41                 }
42
43                 protected override void On非活性化( グラフィックデバイス gd )
44                 {
45                         using( Log.Block( FDKUtilities.現在のメソッド名 ) )
46                         {
47                                 // ここでBGMを終了する。
48                                 var stage = (演奏.演奏ステージ) App.ステージ管理.ステージリスト[ nameof( 演奏.演奏ステージ ) ];
49                                 stage.BGMを停止する();
50
51                                 this.現在のフェーズ = フェーズ.完了;
52                                 this._活性化した直後である = false;
53                         }
54                 }
55
56                 public override void 進行描画する( グラフィックデバイス gd )
57                 {
58                         if( this._活性化した直後である )
59                         {
60                                 this._背景動画.再生を開始する( 開始位置sec: 0.0, ループ再生する: true );
61                                 this._活性化した直後である = false;
62                         }
63
64                         switch( this.現在のフェーズ )
65                         {
66                                 case フェーズ.表示中:
67                                         // 描画
68                                         this._背景動画.描画する( gd, new RectangleF( 0f, 0f, gd.設計画面サイズ.Width, gd.設計画面サイズ.Height ) );
69                                         this._背景画像.描画する( gd, 0f, 0f );
70                                         #region " 結果表示パラメータ "
71                                         //----------------
72                                         this._結果表示パラメータパネル.描画する( gd, 60f, 196f );
73
74                                         var 演奏ステージ = (演奏.演奏ステージ) App.ステージ管理.ステージリスト[ nameof( 演奏.演奏ステージ ) ];
75                                         var hitRankTypes = new[] { 演奏.ヒットランク種別.PERFECT, 演奏.ヒットランク種別.GREAT, 演奏.ヒットランク種別.GOOD, 演奏.ヒットランク種別.POOR, 演奏.ヒットランク種別.MISS, 演奏.ヒットランク種別.AUTO };
76
77                                         int 総数 = 0;
78                                         foreach( var type in hitRankTypes )
79                                                 総数 += 演奏ステージ.ヒットランク別ヒット回数[ type ];
80
81                                         float X = 360f;
82                                         float Y = 230f;
83                                         foreach( var type in hitRankTypes )
84                                         {
85                                                 int 回数 = 演奏ステージ.ヒットランク別ヒット回数[ type ];
86                                                 double 割合 = ( 0 < 総数 ) ? ( 回数 * 100.0 / 総数 ) : 0.0;
87                                                 this._結果表示パラメータ.描画する( gd, X, Y, $"{回数:00000}({割合:000.0}%)" );
88                                                 Y += 71f;
89                                         }
90                                         //----------------
91                                         #endregion
92
93                                         // 入力
94                                         App.入力管理.すべての入力デバイスをポーリングする();
95
96                                         if( App.入力管理.キーボードデバイス.キーが押された( 0, Key.Escape ) || App.入力管理.シンバルが入力された() )
97                                         {
98                                                 #region " シンバル or ESC → ステージ終了。"
99                                                 //----------------
100                                                 this.現在のフェーズ = フェーズ.完了;
101                                                 //----------------
102                                                 #endregion
103                                         }
104                                         break;
105
106                                 case フェーズ.完了:
107                                         break;
108                         }
109                 }
110
111                 private bool _活性化した直後である = false;
112
113                 private 画像 _背景画像 = null;
114
115                 private 動画 _背景動画 = null;
116
117                 private 画像フォント _結果表示パラメータ = null;
118
119                 private 画像 _結果表示パラメータパネル = null;
120         }
121 }