なんか,結構な期間このサイトを見てきた感じ,
- Scene とかいう謎の基底
- Task とかいう(同上)
- XXXManager とかいうクソみてぇな名称の何か
何故彼らはこれらを好むのだろうか?
もちろん,それで何かが楽になるのであれば良いのだが,楽になってない方々は何なの?っていう.
意味わかんねぇ謎の実装形態を(どこかから持ってきて)採用したら直後に実装作業に行き詰るであろうことは明白であると思うのだが.
マゾなのか?
class Scene
{
public:
virtual ~Scene(){}
///<summary>Called when this instance is selected as the current scene.</summary>
virtual void OnSelectedAsCurrent( IGameContext &Context ) = 0;
///<returns>Whether a redraw is required. (If returns true, <see cref="Paint"/> will be called.)</returns>
///<remarks>
///If this method calls IGameContext::TransToXXXScene() method and returns true,
///Paint() of other instance correspond to the target scene will be called (rather than of this instance).
///</remarks>
virtual bool Update( IGameContext &Context, const Input_b &rInput, RndGenerator &Rnd ) = 0;
//
virtual void Paint( HDC hdc, const IGameContext &Context ) const = 0;
};
enum class DifficultyLV { Normal, Hard };
//Scene側から,ゲームの全体的な状況に対して何かするのに必要な処理手段を提供する
class IGameContext
{
public:
virtual ~IGameContext(){}
public:
virtual void TransToTitleScene() = 0;
virtual void TransToGamePlayScene( DifficultyLV GameLV ) = 0;
public:
///<returns>
///Returns the difficulty that selected as argument to <see cref="TransToGamePlayScene"/>
///</returns>
virtual DifficultyLV GetCurrentGameLV() const = 0;
///<returns>
///This method always returns the same value.
///(left, top) is (0,0), and (width, height) is paintable range size.
///</returns>
virtual const RECT &ViewRect() const = 0;
};
void 管理側具体実装::TransToTileScene()
{//「カレントのシーン」を「タイトルシーン」にすげ替える最もシンプルな実装ってこんな感じだよねきっと
delete m_pCurrentScene; //おおっと!
m_pCurrentScene = new TitleScene();
}