예제 #1
0
void Logger::l7dlog(const LevelPtr& level1, const LogString& key,
                    const LocationInfo& location, const std::vector<LogString>& params) const
{
        if (repository == 0 || repository->isDisabled(level1->toInt()))
        {
                return;
        }

        if (level1->isGreaterOrEqual(getEffectiveLevel()))
        {
                LogString pattern = getResourceBundleString(key);
                LogString msg;

                if (pattern.empty())
                {
                        msg = key;
                }
                else
                {
                        msg = StringHelper::format(pattern, params);
                }

                forcedLogLS(level1, msg, location);
        }
}
예제 #2
0
파일: Entity.cpp 프로젝트: mmilewski/magame
bool Entity::DoFieldsEndOnRight(double dt, LevelPtr level) const {
    size_t curr_x_tile, curr_y_tile;
    GetCurrentTile(&curr_x_tile, &curr_y_tile);
    if (level->IsFieldNotCollidable(curr_x_tile + 1, curr_y_tile + 1)
        && level->GetFieldAabb(curr_x_tile + 1, curr_y_tile).IsOnRightOf(GetNextHorizontalAabb(dt))) {
        return true;
    }
    return false;
}
예제 #3
0
bool Logger::isEnabledFor(const LevelPtr& level1) const
{
        if(repository == 0 || repository->isDisabled(level1->toInt()))
        {
                return false;
        }

        return level1->isGreaterOrEqual(getEffectiveLevel());
}
예제 #4
0
파일: Entity.cpp 프로젝트: mmilewski/magame
bool Entity::DoFieldsEndOnLeft(double dt, LevelPtr level) const {
    size_t curr_x_tile, curr_y_tile;
    GetCurrentTile(&curr_x_tile, &curr_y_tile);
    // czy pole o jeden w lewo i w doł jest puste (None)
    // oraz czy jednostka jest przy krawędzi (IsOnLeftOf)...
    if (level->IsFieldNotCollidable(curr_x_tile - 1, curr_y_tile + 1)
        && level->GetFieldAabb(curr_x_tile - 1, curr_y_tile).IsOnLeftOf(GetNextHorizontalAabb(dt))) {
        return true;
    }
    return false;
}
예제 #5
0
파일: Entity.cpp 프로젝트: mmilewski/magame
bool Entity::IsAnyFieldOnRight(double dt, LevelPtr level) const {
    size_t curr_x_tile, curr_y_tile;
    GetCurrentTile(&curr_x_tile, &curr_y_tile);
    for (int y = -1; y < 2; ++y) {
        if (level->IsFieldNotCollidable(curr_x_tile + 1, curr_y_tile + y)) {
            continue;
        }
        const Aabb field_aabb = level->GetFieldAabb(curr_x_tile + 1, curr_y_tile + y);
        if (GetNextHorizontalAabb(dt).IsOnLeftOf(field_aabb)) {
            return true;
        }
    }
    return false;
}
예제 #6
0
파일: Entity.cpp 프로젝트: mmilewski/magame
bool Entity::IsAnyFieldAboveMe(double dt, LevelPtr level) const {
    size_t curr_x_tile, curr_y_tile;
    GetCurrentTile(&curr_x_tile, &curr_y_tile);
    for (int x = -1; x < 2; ++x) {
        if (level->IsFieldNotCollidable(curr_x_tile + x, curr_y_tile - 1)) {
            continue;
        }
        const Aabb field_aabb = level->GetFieldAabb(curr_x_tile + x, curr_y_tile - 1);
        if (GetNextVerticalAabb(dt).IsUnder(field_aabb)) {
            return true;
        }
    }
    return false;
}
예제 #7
0
파일: Level.cpp 프로젝트: mmilewski/magame
Level::Level(LevelPtr level, const std::list<LevelEntityData>& entities_data, const LevelEntityData& player_data)
    : m_name(level->GetName()),
      m_width(level->GetWidth()),
      m_height(level->GetHeight()),
      m_data(level->m_data),
      m_entities_to_create(entities_data),
      m_player_data(player_data),
      m_loaded(true) {
    if (!(m_player_data.name == "player" && m_player_data.x > 0 && m_player_data.y > 0)) {
        m_player_data.name = "player";
        m_player_data.x = 1;
        m_player_data.y = 19;
    }
}
예제 #8
0
 /*--------------------------------------------------------------------------------
     Function    : Display::inspectTile
     Description : Queries a level to see if there is anything interesting at the
                   given coordinate.  If so, it prints a message to the console.
     Inputs      : Level object, coordinate to inspect
     Outputs     : Notable contents of the tile.
     Return      : void
 --------------------------------------------------------------------------------*/
 void Display::inspectTile(const LevelPtr level, const Point& pt)
 {
     string message;
     level->inspectTileContents(message, pt);
     if(message.empty()) return;
     messageTracker->addStdMessage(message);
 }
