void LocationManager::goTo(QString destination) {

    if (destination.startsWith("@")) {
        // remove '@' and go to user
        goToUser(destination.remove(0, 1));
        return;
    }

    if (destination.startsWith("#")) {
        // remove '#' and go to named place
        goToPlace(destination.remove(0, 1));
        return;
    }

    // go to coordinate destination or to Username
    if (!goToDestination(destination)) {
        destination = QString(QUrl::toPercentEncoding(destination));

        JSONCallbackParameters callbackParams;
        callbackParams.jsonCallbackReceiver = this;
        callbackParams.jsonCallbackMethod = "goToAddressFromResponse";
        AccountManager::getInstance().authenticatedRequest(GET_ADDRESSES.arg(destination),
                                                           QNetworkAccessManager::GetOperation,
                                                           callbackParams);
    }
}
Beispiel #2
0
void LocationManager::goTo(QString destination) {
    const QString USER_DESTINATION_TYPE = "user";
    const QString PLACE_DESTINATION_TYPE = "place";
    const QString OTHER_DESTINATION_TYPE = "coordinate_or_username";
    
    if (destination.startsWith("@")) {
        // remove '@' and go to user
        QString destinationUser = destination.remove(0, 1);
        UserActivityLogger::getInstance().wentTo(USER_DESTINATION_TYPE, destinationUser);
        goToUser(destinationUser);
        return;
    }

    if (destination.startsWith("#")) {
        // remove '#' and go to named place
        QString destinationPlace = destination.remove(0, 1);
        UserActivityLogger::getInstance().wentTo(PLACE_DESTINATION_TYPE, destinationPlace);
        goToPlace(destinationPlace);
        return;
    }

    // go to coordinate destination or to Username
    if (!goToDestination(destination)) {
        destination = QString(QUrl::toPercentEncoding(destination));
        UserActivityLogger::getInstance().wentTo(OTHER_DESTINATION_TYPE, destination);
        
        JSONCallbackParameters callbackParams;
        callbackParams.jsonCallbackReceiver = this;
        callbackParams.jsonCallbackMethod = "goToAddressFromResponse";
        callbackParams.errorCallbackReceiver = this;
        callbackParams.errorCallbackMethod = "handleAddressLookupError";
        
        AccountManager::getInstance().authenticatedRequest(GET_ADDRESSES.arg(destination),
                                                           QNetworkAccessManager::GetOperation,
                                                           callbackParams);
    }
}
void Robot::draw() {
	if(robotLife > 0){
		//draw bounding box
		glPushMatrix();
			box->draw();
		glPopMatrix();

		//draw robot
		glPushMatrix();
			if (!isRobotBeingControlled){
				if(computerControlled){
					aiSetDestination();
				}
				goToDestination();
			}
		
			//Translate()
			glTranslatef(xPos,0.0f,zPos);
			
			//Spin()
			glTranslatef(0.5f, 0.0f, 0.5f);
			glRotatef(spinDegrees,0.0f,1.0f,0.0f);
			glTranslatef(-0.5f,0.0f,-0.5f);

			//Draw Headlight
			glPushMatrix();
				glTranslatef(0.0f,height-0.25f,0.0f);
				if(isMyLightOn){
					((HeadlightModel*)headlight)->whiteLight = true;
				}
				else{
					((HeadlightModel*)headlight)->whiteLight = false;
				}
				headlight->draw();
			glPopMatrix();

			//Draw Model
			model->draw();
		glPopMatrix();
	}
	else{
		GLUquadricObj *quadric = gluNewQuadric();
		gluQuadricTexture(quadric, true);

		if ((currentTime - lastExplosion) >= 200.0 && explosionSize <= 2.0f)
		{
			explosionSize+=.5f;
			lastExplosion = clock();
			if (explosionSize == 2.5f)
				stop = true;
		}

		if (!stop)
		{
			glPushMatrix();
				glColor3f(1.0f, 0.4f, 0.0f);
				glTranslatef(xPos, 0.0f, zPos);
				gluSphere(quadric, explosionSize+=.5f, 5, 5);
			glPopMatrix();
		}

		box->resize(box->size.x,0.1f,box->size.z);
		glPushMatrix();
			box->draw();
		glPopMatrix();
		glPushMatrix();
			//Translate()
			glTranslatef(xPos,0.0f,zPos);
			glColor3f(0.5f,0.5f,0.5f);
			rubble->draw();
		glPopMatrix();
		gluDeleteQuadric(quadric);
	}
}