Exemplo n.º 1
0
void Weldingtool::AttackBy(id_ptr_on<Item> item)
{
    if (Working())
        TurnOff();
    else
        TurnOn();
}
Exemplo n.º 2
0
void aiEvents::generateEvent()
{
	if (personA->dailyEvents[eventTime] == NULL)
	{
		eventType = ai_schedule1[eventTime];

		if (eventType == EATING)
		{			
			Eating* eating = &Eating(personA,aiList, eventTime);
			eating->generateEating();
			for (std::vector<aiPerson*>::iterator it = eating->aiInvolved.begin(); it != eating->aiInvolved.end(); it++)
			{
				eating->personA = (*it);
				(*it)->dailyEvents[eventTime] = eating;
			}
		}
		else if (eventType == WORKING)
		{
			Working* working = &Working(personA,aiList, eventTime);
			working->generateWorking();
			for (std::vector<aiPerson*>::iterator it = working->aiInvolved.begin(); it != working->aiInvolved.end(); it++)
			{
				working->personA = (*it);
				(*it)->dailyEvents[eventTime] = working;
			}
		}
		else if (eventType == RESTING)
		{
			Resting* resting = &Resting(personA,aiList, eventTime);
			resting->generateResting();
			for (std::vector<aiPerson*>::iterator it = resting->aiInvolved.begin(); it != resting->aiInvolved.end(); it++)
			{
				resting->personA = (*it);
				(*it)->dailyEvents[eventTime] = resting;
			}
		}
		else if (eventType == FIGHTING)
		{	
			Fighting* fighting = &Fighting(personA,aiList, eventTime);
			fighting->generateFighting();
			for (std::vector<aiPerson*>::iterator it = fighting->aiInvolved.begin(); it != fighting->aiInvolved.end(); it++)
			{
				fighting->personA = (*it);
				(*it)->dailyEvents[eventTime] = fighting;
			}
		}
		else if (eventType == OTHER)
		{
			Other* other = &Other(personA,aiList, eventTime);
			other->generateOther();
			for (std::vector<aiPerson*>::iterator it = other->aiInvolved.begin(); it != other->aiInvolved.end(); it++)
			{
				other->personA = (*it);
				(*it)->dailyEvents[eventTime] = other;
			}
		}
	}
}
Exemplo n.º 3
0
void Weldingtool::TurnOff()
{
    if (!Working())
        return;
    
    on_ = false;
    SetState("welder");
    SetFreq(0);
}
Exemplo n.º 4
0
void Weldingtool::TurnOn()
{
    if (Working())
        return;
    if (fuel_ <= 0)
        return;

    on_ = true;
    SetState("welder1");
    SetFreq(10);
}
Exemplo n.º 5
0
uint8_t Gamefield::CheckGame()
{
	uint8_t gameover = 0;
	//If there is an obstacle on the road, then check if player hits offroad or block obstacle. Else only check offroad
	if (countobstacles > 0)
	{
		(offroad(game_car.GetPosX(), GetPos())||Working(0))?gameover=1:gameover=0;
	}else{
		(offroad(game_car.GetPosX(), GetPos()))?gameover=1:gameover=0;
	}
	return gameover;
}
Exemplo n.º 6
0
void aiEvents::updateEvent(int stages, aiPerson* person)
{
	ai_event eventType = person->dailyEvents[stages]->eventType;

	if (eventType != ai_schedule1[stages])   //reduece the aiInvolved by 1
	{
		for (std::vector<aiPerson*>::iterator it = person->dailyEvents[stages]->aiInvolved.begin(); it != person->dailyEvents[stages]->aiInvolved.end(); it++)
		{
			if ((*it) == person)
			{
				person->dailyEvents[stages]->aiInvolved.erase(it);
				person->dailyEvents[stages]->possibility *= 0.75;
				break;
			}
		}

		if (eventType ==  WORKING)   //generate new event for the ai
		{
			Working(person,aiList, (ai_time)stages).generateWorkingInterruptive();
		}
		else if (eventType == EATING)
		{
			 Eating(person,aiList, (ai_time)stages).generateEatingInterruptive();
		}
		else if (eventType == RESTING)
		{
			Resting(person,aiList, (ai_time)stages).generateRestingInterruptive();
		}
		else if (eventType == FIGHTING)
		{
			Fighting(person,aiList, (ai_time)stages).generateFightingInterruptive();
		}
		else if (eventType == OTHER)
		{
			 Other(person,aiList, (ai_time)stages).generateOtherInterruptive();
		}
	}
}