예제 #9
0
    /*--------------------------------------------------------------------------------
        Function    : Display::drawLevelItems
        Description : Draws the Items found in the given level.  This function is
                      called after the Level's map has been drawn in the 
                      drawPlayfield() function.
        Inputs      : Level object
        Outputs     : None
        Return      : void
    --------------------------------------------------------------------------------*/
    void Display::drawLevelItems(const LevelPtr level)
    {
        vector<ItemPtr> items = level->getItems();
        vector<ItemPtr>::const_iterator it, end;
        it = items.begin(); end = items.end();

        for(; it!=end; ++it)
        {
            drawObject(*it);
        }
    }
예제 #10
0
void Hierarchy::setThreshold(const LevelPtr& l)
{
        if (l != 0)
        {
            synchronized sync(mutex);
            thresholdInt = l->toInt();
            threshold = l;
            if (thresholdInt != Level::ALL_INT) {
               setConfigured(true);
            }
        }
}
예제 #11
0
void SpriteGrid::SetLevel( LevelPtr Level){

    m_level = Level;
    m_level_height= Level -> GetHeight();
    m_level_width= Level -> GetWidth();
    
    
    m_grid.resize(Level->GetHeight());
    for (size_t i = 0; i < m_level_height; ++i) {
        m_grid.at(i).resize( m_level_width ); 
    }

     for ( ushort y = 0; y < m_grid.size(); ++y){
	vector <SpritePtr> & row = m_grid.at(y);
	  for( ushort x = 0; x < row.size(); ++x){
	    const FT::FieldType& ft = m_level ->GetField(x,y);
	    if( ft>0 ){
	      SetSprite( x, y, m_sprites.at(ft),ft); 		
	      }	if ( ft>=7 ){
		SDL_Rect tmp={Engine::GetLua()->CORNER_X + Engine::GetLua()->TILE_SIZE * x,
			      Engine::GetLua()->CORNER_X + Engine::GetLua()->TILE_SIZE * y,
			      Engine::GetLua()->TILE_SIZE*2,Engine::GetLua()->TILE_SIZE*2};
			      
			      Engine::Get().GetTreasure()->AddTreasure(tmp);
	      }
		
		
	      
	  }
     }
   
     for (size_t y = 0; y < m_grid.size(); ++y) {
            const std::vector<SpritePtr>& row = m_grid.at(y);
		for (size_t x = 0; x < row.size(); ++x) {
		  const SpritePtr& sprite = row.at(x);
		  if(sprite){		
			  sprite->SetX(Engine::GetLua()->CORNER_X + Engine::GetLua()->TILE_SIZE * x);
			  sprite->SetY(Engine::GetLua()->CORNER_X + Engine::GetLua()->TILE_SIZE * y);
			  SDL_Rect tmp;
			  tmp.x = sprite->GetX();
			  tmp.y = sprite->GetY();
			  tmp.h = Engine::GetLua()->TILE_SIZE;
			  tmp.w = Engine::GetLua()->TILE_SIZE;
			  
			  if( sprite->GetType() < 7 ) //![ilosc elementow mapy]
			  Engine::Get().GetAabb()->AddBox(tmp);
		  }
		}
     } 
     
}
예제 #12
0
파일: Player.cpp 프로젝트: mmilewski/magame
void Player::CheckCollisionsWithLevel(double dt, LevelPtr level) {
    size_t x_tile, y_tile;
    GetCurrentTile(&x_tile, &y_tile);

    // czy gracz wszedł w portal i należy mu się wygrana :)
    for (int i=-1; i<2; i++) {
        for (int j=-1; j<2; j++) {
            if (static_cast<int>(x_tile) + i < 0 || static_cast<int>(y_tile) + j < 0)
                continue;
            if (level->GetFieldAabb(x_tile + i, y_tile + j).Collides(GetNextAabb(dt))
                    && level->Field(x_tile + i, y_tile + j) == FT::EndOfLevel) {
                LevelCompleted();
            }
        }
    }

    // czy postać koliduje z czymś od góry
    if (IsAnyFieldAboveMe(dt, level)) {
        Fall();
    }

    // czy postać koliduje z czymś od dołu
    if (IsAnyFieldBelowMe(dt, level)) {
        PlayerOnGround();
    }

    // czy postać koliduje z czymś po lewej stronie
    if (IsAnyFieldOnLeft(dt, level)) {
        ForbidGoingLeft();
    }

    // czy postać koliduje z czymś po prawej stronie
    if (IsAnyFieldOnRight(dt, level)) {
        ForbidGoingRight();
    }
}
예제 #13
0
    /*--------------------------------------------------------------------------------
        Function    : Display::drawLevelOccupants
        Description : Draws all of the characters and monsters in the level, including
                      the player's party.  This function is called after the Level's
                      map and the Level's items have been drawn in the drawPlayfield()
                      function.
        Inputs      : Level Object
        Outputs     : None
        Return      : void
    --------------------------------------------------------------------------------*/
    void Display::drawLevelOccupants(const LevelPtr level)
    {
        vector<PartyPtr> parties = level->getParties();
        vector<PartyPtr>::const_iterator it, end;
        it = parties.begin(); end = parties.end();

        for(; it!=end; ++it)
        {
            vector<ActorPtr> members = (*it)->getMembers();
            vector<ActorPtr>::const_iterator current, finish;
            current = members.begin(); finish = members.end();

            for(; current!=finish; ++current)
            {
                drawObject(*current);
            }
        }
    }
