예제 #1
0
void ClusterBomb::explode()
{
#ifdef DEBUG
//  printf("ClusterBomb just exploded!\n");
#endif
  WorldObject * wo;
  float angle = 6.28318 / BOMB_PIECES;
  Vector a = Vector(1, 0, 0);
  Vector b = Vector(0, 0, 1);
  Vector c = Vector(0, .1, 0);
  float mag = global::factory->getBlueprint(type).getSize().mag() / 4;
  Vector off;
  for (int i = 0; i < BOMB_PIECES; i++)
  {
    wo = new WorldObject(0, 0, DUMMY_SPHERE);
    off = a * mag * sin(i * angle) + b * mag * cos(i * angle) + c;
    wo->setPosition(position + off);
    wo->setVelocity(velocity + off);
    networkManager->network->getPhysicsPtr()->insertWorldObject(wo);
    wo = new WorldObject(0, 0, DUMMY_SPHERE);
    off = a * mag * cos(i * angle) + b * mag * sin(i * angle) - c;
    wo->setPosition(position + off);
    wo->setVelocity(velocity + off);
    networkManager->network->getPhysicsPtr()->insertWorldObject(wo);
  }
}
예제 #2
0
void CarnageState::updateInput(long milli_time) {
#ifdef CLIENT
   // TODO REMOVE DEMO CODE
   if(io::keys['8']) {
	  io::keys['8'] = false;
      networkManager->network->loadLevel("resources/2base.lvl");
   }
   if(io::keys['9']) {
	  io::keys['9'] = false;
      networkManager->network->loadLevel("resources/test2.lvl");
   }
   if(io::keys['0']) {
	  io::keys['0'] = false;
      networkManager->network->loadLevel("resources/bigplus.lvl");
   }
   if(io::keys['-']) {
	  io::keys['-'] = false;
      networkManager->network->loadLevel("resources/ibigplus.lvl");
   }
   if(io::keys['c']) {
	  io::keys['c'] = false;
	  networkManager->network->serverConnect("127.0.0.1", 5060);
   }

	//stop music
	if(io::keys['['])
	{
		global::soundManager->stopPlayingMusic();
	}

	//play music for carnage state
	if(io::keys[']'] && music_delay <= 0)
	{
		if(stateType() == RESULTS_STATE)
		{
			global::soundManager->playResultWinSong();
		}
		else
		{
			global::soundManager->playCarnageSong();
		}
		music_delay = MUSIC_DELAY;
	}

	if(io::keys['n'] && music_delay <= 0)
	{
		if(stateType() == RESULTS_STATE)
		{
			global::soundManager->playNextResultSong();
		}
		else
		{
			global::soundManager->playNextCarnageSong();
		}
		music_delay = MUSIC_DELAY;
	}

   // TODO END DEMO CODE

   // General Keyboard Layout
   if(io::keys[27]) {
	  networkManager->network->serverDisconnect();
      exit(0);
   }

   // FIRE CONTROLS
   if (stateType() == CARNAGE_STATE) // only fire in the real carnage state
   {
	   if((io::keys[' '] || io::mouse_buttons[MOUSE_LEFT] == GLUT_DOWN) &&
			   ammoTimers[ammoIndex] <= 0 &&
			   (ammoCounts[ammoIndex] > 0 || ammoCounts[ammoIndex] == -1))
	   {
			switch(ammoIndex)
			{
				case 0:
					global::soundManager->playCarnageSfx(0);
					break;
					
				case 1:
					global::soundManager->playCarnageSfx(4);
					break;
				
				case 2:
					global::soundManager->playCarnageSfx(3);
					break;
					
				case 3:
					global::soundManager->playCarnageSfx(1);
					break;
					
				case 4:
					global::soundManager->playCarnageSfx(2);
					break;
					
				case 5:
					global::soundManager->playCarnageSfx(4);
					break;
					
				default:
					break;
			}
		  WorldObject *newObjPtr = global::factory->makeObject(ammoTypes[ammoIndex]);
		  newObjPtr->setPosition(camera->position() - Vector( 0.0f, 1.0f, 0.0f));
		  newObjPtr->setVelocity((camera->viewVec() + Vector(0.0f, 0.15f, 0.0f)) * 50); // offset the view vector a bit to more closely match the targeting reticle
		  networkManager->network->addObject(newObjPtr);
		  ammoTimers[ammoIndex] = ammoDelayTimers[ammoIndex];
		  if(ammoCounts[ammoIndex] != -1)
			  --ammoCounts[ammoIndex];
	   }
	}
#endif
}