Ejemplo n.º 1
0
task main(){
	calibrateLight();
	calibrateCompass();
	ExploreStack stack;
	Graph graph;

	initStack(stack);
	initGraph(graph);
	Stub stub;
	Edge lastEdge;

	int currentNode = -1;
	int canNode = -1;
	//go to node
	currentNode = exploreNewNode(graph, stack, currentNode, lastEdge);
	if(detectCan()) {
		canNode = currentNode;
		announceCan(currentNode);
	}
	//while not empty
	while(!empty(stack)){
		pop(stack, stub);
		motor[left] = 0;
		motor[right] = 0;
		goToNode(graph, currentNode, stub.node);
		currentNode = stub.node;
		turnToAngle(stub.angle, 15);
		turnToLine();
		nxtDisplayCenteredTextLine(4, "Exploring...");
		int stackSize = stack.top;
		FollowSegmentTilEnd(lastEdge);
		currentNode = exploreNewNode(graph, stack, currentNode, lastEdge);
		if(stackSize == stack.top && detectCan()) {
			canNode = currentNode;
			announceCan(currentNode);
		}
	}
	motor[left] = 0;
	motor[right] = 0;
	eraseDisplay();
	nxtDisplayCenteredTextLine(3, "%i nodes found", graph.nNodes);
	wait10Msec(500);


	if(canNode >= 0) {
		goToNode(graph, currentNode, canNode);
		motor[left] = 0;
		motor[right] = 0;
		eraseDisplay();
		nxtDisplayCenteredTextLine(3, "Can was here");
		wait10Msec(500);
	} else {
		motor[left] = 0;
		motor[right] = 0;
		eraseDisplay();
		PlaySound(soundLowBuzz);
		nxtDisplayCenteredTextLine(3, "There was no can");
		wait10Msec(500);
	}
}
Ejemplo n.º 2
0
void LinkedList::removeAt(int index)
{
	if (index == 0)
	{
		tempPtr = head->nextLink;
		delete head;
		if (tempPtr != NULL)
		{
			tempPtr->previousLink = NULL;
			head = tempPtr;
		}
	} else
	{
		goToNode(index);
		tempPtr = visitPtr->previousLink;
		tempPtr->nextLink = visitPtr->nextLink;
		tempPtr = visitPtr->nextLink;
		if (tempPtr != NULL)
		{
			tempPtr->previousLink = visitPtr->previousLink;
		}
		delete visitPtr;
	}
	_count--;
}
Ejemplo n.º 3
0
void Doctor::attendPatient()
{
	//
	if (travellingToResident)
	{
		//This is here so that it will compile. Get rid of when uncommenting goToNode()
 
		if (goToNode("Resident0"))

		{
			travellingToResident = false;
			treating = true;
			first = true;
		}
		return;
	}

	else if (treating)
	{
		//Send message to patient to rise health stats
		if (first)
		{
			requestLock("Doctor");
			first = false;
		}

		if (haveLock)
		{
			//Treat resident
			if (!(healthLevel >= 99))
			{

				doResponse("health");

				counterHealthTimes++;
				if (counterHealthTimes > 35){
					goHome = true;
					treating = false;
					homeVisit = false;
				}
			} else 

			{
				goHome = true;
				treating = false;
				homeVisit = false;
			}
		} else if (deniedLock)
		{
			if (otherUnlocked)
			{
				requestLock("Doctor");
				deniedLock = false;
				otherUnlocked = false;
			}
		}
	}

}
Ejemplo n.º 4
0
void Doctor::doExecuteLoop()
{
	if (RCmode == "doctor")
	{
		controlRobot();
		return;
	}

	if (homeVisit)
	{

		attendPatient();
	}

	if (goHome)
	{
		goToNode("nodeHouseDoor");
	}

}
Ejemplo n.º 5
0
void Menu::updateMainMenu(uint16 action) {
	switch (action) {
	case 1: {
			// New game
			int16 choice = 1;

			// If a game is playing, ask if wants to save
			if (_vm->_state->getMenuSavedAge() != 0) {
				choice = _vm->openDialog(1080);
			}

			if (choice == 0) {
				// Go to save screen
				_vm->_state->setMenuSaveBack(1);
				_vm->_state->setMenuSaveAction(6);
				goToNode(300);
			} else if (choice == 1) {
				// New game
				goToNode(98);
			}
		}
		break;
	case 2: {
			// Load game
			int16 choice = 1;

			// If a game is playing, ask if wants to save
			if (_vm->_state->getMenuSavedAge() != 0) {
				choice = _vm->openDialog(1060);
			}

			if (choice == 0) {
				// Go to save screen
				_vm->_state->setMenuSaveBack(1);
				_vm->_state->setMenuSaveAction(3);
				goToNode(300);
			} else if (choice == 1) {
				// Load game screen
				_vm->_state->setMenuLoadBack(1);
				goToNode(200);
			}
		}
		break;
	case 3:
		// Go to save screen
		_vm->_state->setMenuSaveBack(1);
		_vm->_state->setMenuSaveAction(1);
		goToNode(300);
		break;
	case 4:
		// Settings
		_vm->_state->setMenuOptionsBack(1);
		_vm->runScriptsFromNode(599, 0, 0);
		break;
	case 5: {
			// Asked to quit
			int16 choice = 1;

			// If a game is playing, ask if wants to save
			if (_vm->_state->getMenuSavedAge() != 0) {
				choice = _vm->openDialog(1070);
			}

			if (choice == 0) {
				// Go to save screen
				_vm->_state->setMenuSaveBack(1);
				_vm->_state->setMenuSaveAction(5);
				goToNode(300);
			} else if (choice == 1) {
				// Quit
				_vm->quitGame();
			}
		}
		break;
	default:
		warning("Menu action %d is not implemented", action);
		break;
	}
}
Ejemplo n.º 6
0
Client LinkedList::getAt(int index)
{
	goToNode(index);
	return visitPtr->data; // std::bad_alloc at memory location   ??? WT?
}