예제 #14
0
    /*--------------------------------------------------------------------------------
        Function    : Display::drawPlayfield
        Description : Draws the level Map.  Before drawing anything, this function
                      firsts calculates how much of the map is actually displayed on
                      the screen and does not attempt to draw outside the map bounds.
                      (Sounds obvious, but the first implementation simply caught
                      std::out_of_range exceptions and ignored them.  Turned out to be
                      inefficient to catch a few thousand exceptions every refresh.  
                      Who knew.)
        Inputs      : None
        Outputs     : None
        Return      : void
    --------------------------------------------------------------------------------*/
    void Display::drawPlayfield() 
    {
        // erase the old contents of the playfield
        _playfield->clear();

        LevelPtr level = Level::getCurrentLevel();

        // determine if part of the camera view is off the map
        bool camTLX_gt_0 = camTL.X() >= 0;
        bool camTLY_gt_0 = camTL.Y() >= 0;
        bool camBRX_lt_w = camBR.X() < level->getMapWidth();
        bool camBRY_lt_h = camBR.Y() < level->getMapHeight();

        // adjust display and camera coordinates accordingly
        int dispTL_X = camTLX_gt_0 ? dispTL.X() : dispTL.X() - camTL.X();
        int dispTL_Y = camTLY_gt_0 ? dispTL.Y() : dispTL.Y() - camTL.Y();
        int dispBR_X = camBRX_lt_w ? dispBR.X() : dispBR.X() + (level->getMapWidth() - camBR.X());    // '-1' not necessary here, for some reason.
        int dispBR_Y = camBRY_lt_h ? dispBR.Y() : dispBR.Y() + (level->getMapHeight() - camBR.Y()-1); // '-1' necessary to avoid drawing tiles off the edge of the map 
        int camTL_X  = (camTL.X() >= 0) ? camTL.X() : 0;
        int camTL_Y  = (camTL.Y() >= 0) ? camTL.Y() : 0;

        int a,b,x,y; // loop variables. (a,b) - console location; (x,y) map location
        TileInfo tileInfo;
        for(a=dispTL_X, x=camTL_X; a<dispBR_X; ++a, ++x)
        {
            for(b=dispTL_Y, y=camTL_Y; b<dispBR_Y; ++b, ++y)
            {
                try 
                {
                    tileInfo = level->getTileInfo(x,y);
                    _playfield->putCharEx(a,b, tileInfo.ascii, tileInfo.fgColor, tileInfo.bgColor);
                }
                catch(std::out_of_range&)
                {
                    cerr << "map exception caught" << endl;
                }
            }
        }

        drawLevelItems(level);
        drawLevelOccupants(level);
    }
예제 #15
0
bool AppenderSkeleton::isAsSevereAsThreshold(const LevelPtr& level) const
{
        return ((level == 0) || level->isGreaterOrEqual(threshold));
}