Exemple #1
0
QVariant QtSkillModel::data(const QModelIndex& index, int role) const {
	if (!index.isValid()) return QVariant();
	boost::shared_ptr<SkillItem> item = getItem(index);
	if (!item) return QVariant();

	SkillLevel::ref skillLevel = boost::dynamic_pointer_cast<SkillLevel>(item);
	return skillLevel ? getLevelData(skillLevel, role) : getItemData(item, role);
	
}
Exemple #2
0
	vector<string> getLevelIdsByPack(string mPackPath)
	{
		vector<LevelData> levelDataVector;
		for(string id : levelIdsByPackMap[mPackPath]) levelDataVector.push_back(getLevelData(id));

		sort(begin(levelDataVector), end(levelDataVector),
		[](LevelData a, LevelData b)
		{
			return a.getMenuPriority() < b.getMenuPriority();
		});

		vector<string> result;
		for(auto levelData : levelDataVector) if(levelData.getSelectable()) result.push_back(levelData.getId());
		return result;
	}
void HexagonGame::newGame(string mId, bool mFirstPlay)
{
    clearMessages();

    setLevelData(getLevelData(mId), mFirstPlay);

    stopAllSounds();
    playSound("play");

    pm->resetAdj();

    stopLevelMusic();
    playLevelMusic();

    rotationDirection = getRnd(0, 100) > 50 ? true : false;

    scripts.clear();

    timeStop = 0;
    randomSideChangesEnabled = true;
    incrementEnabled = true;
    maxPulse = 85;
    minPulse = 75;
    pulseSpeedBackwards = 1;
    pulseSpeed = 1;

    hasDied = false;
    mustRestart = false;
    currentTime = 0;
    incrementTime = 0;
    setSides(levelData.getSides());
    radius = minPulse;

    manager.clear();
    createPlayer(manager, this, centerPos);

    scriptsTimeline = Timeline{};
    messagesTimeline = Timeline{};
    timeline = Timeline{};
}
Exemple #4
0
	void HexagonGame::newGame(const string& mId, bool mFirstPlay, float mDifficultyMult)
	{
		firstPlay = mFirstPlay;
		setLevelData(getLevelData(mId), mFirstPlay);
		difficultyMult = mDifficultyMult;

		// Audio cleanup
		stopAllSounds();
		playSound("go.ogg");
		stopLevelMusic();
		playLevelMusic();

		// Events cleanup
		clearMessage();

		for(auto eventPtr : eventPtrs) delete eventPtr;
		eventPtrs.clear();

		while(!eventPtrQueue.empty()) { delete eventPtrQueue.front(); eventPtrQueue.pop(); }
		eventPtrQueue = queue<EventData*>{};

		// Game status cleanup
		status = HexagonGameStatus{};
		restartId = mId;
		restartFirstTime = false;
		setSides(levelData.getSides());

		// Manager cleanup
		manager.clear();
		factory.createPlayer();

		// Timeline cleanup
		timeline.clear(); timeline.reset();
		messageTimeline.clear(); messageTimeline.reset();
		effectTimelineManager.clear();

		// FPSWatcher reset
		fpsWatcher.reset();
		if(getOfficial()) fpsWatcher.enable();

		// LUA context cleanup
		if(!mFirstPlay) runLuaFunction<void>("onUnload");
		lua = Lua::LuaContext{};
		initLua();
		runLuaFile(levelData.getValueString("lua_file"));
		runLuaFunction<void>("onLoad");

		// Random rotation direction
		if(getRnd(0, 100) > 50) setRotationSpeed(getRotationSpeed() * -1);

		// Reset zoom
		overlayCamera.setView({{getWidth() / 2.f, getHeight() / 2.f}, sf::Vector2f(getWidth(), getHeight())});
		backgroundCamera.setView({{0, 0}, {getWidth() * getZoomFactor(), getHeight() * getZoomFactor()}});
		backgroundCamera.setRotation(0);

		// 3D Cameras cleanup
		depthCameras.clear();
		unsigned int depth{styleData.get3DDepth()};
		if(depth > get3DMaxDepth()) depth = get3DMaxDepth();
		for(unsigned int i{0}; i < depth; ++i) depthCameras.push_back({window, {}});
	}