CSC3224_Computer_Games_Development / GameEngine / Engine_Graphics / Scene.h
Scene.h
Raw
#pragma once
#include "../Engine_Common/Common.h"
#include "../Engine_Resource_Management/ResourceManagement.h"
#include "../Engine_Resource_Management/EntityManagement.h"
#include "../Engine_Messaging_System/EngineMessageSystem.h"
#include "../Engine_Physics/EnginePhysicsSystem.h"
#include "../Engine_Graphics/EngineRenderingSystem.h"
#include "../Engine_Audio/EngineAudioSystem.h"
#include "../Engine_Physics/SpriteRectangle.h"
#include "Box2D/Box2D/Common/b2Math.h"
#include "../Engine_Profiler/Profiler.h"
#include <SFML/System/Clock.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <iostream>
// The Scene created in the Window, everything inside the game
class Scene
{
public:
	enum SceneState
	{		
		INITIALIZATION_STATE,
		RUNNING_STATE,
		QUITTING_STATE,
		SHUTDOWN_STATE,
		CHOOSING_CHARACTER_STATE,
		CHANGE_WINDOW_STATE,
		CLOSE_WINDOW_STATE, 
		RESTART_SUB_SYSTEMS_STATE,
		SPLASH_SCREEN_STATE,
		MAIN_MENU_STATE,
		RETURN_TO_MAIN_MENU_STATE,
		LEVEL_TEST,
		LEVEL_1,
		LEVEL_2,
		LEVEL_3
	};
	sf::Time fontElapsedTime;
	explicit Scene(ResourceManagement& resourceManagement, float time = 1.0f);
	~Scene();
	void changeSceneState(SceneState inputSceneState) { sceneState = inputSceneState; };
	SceneState getSceneState() const { return sceneState; };
	void addSceneSystem(EngineMessageSystem* engineSystemMessage);
	void sendSceneSystemMessage(const SystemMessage& systemMessage);
	void playScene(const sf::Time& gameTime);
	void drawScene(sf::RenderWindow& renderWindow, ResourceManagement& resourceManager);
	EntityManagement& getEntityManagement();
	EnginePhysicsSystem& getEnginePhysicsSystem() const;
	sf::Text text;
	void enableDebugTextOnScene(bool enable) { setFont = enable; }
	Profiler addEnginePhysicsLoadingTimes;
	Profiler addEngineRenderingLoadingTimes;
	Profiler addEngineAudioSystemLoadingTimes;
	float saveFPS(float fps) { return fps = fpsCounter; }
	float fpsCounter;
	// Draw all sprites
	std::vector<SpriteRectangle*> spriteRectangleVector;
protected:
// Set the default physics for player character 
	float physicsXInput = 0.0f;
	float physicsYInput = 15.0f;
//Set the default Font
	std::string defaultFont = "gara.ttf";
	SceneState sceneState;
	EntityManagement entityManagement;
	EnginePhysicsSystem* enginePhysicsSystem;
// Store engine messages
	std::vector<EngineMessageSystem*>  engineMessageSystem;
// Render scene
	friend void EngineRenderingSystem::play(const sf::Time& elapsedTime);

// Scale time to one unit
	float scaleTime;
// Set font style
	bool setFont = false;
	float fontSize = 5.0f;
	sf::Font font;
};