forked from ScruffyFurn/SumoDX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SumoDX.h
105 lines (77 loc) · 3 KB
/
SumoDX.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
// SumoDX:
// This is the main game class. It controls game play logic and game state.
// Some of the key object classes used by SumoDX are:
// MoveLookController - for handling all input to control player/camera/cursor movement.
// GameRenderer - for handling all graphics presentation.
// Camera - for handling view projections.
// m_renderObjects <GameObject> - is the list of all objects in the scene that may be rendered.
#include "../GameObjects/GameConstants.h"
#include "../GameObjects/Camera.h"
#include "../GameObjects/GameObject.h"
#include "../Utilities/GameTimer.h"
#include "../Input/MoveLookController.h"
#include "../Utilities/PersistentState.h"
#include "../Rendering/GameRenderer.h"
#include "../GameObjects/AISumoBlock.h"
#include "../GameObjects/SumoBlock.h"
//--------------------------------------------------------------------------------------
enum class GameState
{
Waiting,
Active,
PlayerLost,
GameComplete,
};
typedef struct
{
Platform::String^ tag;
float bestRoundTime;
} HighScoreEntry;
typedef std::vector<HighScoreEntry> HighScoreEntries;
//--------------------------------------------------------------------------------------
ref class GameRenderer;
ref class SumoDX
{
internal:
SumoDX();
void Initialize(
_In_ MoveLookController^ controller,
_In_ GameRenderer^ renderer
);
void LoadGame();
void StartLevel();
void PauseGame();
void ContinueGame();
GameState RunGame();
void OnSuspending();
void OnResuming();
bool IsActivePlay() { return m_timer->Active(); }
int RoundTime() { return m_timer->PlayingTime(); }
bool GameActive() { return m_gameActive; }
HighScoreEntry HighScore() { return m_topScore; }
Camera^ GameCamera() { return m_camera; }
std::vector<GameObject^> RenderObjects() { return m_renderObjects; }
private:
void LoadState();
void SaveState();
void SaveHighScore();
void LoadHighScore();
void UpdateDynamics();
MoveLookController^ m_controller;
GameRenderer^ m_renderer;
Camera^ m_camera;
HighScoreEntry m_topScore;
PersistentState^ m_savedState;
GameTimer^ m_timer;
bool m_gameActive;
SumoBlock^ m_player;
AISumoBlock^ m_enemy;
std::vector<GameObject^> m_renderObjects; // List of all objects to be rendered.
};