示例#1
0
void World::reset(int levelIndex, int difficultyLevel)
{
	m_spawnPointsState = World_Spawn_Points_State::COUNTING_DOWN;
	m_fSpawnPointsStateTime = 0;
	m_fWaveWaitTime = 5;
	m_difficultyLevel = difficultyLevel;
	m_iLevelIndex = levelIndex;
	m_iWave = 0;
	m_iScoreEarnedThisFrame = 0;
	m_iTimesCoreShipModuleHitThisFrame = 0;

	m_spawns.clear();
	m_platforms.clear();
	m_creeps.clear();
	m_creepBodyParts.clear();
	m_towers.clear();
	m_projectiles.clear();
	m_projectileParticles.clear();
	m_electricBolts.clear();
	m_lazerBeams.clear();
	m_iceBlasts.clear();
	m_missiles.clear();
	m_explosions.clear();
	m_fireBolts.clear();
	m_toxicClouds.clear();
	m_acidDrops.clear();

	generateWorld();
}
示例#2
0
Victory::Victory(float xPosition, float yPosition) : 
	WorldObject(AB_VICTORY, xPosition, yPosition),
	restartButton(Button(xPosition + AB_VICTORY_TEXT_OFFSET_X,
	yPosition + AB_VICTORY_TEXT_OFFSET_Y)),
	victoryText(HUDElement(xPosition + AB_VICTORY_MSG1_X, yPosition + AB_VICTORY_MSG1_Y)),
	teamText(HUDElement(xPosition + AB_VICTORY_MSG2_X, yPosition + AB_VICTORY_MSG2_Y)) {
		auto armyengine = ArmyEngine::getInstance();
		auto componentFactory = armyengine->getComponentFactory();
		//setup the shape component to represent the border of the 
		// victory screen
		auto shapeComponent = componentFactory.createShapeComponent(AB_VICTORY_SHAPE);
		this->getEntity()->addComponent(shapeComponent);

		//shape attributes
		shapeComponent->setAttribute_int(ATTRIBUTE_ENABLE, 0);
		shapeComponent->setAttribute_string(ATTRIBUTE_SHAPE_TYPE, SHAPETYPE_RECTANGLE);
		shapeComponent->setAttribute_float(ATTRIBUTE_WIDTH, 400.0);
		shapeComponent->setAttribute_float(ATTRIBUTE_HEIGHT, 400.0);
		COLOR_FILL_BLACK(shapeComponent);
		COLOR_OUTLINE_GREEN(shapeComponent);
		shapeComponent->update();

		//button parameters
		restartButton.hide();
		restartButton.setButtonText("Restart");
		restartButton.setSize(200, 100);
		restartButton.setButtonCallback((functionEventTemplate) [] (int ID, int eventIndex) {
			auto entityManager = EntityManager::getInstance();
			auto entity = entityManager->getEntityById(ID);
			sf::Event theEvent = *EventManager::getInstance()->getEvents()[eventIndex];
			auto mouseButton = theEvent.mouseButton.button;
			if (mouseButton == sf::Mouse::Button::Left) {
				auto world = World::getInstance();
				world->menu.hide();
				world->victory.hide();
				world->generateWorld();
				EntityManager::getInstance()->sortEntityList();

#ifdef LOGGING
				std::cout << "Restart Button Pressed" << std::endl;
#endif //LOGGING
			}
			return 0;
		});

		//set the Z-buffer of the text to show
		auto textComponent = restartButton.buttonHUDElement.getEntity()->getComponentByName(AB_HUD_TEXT);
		textComponent->setAttribute_float(ATTRIBUTE_ZBUFFER, 16.0);

		//change the text size for the restart button
		restartButton.buttonHUDElement.setTextSize(50);

		//text parameters
		victoryText.setSuccessString(AB_VICTORY_MSG1);
		victoryText.hide();
		teamText.setSuccessString("");
		teamText.hide();

}
示例#3
0
/** \brief Generates the vertices and elements necessary to represent the heightmap
*
*/
void Heightmap::create()
{
    heightmap.loadFromFile(imagePath);

	mapWidth = heightmap.getSize().y;
	mapDepth = heightmap.getSize().x;

    vertexSize = mapDepth * mapWidth * 6;
    elementSize = 3*(vertexSize*3 - mapDepth*3 - (mapWidth-1)*3);

    vertices = new GLfloat[vertexSize];
	elements = new GLuint[elementSize];

    generateWorld(heightmap, vertices);
    generateElements(elements, vertices);
}
示例#4
0
World::World(int numCities)
{
    generateWorld(numCities);
}