コード例 #1
0
void SolarSystem::update(float delta, PlaySpace *Space)
{
	if (Clock.elapsed() > Interval)
	{
		const int GROUP_SIZE = 4;
		Clock.start();
		
		float radius = gRNG.getNumber(100+TheGravitySource.CenterSize*800, TheGravitySource.CenterSize*1200.f);
		Angle angle = Angle::FromTurn(gRNG.getFloat());
		
		spawnGroup(Position + angle.toDirection().normalized() * radius, GROUP_SIZE, Space);
	}
}
コード例 #2
0
ファイル: GameController.cpp プロジェクト: bschalich/Taverna
void GameController::Update() {
   if (!isMonthBreak) {
		manageGroups();
		GameData::getInstance()->setDay(monthDay);

	   if (spawnGroupToggle == true) {
         spawnGroup(table);
	   }
   
   //FOR NOW if timer >10 seconds then spawnPatron();
   if (spawnTimer->getElapsedf() > spawnTime) {
      spawnTimer->Reset();
		  if (rand() % 20 == 0 && spawnGroupToggle == false) {
			 for (int i = 0; i < tableList.size(); i++) {
				if (TavernResources::getInstance()->tablesList[i]->openChairs.size() == 4 && TavernResources::getInstance()->getMaxCapacity() -TavernResources::getInstance()->getCapacity() >= 4) {
				   spawnGroupToggle = true;
				   table = tableList[i];
				   table->reserved = true;
				   break;
				}
			 }
		  }
		  else {
			 spawnPatron(20, 1, Person::WANDER);
		  }
	   }

	   //Month
	   if (monthTimer->getElapsedf() > MONTH_TIME_SECONDS) {
		   isMonthBreak = true;
		   menuMonth = new MenuMonth();
		   gameUI->menubar->visible = false;
		   gameUI->portrait->visible = false;
         
         if (spawnTime > 4) {
            spawnTime -= 0.5;
         }
         
		   //Remove all people
		   vector<Person*> patronList = TavernResources::getInstance()->getPatrons();

		   for (int i = 0; i < patronList.size(); i++)
		   {
			    Person *curPerson = patronList[i];
				//gameData->firePE->setPosition(curPerson->getPosition().x, 0, curPerson->getPosition().z);
				//gameData->firePE->setLoopParticles(true);
				//gameData->firePE->setLoopParticles(false);
				//patronList.erase(std::remove(patronList.begin(), patronList.end(), curPerson), patronList.end());
	    //patrons.erase(patrons.begin() + i);
	    gameData->getScene3D()->removeEntity(curPerson);
				gameData->getScene3D()->removeEntity(curPerson->shadow);
				gameData->getScene3D()->removeEntity(curPerson->box);
		   }

	 TavernResources::getInstance()->setCapacity(0);
	 TavernResources::getInstance()->openOrders.clear();
	 TavernResources::getInstance()->closedOrders.clear();
         
         //reset tables
         vector<Table*> tableList = TavernResources::getInstance()->tablesList;
      
         for (int i = 0; i < tableList.size(); i++) {
            tableList[i]->reset();
         }
         
		   vector<Staff*> staffList = TavernResources::getInstance()->getStaff();

		   for (int i = 0; i < staffList.size(); i++)
		   {
	    staffList[i]->reset();
			   staffList[i]->paused = true;
		   }
	   }
   }
   else if (menuMonth->getIsDone())
   {
		monthTimer->Reset();
		monthDay = 0;
		Tween *monthDays = new Tween(&monthDay, Tween::EASE_NONE, 1, 31, MONTH_TIME_SECONDS);
		GameData::getInstance()->incrementMonth();
		isMonthBreak = false;
		
		gameUI->menubar->visible = true;
		gameUI->portrait->visible = true;

		vector<Staff*> staffList = TavernResources::getInstance()->getStaff();

		for (int i = 0; i < staffList.size(); i++)
		{
			staffList[i]->paused = false;
		}

		//Pay staff
		//vector<Staff*> staffList = TavernResources::getInstance()->getStaff();

		for (int i = 0; i < staffList.size(); i++)
		{
			Staff *sPerson = staffList[i];
			char* pay = new char[5];
			sprintf(pay, "-$%d", sPerson->getPay());
			new TextBubble(Vector3(((Person*)sPerson)->getPosition().x, 0, ((Person*)sPerson)->getPosition().z), "", pay, 0, (Person*)sPerson);
			TavernResources::getInstance()->addGold(-sPerson->getPay());
		}
   }
   else
   {
	   menuMonth->Update();
   }
}