Esempio n. 1
0
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
  // Don't kill badguys that have already been killed
  if (!is_active()) return;

  if (tile_attributes & Tile::WATER && !is_in_water())
  {
    m_in_water = true;
    SoundManager::current()->play("sounds/splash.ogg", get_pos());
  }
  if (!(tile_attributes & Tile::WATER) && is_in_water())
  {
    m_in_water = false;
  }

  if (tile_attributes & Tile::HURTS && is_hurtable()) {
    if (tile_attributes & Tile::FIRE) {
      if (is_flammable()) ignite();
    }
    else if (tile_attributes & Tile::ICE) {
      if (is_freezable()) freeze();
    }
    else {
      kill_fall();
    }
  }
}
Esempio n. 2
0
void GameObjectManager::run()
{
    switch (Game::cLevel)
    {

    case Game::MENU_0:
        break;

    case Game::LEV_1:
        ignite( mBox_1 );
        ignite( mNPC_1 );
        ignite( mPlayer_1 );
        break;

    case Game::LEV_2:
        ignite( mBox_2 );
        ignite( mEnemy_1 );
        ignite( mEnemy_2 );
        ignite( mPlayer_2 );
        break;

    default:
        break;
    }
}
Esempio n. 3
0
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
  if(tile_attributes & Tile::HURTS) {
    if (tile_attributes & Tile::FIRE) {
      if (is_flammable()) ignite();
    }
    else if (tile_attributes & Tile::ICE) {
      if (is_freezable()) freeze();
    }
    else {
      kill_fall();
    }
  }
}
Esempio n. 4
0
HitResponse
BadGuy::collision_bullet(Bullet& bullet, const CollisionHit& hit)
{
  if (is_frozen()) {
    if (bullet.get_type() == FIRE_BONUS) {
      // fire bullet thaws frozen badguys
      unfreeze();
      bullet.remove_me();
      return ABORT_MOVE;
    } else {
      // other bullets ricochet
      bullet.ricochet(*this, hit);
      return FORCE_MOVE;
    }
  }
  else if (is_ignited()) {
    if (bullet.get_type() == ICE_BONUS) {
      // ice bullets extinguish ignited badguys
      extinguish();
      bullet.remove_me();
      return ABORT_MOVE;
    } else {
      // other bullets are absorbed by ignited badguys
      bullet.remove_me();
      return FORCE_MOVE;
    }
  }
  else if (bullet.get_type() == FIRE_BONUS && is_flammable()) {
    // fire bullets ignite flammable badguys
    ignite();
    bullet.remove_me();
    return ABORT_MOVE;
  }
  else if (bullet.get_type() == ICE_BONUS && is_freezable()) {
    // ice bullets freeze freezable badguys
    freeze();
    bullet.remove_me();
    return ABORT_MOVE;
  }
  else {
    // in all other cases, bullets ricochet
    bullet.ricochet(*this, hit);
    return FORCE_MOVE;
  }
}
Esempio n. 5
0
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
  // Don't kill badguys that have already been killed
  if (!is_active()) return;

  if(tile_attributes & Tile::HURTS) {
    if (tile_attributes & Tile::FIRE) {
      if (is_flammable()) ignite();
    }
    else if (tile_attributes & Tile::ICE) {
      if (is_freezable()) freeze();
    }
    else {
      kill_fall();
    }
  }
}
Esempio n. 6
0
bool Foam::ignition::ignited() const
{
    if (!ignite())
    {
        return false;
    }

    bool igned = false;

    forAll(ignSites_, i)
    {
        if (ignSites_[i].ignited())
        {
            igned = true;
        }
    }

    return igned;
}
Esempio n. 7
0
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  std::tr1::shared_ptr<BunsenBCFactory> bc_factory( new BunsenBCFactory );
  sim_builder.attach_bc_factory( bc_factory );

  std::tr1::shared_ptr<GRINS::PhysicsFactory> physics_factory( new BunsenPhysicsFactory );
  sim_builder.attach_physics_factory( physics_factory );

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder );

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = libMesh_inputfile( "restart-options/restart_file", "none" );

  // If we are "cold starting", setup the flow field.
  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);
      
      Parameters &params = es->parameters;

      libMesh::Real& T_init = params.set<libMesh::Real>("T_init");
      T_init = libMesh_inputfile("InitialConditions/T0", 0.0);

      libMesh::Real& p0 = params.set<libMesh::Real>("p0");
      p0 = libMesh_inputfile("Physics/ReactingLowMachNavierStokes/p0", 1.0e5);

#ifdef GRINS_HAVE_CANTERA
      //Cantera::IdealGasMix& cantera = GRINS::CanteraSingleton::cantera_instance(libMesh_inputfile);
#endif

      libMesh::Real& w_H2 = params.set<libMesh::Real>( "w_H2" );
      w_H2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 0 );

      libMesh::Real& w_O2 = params.set<libMesh::Real>( "w_O2" );
      w_O2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 1 );

      libMesh::Real& w_H2O = params.set<libMesh::Real>( "w_H2O" );
      w_H2O = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 2 );

      libMesh::Real& w_H = params.set<libMesh::Real>( "w_H" );
      w_H = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 3 );

      libMesh::Real& w_O = params.set<libMesh::Real>( "w_O" );
      w_O = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 4 );

      libMesh::Real& w_OH = params.set<libMesh::Real>( "w_OH" );
      w_OH = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 5 );

      libMesh::Real& w_HO2 = params.set<libMesh::Real>( "w_HO2" );
      w_HO2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 6 );

      libMesh::Real& w_H2O2 = params.set<libMesh::Real>( "w_H2O2" );
      w_H2O2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 7 );

      libMesh::Real& w_N2 = params.set<libMesh::Real>( "w_N2" );
      w_N2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 8 );

      std::cout << "==============================================" << std::endl;
      std::cout << "Projecting Solution." << std::endl;
      std::cout << "==============================================" << std::endl;
      system.project_solution( initial_values, NULL, params );
      std::cout << "==============================================" << std::endl;
      std::cout << "Done Projecting Solution!" << std::endl;
      std::cout << "==============================================" << std::endl;
    }

  /* If we're restarting to try and get ignition, then we need to setup a
     "restart" system and using the IgniteInitalGuess functor to do the projection
     on the "real" system. */
  if( libMesh_inputfile( "restart-options/ignition", false ) && 
      restart_file != std::string("none") )
    {
      std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );

      /*
      GetPot restart_input( "bunsen_restart.in" );
      
      GRINS::Simulation restart_sim( restart_input,
				     sim_builder );
      std::tr1::shared_ptr<libMesh::EquationSystems> restart_es = restart_sim.get_equation_system();
      libMesh::System& restart_system = restart_es->get_system(system_name);
      GRINS::MultiphysicsSystem& restart_ms_system = libmesh_cast_ref<GRINS::MultiphysicsSystem&>( restart_system );
      */

      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      libMesh::System& system = es->get_system(system_name);
      GRINS::MultiphysicsSystem& ms_system = libmesh_cast_ref<GRINS::MultiphysicsSystem&>( system );

      Bunsen::IgniteInitialGuess<libMesh::Real> ignite( libMesh_inputfile, ms_system, 
					       ms_system );

      es->reinit();
      
      std::cout << "==============================================" << std::endl;
      std::cout << "Projecting Solution." << std::endl;
      std::cout << "==============================================" << std::endl;
      ms_system.project_solution( &ignite );
      std::cout << "==============================================" << std::endl;
      std::cout << "Done Projecting Solution!" << std::endl;
      std::cout << "==============================================" << std::endl;
    }

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

  grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}