Пример #1
0
void Raven_WeaponSystem::RenderDesirabilities()const
{
	Vector2D p = m_pOwner->Pos();

	int num = 0;

	WeaponMap::const_iterator curWeap;
	for (curWeap = m_WeaponMap.begin(); curWeap != m_WeaponMap.end(); ++curWeap)
	{
		if (curWeap->second) num++;
	}

	int offset = 15 * num;

	for (curWeap = m_WeaponMap.begin(); curWeap != m_WeaponMap.end(); ++curWeap)
	{
		if (curWeap->second)
		{
			double score = curWeap->second->GetLastDesirabilityScore();
			std::string type = GetNameOfType(curWeap->second->GetType());

			gdi->TextAtPos(p.x + 10.0, p.y - offset, ttos(score) + " " + type);

			offset += 15;
		}
	}
}
Пример #2
0
//---------------------------- Clear ------------------------------------------
//
//  deletes all the current objects ready for a map load
//-----------------------------------------------------------------------------
void Raven_Game::Clear()
{
#ifdef LOG_CREATIONAL_STUFF
    debug_con << "\n------------------------------ Clearup -------------------------------" <<"";
#endif

  //delete the bots
  std::list<Raven_Bot*>::iterator it = m_Bots.begin();
  for (it; it != m_Bots.end(); ++it)
  {
#ifdef LOG_CREATIONAL_STUFF
    debug_con << "deleting entity id: " << (*it)->ID() << " of type "
              << GetNameOfType((*it)->EntityType()) << "(" << (*it)->EntityType() << ")" <<"";
#endif

    delete *it;
  }

  //delete any active projectiles
  std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin();
  for (curW; curW != m_Projectiles.end(); ++curW)
  {
#ifdef LOG_CREATIONAL_STUFF
    debug_con << "deleting projectile id: " << (*curW)->ID() << "";
#endif

    delete *curW;
  }

  //clear the containers
  m_Projectiles.clear();
  m_Bots.clear();

  m_pSelectedBot = NULL;


}
//------------------------- LoadMap ------------------------------------
//
//  sets up the game environment from map file
//-----------------------------------------------------------------------------
bool Raven_Map::LoadMap(const std::string& filename)
{  
  std::ifstream in(filename.c_str());
  if (!in)
  {
    ErrorBox("Bad Map Filename");
    return false;
  }

  Clear();

  BaseGameEntity::ResetNextValidID();

  //first of all read and create the navgraph. This must be done before
  //the entities are read from the map file because many of the entities
  //will be linked to a graph node (the graph node will own a pointer
  //to an instance of the entity)
  m_pNavGraph = new NavGraph(false);
  
  m_pNavGraph->Load(in);

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "NavGraph for " << filename << " loaded okay" << "";
#endif

  //determine the average distance between graph nodes so that we can
  //partition them efficiently
  m_dCellSpaceNeighborhoodRange = CalculateAverageGraphEdgeLength(*m_pNavGraph) + 1;

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "Average edge length is " << CalculateAverageGraphEdgeLength(*m_pNavGraph) << "";
#endif

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "Neighborhood range set to " << m_dCellSpaceNeighborhoodRange << "";
#endif


  //load in the map size and adjust the client window accordingly
  in >> m_iSizeX >> m_iSizeY;

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "Partitioning navgraph nodes..." << "";
#endif

  //partition the graph nodes
  PartitionNavGraph();


  //get the handle to the game window and resize the client area to accommodate
  //the map
  extern char* g_szApplicationName;
  extern char* g_szWindowClassName;
  HWND hwnd = FindWindow(g_szWindowClassName, g_szApplicationName);
  const int ExtraHeightRqdToDisplayInfo = 50;
  ResizeWindow(hwnd, m_iSizeX, m_iSizeY+ExtraHeightRqdToDisplayInfo);

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "Loading map..." << "";
#endif

 
  //now create the environment entities
  while (!in.eof())
  {   
    //get type of next map object
    int EntityType;
    
    in >> EntityType;

#ifdef LOG_CREATIONAL_STUFF
    debug_con << "Creating a " << GetNameOfType(EntityType) << "";
#endif

    //create the object
    switch(EntityType)
    {
    case type_wall:
 
        AddWall(in); break;

    case type_sliding_door:
 
        AddDoor(in); break;

    case type_door_trigger:
 
        AddDoorTrigger(in); break;

   case type_spawn_point:
     
       AddSpawnPoint(in); break;

   case type_health:
     
       AddHealth_Giver(in); break;

   case type_shotgun:
     
       AddWeapon_Giver(type_shotgun, in); break;

   case type_rail_gun:
     
       AddWeapon_Giver(type_rail_gun, in); break;

   case type_rocket_launcher:
     
       AddWeapon_Giver(type_rocket_launcher, in); break;

    default:
      
      throw std::runtime_error("<Map::Load>: Attempting to load undefined object");

      return false;
      
    }//end switch
  }

#ifdef LOG_CREATIONAL_STUFF
    debug_con << filename << " loaded okay" << "";
#endif

   //calculate the cost lookup table
  m_PathCosts = CreateAllPairsCostsTable(*m_pNavGraph);

  return true;
}