Пример #1
0
void Game::updateWorld()
{
	double secsElapsed = mElapsed.restart() / 1000.0;
	world()->update(secsElapsed);

	emit worldUpdated();
}
Пример #2
0
GameUI::GameUI()
{
	resize(1000, 800);
	setWindowTitle("Adage");

	QDockWidget *dock = new QDockWidget(tr("Shell"), this);
	ShellWindow *shell = new ShellWindow(dock);
	//ShellInterface *shellInt = new ShellInterface(shell);
	dock->setWidget(shell);
	addDockWidget(Qt::RightDockWidgetArea, dock);

	dock = new QDockWidget(tr("Comm"), this);
	CommWindow *comm = new CommWindow(dock);
	dock->setWidget(comm);
	addDockWidget(Qt::RightDockWidgetArea, dock);

	//connect(mBtnClose, SIGNAL(clicked()), this, SLOT(close()));

	mGame = new Game(comm);
	//connect(mGame, SIGNAL(worldUpdated()), this, SLOT(update()));

	//TEST GAME ENTITIES GO HERE
	Map* map = new Map(mGame->world());
	QFile* file = new QFile("data/map.map");
	bool result = file->open(QIODevice::ReadOnly | QIODevice::Text);
	assert(result); //TODO error handling
	map->load(file);

	/*QFile* outFile = new QFile("map-out.map");
	result = outFile->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
	assert(result);
	map->save(outFile);*/

	new GhostBustersHQ(mGame->world());

	for (int i=0; i<60; ++i) //ghost food
		new Person(Math::Point(Math::randFloat(-75,75),Math::randFloat(-80,90)), mGame->world());
	for (int i=0; i<60; ++i)
		new Person(Math::Point(Math::randFloat(-75,75),Math::randFloat(190,260)), mGame->world());
	for (int i=0; i<20; ++i)
		new Ghost(Math::Point(Math::randFloat(-100,100),Math::randFloat(-100,100)), mGame->world());
	for (int i=0; i<20; ++i)
		new Ghost(Math::Point(Math::randFloat(-100,100),Math::randFloat(180,380)), mGame->world());
	for (int i=0; i<4; ++i)
		new GhostBuster(Math::Point(Math::randFloat(-75,75),Math::randFloat(-90,90)), mGame->world());
	for (int i=0; i<4; ++i)
		new GhostBuster(Math::Point(Math::randFloat(-75,75),Math::randFloat(190,270)), mGame->world());

	Navigator* navvy = new Navigator(mGame->world());
	mGame->setNavvy(navvy);

	mBlueprint = new BlueprintWindow(mGame);
	setCentralWidget(mBlueprint);

	connect(mGame, SIGNAL(worldUpdated()), mBlueprint->blueprint(), SLOT(repaint()));
}
Пример #3
0
void TileView::setWorld(TileWorld& world)
{
    if ( mpWorld != &world )
    {
        mpWorld = &world;
        prepare();

        connect(mpWorld, SIGNAL(worldDirty()), SLOT(worldUpdated()));
    }
}
Пример #4
0
EditorUI::EditorUI()
	:	mFile(0)
{
	setupUi(this);
	actNew->setIcon(style()->standardIcon(QStyle::SP_FileIcon));
	actOpen->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon));
	actSave->setIcon(style()->standardIcon(QStyle::SP_DriveFDIcon));

	CommWindow *comm = new CommWindow(CommDock);
	CommDock->setWidget(comm);
	CommDock->setVisible(false);

	mGame = new EditorGame(comm);
	mBp = new EditorBlueprint(mGame, this);
	setCentralWidget(mBp);
	connect(mBp, SIGNAL(zoomChanged(float)), this, SLOT(zoomChanged(float)));
	connect(mBp, SIGNAL(dropEntity(Math::Point)), this, SLOT(dropEntity(Math::Point)));
	connect(mGame, SIGNAL(worldUpdated()), mBp, SLOT(repaint()));

	toolSelect = new QButtonGroup(this);
	toolSelect->addButton((QAbstractButton*)toolBar->widgetForAction(actPanTool), EditorBlueprint::pan);
	toolSelect->addButton((QAbstractButton*)toolBar->widgetForAction(actMoveTool), EditorBlueprint::move);
	toolSelect->addButton((QAbstractButton*)toolBar->widgetForAction(actBuildTool), EditorBlueprint::build);
	connect(actMoveTool, SIGNAL(triggered()), this, SLOT(updateTool()));
	connect(actPanTool, SIGNAL(triggered()), this, SLOT(updateTool()));
	connect(actBuildTool, SIGNAL(triggered()), this, SLOT(updateTool()));

	entityBox = new QComboBox(this);
	entityBox->addItem("");
	entityBox->addItems(FactoryManager::instance()->types());
	toolBar->addSeparator();
	toolBar->addWidget(entityBox);

	zoomLabel = new QLabel;
	statusbar->addPermanentWidget(zoomLabel);
	zoomChanged(mBp->zoom());


	connect(actNew, SIGNAL(triggered()), this, SLOT(New()));
	connect(actOpen, SIGNAL(triggered()), this, SLOT(open()));
	connect(actSave, SIGNAL(triggered()), this, SLOT(save()));
	connect(actSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
	connect(actShowNavmesh, SIGNAL(triggered(bool)), mBp, SLOT(setShowNavmesh(bool)));
	connect(actPopulate, SIGNAL(triggered()), this, SLOT(populate()));
	connect(actReset, SIGNAL(triggered()), this, SLOT(reset()));
	connect(actStartStop, SIGNAL(triggered()), this, SLOT(startStop()));
	connect(actGenNavmesh, SIGNAL(triggered()), this, SLOT(generateNavmesh()));

	New();
}