コード例 #1
0
ファイル: layertax.cpp プロジェクト: KSLcom/caesaria-game
void Tax::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
    Point screenPos = tile.mappos() + offset;

    if( tile.overlay().isNull() )
    {
        //draw background
        engine.draw( tile.picture(), screenPos );
    }
    else
    {
        bool needDrawAnimations = false;
        TileOverlayPtr overlay = tile.overlay();

        int taxLevel = -1;
        if( _isVisibleObject( overlay->type() ) )
        {
            // Base set of visible objects
            needDrawAnimations = true;
        }
        else if( overlay->type() == objects::house )
        {
            HousePtr house = ptr_cast<House>( overlay );
            //taxLevel = house->getServiceValue( Service::forum );
            taxLevel = math::clamp<int>( house->taxesThisYear(), 0, 100 );
            needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());

            if( needDrawAnimations  )
            {
                int taxAccess = house->hasServiceAccess( Service::forum );
                needDrawAnimations = (taxAccess < 25);
            }

            if( !needDrawAnimations )
            {
                city::Helper helper( _city() );
                drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
            }
        }
        else
        {
            city::Helper helper( _city() );
            drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
        }

        if( needDrawAnimations )
        {
            Layer::drawTile( engine, tile, offset );
            registerTileForRendering( tile );
        }
        else if( taxLevel > 0 )
        {
            _addColumn( screenPos, taxLevel );
            //drawColumn( engine, screenPos, taxLevel );
        }
    }

    tile.setWasDrawn();
}
コード例 #2
0
void Entertainment::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
  Point screenPos = tile.mappos() + offset;

  if( tile.overlay().isNull() )
  {
    //draw background
    //engine.draw( tile.picture(), screenPos );

    drawPass( engine, tile, offset, Renderer::ground );
    drawPass( engine, tile, offset, Renderer::groundAnimation );
  }
  else
  {
    bool needDrawAnimations = false;
    OverlayPtr overlay = tile.overlay();

    int entertainmentLevel = -1;
    if( _isVisibleObject( overlay->type() ) )
    {
      // Base set of visible objects
      needDrawAnimations = true;
    }
    else if( _flags.count( overlay->type() ) > 0 )
    {
      needDrawAnimations = true;
      //if( !needDrawAnimations )
      //{
      //  city::Helper helper( _city() );
      //  drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
      //}
    }
    else if( overlay->type() == object::house )
    {
      HousePtr house = ptr_cast<House>( overlay );
      entertainmentLevel = _getLevelValue( house );

      needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());
      drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
    }
    else
    {
      drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
    }

    if( needDrawAnimations )
    {
      Layer::drawTile( engine, tile, offset );
      registerTileForRendering( tile );
    }
    else if( entertainmentLevel > 0 )
    {
      _addColumn( screenPos, entertainmentLevel );
    }
  }

  tile.setWasDrawn();
}
コード例 #3
0
ファイル: layerfire.cpp プロジェクト: b606/caesaria-game
void Fire::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
  Point screenPos = tile.mappos() + offset;

  if( tile.overlay().isNull() )
  {
    //draw background
    //engine.draw( tile.picture(), screenPos );

    drawPass( engine, tile, offset, Renderer::ground );
    drawPass( engine, tile, offset, Renderer::groundAnimation );
  }
  else
  {
    bool needDrawAnimations = false;
    OverlayPtr overlay = tile.overlay();
    int fireLevel = 0;
    if( _isVisibleObject( overlay->type() ) )
    {
      // Base set of visible objects
      needDrawAnimations = true;
    }
    else if( overlay->type() == object::house )
    {
      HousePtr house = ptr_cast<House>( overlay );
      fireLevel = (int)house->state( pr::fire );
      needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
      drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase  );
    }
    else //other buildings
    {
      ConstructionPtr constr = ptr_cast<Construction>( overlay );
      if( constr != 0 )
      {
        fireLevel = (int)constr->state( pr::fire );
      }

      drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base  );
    }

    if( needDrawAnimations )
    {
      Layer::drawTile( engine, tile, offset );
      registerTileForRendering( tile );
    }
    else if( fireLevel >= 0)
    {
      _addColumn( screenPos, fireLevel );
    }
  }

  tile.setWasDrawn();
}
コード例 #4
0
void LayerEntertainment::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
  Point screenPos = tile.mappos() + offset;

  if( tile.overlay().isNull() )
  {
    //draw background
    engine.draw( tile.picture(), screenPos );
  }
  else
  {
    bool needDrawAnimations = false;
    TileOverlayPtr overlay = tile.overlay();

    int entertainmentLevel = -1;
    switch( overlay->type() )
    {
    // Base set of visible objects
    case construction::road:
    case construction::plaza:
    case construction::garden:

    case building::burnedRuins:
    case building::collapsedRuins:

    case building::lowBridge:
    case building::highBridge:

    case building::elevation:
    case building::rift:
      needDrawAnimations = true;
    break;

    case building::theater:
    case building::amphitheater:
    case building::colloseum:
    case building::hippodrome:
    case building::lionsNursery:
    case building::actorColony:
    case building::gladiatorSchool:
      needDrawAnimations = _flags.count( overlay->type() ) > 0;
      if( !needDrawAnimations )
      {
        city::Helper helper( _city() );
        drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
      }
    break;

      //houses
    case building::house:
      {
        HousePtr house = ptr_cast<House>( overlay );
        entertainmentLevel = _getLevelValue( house );

        needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty());
        city::Helper helper( _city() );
        drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
      }
    break;

      //other buildings
    default:
      {
        city::Helper helper( _city() );
        drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
      }
    break;
    }

    if( needDrawAnimations )
    {
      Layer::drawTile( engine, tile, offset );
      registerTileForRendering( tile );
    }
    else if( entertainmentLevel > 0 )
    {
      _addColumn( screenPos, entertainmentLevel );
    }
  }

  tile.setWasDrawn();
}